I am trying to transfer PDF content to the context of a GDI device (more precisely, a 24-bit bitmap). Parsing a PDF stream into PDF objects and rendering PDF commands from a content dictionary works well, including font rendering.
Embedded fonts are unpacked from FontFile streams and "loaded" using AddFontMemResourceEx . Now some inline fonts delete some TrueType tables that GDI needs, such as the "name" table. Because of this, I tried to change the font by analyzing the font of the subset of TrueType in its tables and changing those tables in which the missing / missing data tables are regenerated with the maximum possible information.
I use the Microsoft Font Validator tool to see how the “correct” font is created. I am still getting a few errors, for example, for the maxp table, the maximum values are usually too large (this is a subset), or the xAvgCharWidth field xAvgCharWidth not equal to the calculated value of the "OS / 2" table, but this is incorrect, but this does not stop the use of other built-in fonts. Fonts embedded with PDFCreator are problematic.
Questions:
- How can I determine that I need to go to the font file in order for GDI to be able to use it?
- Are there any other font checking tools that can give me insight into what is still wrong with fontfile?
If necessary: I can create a source font file and a modified font file that can be downloaded anywhere.
What changes have been made so far:
- Make sure there is a section called "head", "hhea", "maxp" and "OS / 2".
- If we have a character font, clear the Panose and Unicode fields in the "OS / 2" section
- Fill in the correct values for WInAscent / Desc and TypoAsc / Desc if they are zero.
- Fill in the valid values for the positions and sizes of the super / substring / underline.
- Scan all the glyphs that are left, fill in the minimum / maximum X / Y values in the head.
- Rebuild the name section with information from the PDF file from which it came.
pdf embedded-fonts true-type-fonts gdi
Ritsaert hornstra
source share