Closed 00sapo closed 1 year ago
Hi Frederico,
To assemble the OT-SVG font you're using your own scripts, as opposed to using the ones provided with opentype-svg
, so my ability to help you is limited.
I also don't know how well Inkscape or LuaLaTeX PDF support OpenType-SVG fonts. It's possible that the issues you're facing are caused by bugs in those applications, rather than problems with your font.
Having said that, I'll mention a few points that might help you with your project:
viewBox
, width
, and height
parameters from the SVG file helps with fixing scaling and positioning problems. But this assumes that 1) the SVG artwork was designed at the same scale as the font's unitsPerEm, and 2) the SVG artwork is positioned on the canvas in a way that aligns with the font's origin coordinates (i.e. baseline and left sidebearing).viewBox
, width
, and height
parameters from your a.svg file and open it in Adobe Illustrator, I see the artwork way off canvas (screenshot below). The baseline of the a should be touching the top of the page, and the whole letter needs to be moved to the left, in order to be closer to the page's origin (see second screenshot, and notice the rulers). Thank you so much. I still don't have a clear rule to follow for rescaling the images, but your words pointed me towards a rule of thumbs that works in my case. I managed to obtain a meaningful size by transposing and rescaling the SVG using a transform attribute and then applying the transform attribute to each inner object using an Inkscape extension (without using Inkscape, actually, only its python extension module inkex
)
cross-linking: https://github.com/fonttools/fonttools/discussions/3229
I am opening this issue only because I think you can really help me with this problem. Basically, I have an SVG an OTF font and I want to attach the SVG to the font programmatically. For this, I'm using
opentype-svg
andfonttools
, but the final font contains badly scaled glyphs.Here the problem is explained in more details. Here is the source code for reproducing the issue: Archive.zip
1. Dummy Font Creation
First, I create a dummy font having dummy glyphs. In this example, only the glyph
a
is created. For this, I use fontforge.To run the script, install fontforge and python and run
fontforge -script example_dummy.py
. A file namedDummyFont.otf
will be created. It's also attached in the zip.2. Attaching SVG Files
The second step is to attach SVG files in the SVG table of the font. As suggested by opentypesvg tool, I remove both widht and height, as well as the viewport property of the
<svg>
tag. The problem is that the SVGs are not rescaled properly. In both LuaTeX and Inkscape, they appear to have a small size compared to the glyph viewport. Below are two screenshots of the result.To run the script, run
pip install opentypesvg fonttools
and thenpython example_svg.py
. A file namedDummyFontSvg.otf
will be created. It's also attached in the zip.3. Result
Terminal output: (note that SVG and font have the same viewport and that font is correctly validated by fontforge)![screenshot_terminal](https://github.com/adobe-type-tools/opentype-svg/assets/22996003/00a43751-d6ca-44e9-a674-cae6ac6aa02b)
Inkscape: (the green background is the text-selection color of one character, it shows the maximum size a glyph can have)![Screenshot_inkscape](https://github.com/adobe-type-tools/opentype-svg/assets/22996003/5322758d-f218-4ac1-b4b4-1139d9daa6db)
LuaLaTeX PDF:![screenshot_latex](https://github.com/adobe-type-tools/opentype-svg/assets/22996003/3bc18657-12f5-458c-8d62-ebf8d7923f43)