TTF to OTF conversion #2836
-
I am trying to write a command line TTF to OTF converter as follows:
When saving the OTF file, fontTools prints the following warning:
For GSUB table, this code seems to work:
Is there a faster and more elegant way to process all the |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 16 replies
-
I can't answer your question, but I feel you're going about the conversion the wrong way. The font doesn't need to change much: just convert the glyf outlines to CFF outlines. See |
Beta Was this translation helpful? Give feedback.
-
Thanks, very interesting. For sure wil be faster than ttf -> ttx -> ufo -> otf. I fear that |
Beta Was this translation helpful? Give feedback.
-
The point is, you don't need to decompile/recompile any features if the glyph order stays the same. You can literally use the same GSUB/GPOS binary data, and there is no need to call |
Beta Was this translation helpful? Give feedback.
-
Definitely I changed the glyphs order. In the original file that warning doesn’t appear. Thanks for your replies, the FontBuilder way will be faster for sure. I’m just trying to understand how to draw the glyphs, but copying the other tables is very easy |
Beta Was this translation helpful? Give feedback.
-
For the record, to suppress the
On the other side, when I try to convert the font using FontBuilder:
It fails when saving the output file:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks, works fine even if it produces a bigger CFF table than the reference OTF. What caused the CFF table compilation error was this line, where I enclosed "Test" into brackets:
Correct:
|
Beta Was this translation helpful? Give feedback.
-
I'm trying to simplify of outlines of the converted OTF font. The steps are the following:
Here's a comparison of the original TTF (left) file with the converted one (right) And here's the converted file (right) compared with the same font converted with makeotf (left) I'm aware that the contours can be simplified with FontForge, but I was wondering if there's a pure Python solution to simplify the outlines and get a result similar to the one produced by makeotf. |
Beta Was this translation helpful? Give feedback.
-
I'm wondering what the subject line has to do with the actual topic. :) |
Beta Was this translation helpful? Give feedback.
I can't answer your question, but I feel you're going about the conversion the wrong way.
The font doesn't need to change much: just convert the glyf outlines to CFF outlines. See
ttFont.getGlyphSet()
for outline extraction andfontTools.fontBuilder.FontBuilder
for how to build a CFF table with T2 outlines. Make sure to keep the same glyph order, and not a single byte needs changing in GSUB/GPOS and many other tables.