Embedding and Extracting Fonts
Posted on 2000-03-17
I'd like to be able to embed a Windows TrueType font in a proprietary-format document. Therefore, I need to know the following:
(1) How to obtain the data for a font, given the name by which the font is registered in Windows. For example, if I specified the "Courier New" font, where would you obtain the appropriate data (as a string)? Is there a way to get the path and filename for each Windows TT font?
(2) Once the data has been stored (and later retrieved), how would you go about installing the font in Windows? The obvious idea would be to write the data to a file in the Windows font directory, then add the font programatically. However, I would prefer to create a "virtual" font that would be usable by my application only and would cease to exist once the application is finished with it.
To get a better idea of what I need to do, think about an Adobe Acrobat (PDF) file. If you create a PDF on another system and utilize a non-standard TrueType font, that font is embedded in the document. If you open (read) the PDF on another PC, it looks the same --even though you may not have that font --- because the font data is embedded within the document. I'm sure you get the idea.
What I'd really like to see is a simple application that writes a font's data to disk in a Binary file, then reads the file and creates the font on-the-fly without actually installing it in Windows.
Good luck, guys, and thanks for reading this far!