2
votes

Does anyone have any pointers where I can find extra information on how to create an opentype wrapper around a CFF font?

Currently I have a parser for CFF files so I can get all sorts of information out of it (cmap, glyph names, widths, names etc etc). Given this information I am unable to create an Opentype (truetype format like) wrapper so I can use the font on Windows using GDI; GDI will not load the Opentype font and the only thing I know is that it fails to load the font.

Does anyone know any additional information, validation applications, example code, get additional information why the font does not load from Windows etc etc?

Note: I am looking for information how to do it, not utilities and/or conversion tools.

4
I've got to ask, where did you find a CFF font file? I've never seen one, and a search came up empty. There's OpenType/CFF but those already have the wrapper.Mark Ransom
@Mark: look into PDF files, there usually subsets are embedded. TYou find them also within OTF fonts (naturally). At the moment I am trying to render PDF files to GDI device contexts (screen/printer) and also need to render some CFF embedded fonts. hence the question. The documentation given in the OpenType file format description from Microsoft are not very clear on how to build this wrapper (it's a format record structure description, not a how to).Ritsaert Hornstra
The short following question: OpenType font files have CFF table inside. I can simply extract it by the offset address and size in the dictionary table. In PDF file, font resource objects, /FontFile3 stream contents deflated CFF font file. Are that the same CFFs or not? Actually, when I see on the binary, I can see some differences, like FontName in the file is Font-Name, but in the PDF it is FHDH+Font-Name etc. PDF excerpt is shorter, which means for me it is the part of whole CFF of font file. Can I include the whole CFF part of the font file in resource stream of PDF file?Ruben Kazumov
@user1543083: There are several changes that can be made to the CFF font file. First: it is the same font file but names are different (due to PDF standard) Subsetting (only leaving the used glyphs) makes the file smaller and is also common practice.Ritsaert Hornstra
OK, finally I have got the CFF table of an OTF font. Can you help me to find in which index/dict/place/offset/section etc. I have to digg to find a some GLYPH WIDTH parameter value (not average glyph width, not min/max glyph width, just a glyph width of some glyph)? I am trying to find some information about subject in "ISO/IEC STANDARD 14496-22 Open Font Format" and "The Compact Font Format Specification Version 1.0", but nothing found.Ruben Kazumov

4 Answers

1
votes

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!

1
votes

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

0
votes

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.

0
votes

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