Convert CFF fonts into OpenType fonts programmatically

旧城冷巷雨未停 提交于 2019-12-04 15:06:39

Util now, I got 3 libraries as reference:

  1. FreeType: mainly in cff package, and main entry is cff\cffload.c, now in github
  2. FontForge: fontforge\parsettf.c, still in sf.net
  3. fonttools: fonttools\cffLib.py, in sf.net
  4. ots tools: http://code.google.com/p/ots/source/browse/trunk/src/cff.cc

In parsettf.c, George Williams write: True Type is a really icky format. ...now that I understand it better it seems better designed but the docs remain in conflict. Sometimes badly so.

IMO, the cff doc same bad. Maybe it better designed. Just maybe, if I have time:) I will confirm the maybe. Why? look at the creation time of those thing, too old.

What is better only if older? Parent, math and filosophy:) Anything others must uptodate!

CFF(Compact Font Format) is mainly used for embedded PostScript font in PDF files. And you can also find CFF in OpenType font files which is based on PostScript outlines.

If you got CFF from the embedded font file of a PDF, you can get a PostScript name from the NameIndex of the CFF. You should find the corresponding OpenType File by the PostScript Name.

If you got CFF from a OpenType file, why did you ask this question? :-D

Simon Mourier

I quote this link: Raster, Vector, TrueType, and OpenType Fonts

... the glyphs for a font are stored in a font-resource file. ...

So, Windows loads glyphs from a file with a format that it understands, not a CFF file, and not a structure from memory. If you want to draw CFF files without using a file conversion tool, I think you will need to load the CFF and draw the glyphs by yourself.

To load the CFF and determine the glyph, you can use the FreeType Project. Here is a link here on SO that explain how to build a Win32 DLL from FreeType source: Compiling FreeType to DLL (as opposed to static library)

To draw the glyphs, you can get some inspiration from the gdipp project, which is a replacement of the Windows text renderer, and contains Win32 C/C++ sample code that display glyphs loaded from FreeType.

It appears that the CFF format was made to be embedded directly into an OpenType file. Microsoft has a good overview of OpenType files: http://www.microsoft.com/typography/otspec/otff.htm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!