Altering an embedded truetype font so it will be useable by Windows GDI
Posted
by Ritsaert Hornstra
on Stack Overflow
See other posts from Stack Overflow
or by Ritsaert Hornstra
Published on 2010-06-14T10:10:07Z
Indexed on
2010/06/14
10:12 UTC
Read the original article
Hit count: 283
I am trying to render PDF content to a GDI device context (a 24bit bitmap to be exact). Parsing the PDF stream into PDF objects and rendering the PDF commands from the content dictionary works well, inclduing font rendering.
Embedded fonts are decompressed from their FontFile streams and "loaded" using AddFontMemResourceEx. Now some embedded fonts remove some TrueType tables that are needed by GDI, like the NAME table. Because of this, I tried to modify the font by parsing the TrueType subset font into it's tables and modify those tables that have data missing / missing tables are regenerated with as correct information as possible.
I use the Microsoft Font Validator tool to see how "correct" the generated font is. I still get a few errors, like for the maxp table the max values are usually too large (it is a subset) or The xAvgCharWidth field does not equal the calculated value of the OS/2 table is not correct but this does not stop other embedded fonts to be useable.The fonts embedded using PDFCreator are the ones that are problematic.
Question: - How can I determine what I need to change to the font file in order for GDI to be able to use it? - Are there any other font validation tools that might give me insight into what is still wrong with the fontfile?
If needed: I can make an original fontfile and an altered fontfile available for download somewhere.
© Stack Overflow or respective owner