When SVG file contains embedded font in the <defs> element using @font-face with the data URL, the font is not loaded and a substitute font is used instead.
This only happens when SVG image is included with the <img> tag. However, if the SVG code is embedded directly into HTML, the @font-face instructions within the SVG code are processed correctly.
Sample SVG File
Sample HTML:
Debug log:
It seems a reference to the 'my math font' in the SVG file is not even processed. There is nothing in the debug log about it.
Expected log:
This is what happens when SVG is directly embedded in HTML, but not when it is loaded via the <img> tag.
Prince version: 13.6
This only happens when SVG image is included with the <img> tag. However, if the SVG code is embedded directly into HTML, the @font-face instructions within the SVG code are processed correctly.
Sample SVG File
Sample HTML:
<html>
<head><title>SVG Demo</title></head>
<body>
<p>Font embedded in the external SVG file and is loaded in the <defs> element of the SVG file</p>
<p><img src="https://test-dmitry.au.coredna.dev/assets/formulae_embedded.svg" width="120" height="120"></p>
</body>
</html>
Debug log:
prince: Preparing document...
prince: debug: [prefetch-1] loading https://test-dmitry.au.coredna.dev/assets/formulae_embedded.svg
prince: debug: stopping prefetch threads
prince: debug: [prefetch-1] loaded https://test-dmitry.au.coredna.dev/assets/formulae_embedded.svg
prince: Converting document...
prince: debug: pack
prince: debug: font request: serif
prince: debug: font scan: Times New Roman
prince: debug: font scan: Times New Roman, 4 matches
...
prince: debug: font scan: Garuda
prince: debug: font scan: Garuda, 0 matches
prince: loading font: /usr/share/fonts/webcore/times.ttf
prince: debug: loaded resource: /usr/share/fonts/webcore/times.ttf
prince: debug: loaded resource: type: no
prince: used font: Times New Roman, Regular
prince: debug: writing PDF to file: output.pdf
prince: Finished: success
It seems a reference to the 'my math font' in the SVG file is not even processed. There is nothing in the debug log about it.
Expected log:
prince: Preparing document...
prince: debug: stopping prefetch threads
prince: Converting document...
prince: debug: pack
...
prince: debug: font request: my math font
prince: loading font: data URL
prince: debug: loaded resource: data URL
prince: debug: loaded resource: type: yes(resource_type("font/truetype", ["charset" - "utf-8"], unknown, yes(utf8)))
prince: used font: Horizontal Font, Regular
...
prince: Finished: success
This is what happens when SVG is directly embedded in HTML, but not when it is loaded via the <img> tag.
Prince version: 13.6