相关文章推荐
有情有义的大白菜  ·  python ...·  3 周前    · 
完美的馒头  ·  python QTreeWidget ...·  3 周前    · 
失眠的烤红薯  ·  python qt textBrowser ...·  2 周前    · 
帅气的领带  ·  【Pyspark ...·  2 天前    · 
近视的橙子  ·  python ...·  16 小时前    · 
飞翔的打火机  ·  Communications link ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to generate a ttf font file from a bunch of SVGs or PNGs. Every time I try, I get the error:

"Warning: Font contained no glyphs"

I've tried this on Mac and Linux:

font = fontforge.font()
glyph = font.createChar(65, "font1")
glyph.importOutlines("1.png")
glyph2 = font.createChar(66, "font2")
glyph2.importOutlines("2.png")
glyph3 = font.createChar(67, "font3")
glyph3.importOutlines("3.png")
font.generate("output.ttf")

I tried the hints on: Import a sequence of .svg files into FontForge as glyphs and output a font file

but still couldn't get it to work.

If anyone has any ideas on a better library I can call from commmandline to convert SVG to TTF, that would be great.

because ttf font use vector graphics. you need to vecotrize your png's en.wikipedia.org/wiki/TrueType how to make a vector from png goinkscape.com/how-to-vectorize-in-inkscape – Nivatius Dec 4, 2018 at 13:40

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.