GDI Font Installation and Printing
I learned something new about GDI font installation and printing recently. So if you're use functions like AddFontResourceEx or AddFontMemResourceEx to install fonts in your application and your application supports printing, you may want to continue reading.
- Font name collision: if you install a font which has the same full name as an existing font already installed on the system, you do not have a way to tell GDI to use it. In GDI API, there is no way to specify a physical font, you can only provide a logical description of a font you want and then let GDI pick the right physical font for you. So when name collision occurs, GDI is more likely to match logical font with an existing font. To solve this problem, you need to rename the font before installing it. By renaming, I meant you need to walk through the TrueType font name table and update font name, and then use the new name to describe logical font to GDI. Also, once you touch the name table, please also update its checksum. Here is the specification to read http://www.microsoft.com/typography/otspec/name.htm
- Life time of fonts. If your application supports printing, GDI can handle non-EMF spooling and EMF spooling to another machine properly. In the first case, printer driver will be processing the print job in your application's address space; in the second case, these fonts will be embedded into EMF spool files unless the exact same fonts are on the remote machine. But the third case of local EMF spooling needs little bit of attention. When printing using EMF spooling to a local printer, GDI does not embed fonts into EMF spool file, but somehow the fonts are still available to printer driver running in the spooler process. There is one catch though, the fonts can't be uninstalled before the print job is processed. For example, if you have a document on your desktop which uses an embedded font, you right-mouse click, select the Print command to print it to a local printer using EMF spooling , there is a chance that any text using embedded fonts will not print properly. The reason is that application is only opened briefly to print the document, so when the printer driver is handling the document in the spooler process, the original fonts are already gone.