Basically, what I am trying to do is to use a standard Windows font selection dialog to select the font that I will use with FreeType.
The output from the font dialog is a Windows LOGFONT structure that contains information about the font, such as the weight, charset, face name, etc. Unfortunately, there is no function in Windows for getting the file name of the font, nor for getting the index of the font in the file, in the case of .ttc files. The solution I found was to create a Windows font from the LOGFONT structure, select the font into a Windows device context, and then use the Windows function GetFontData to extract a data buffer defining the font. This buffer corresponds to the contents of the font file, EXCEPT for .ttc files! For .ttc files, the buffer corresponds to the file content, beginning at the start of the definition of the face that the LOGFONT describes. Because the offsets in the face's table directories are from the beginning of the FILE, these offsets are now useless because in the file there is an unknown amount of data (TTCHeader + maybe other faces) before the data block that was returned by GetFontData. Therefore, FT_New_Memory_Face fails. An example: The file batang.ttc contains - TTCHeader - Face 0: Batang - Face 1: BatangChe - Face 2: Gungsuh - Face 3: GungsuhChe If I select Gungsuh then GetFontData returns a buffer containing the part of the file that contains Gungsuh and GungsuhChe. Gungsuh is situated at offset 96624 in the file, so the offsets in the table directories for Gungsuh are off by 96624 bytes! The question is, is there a way to make FreeType able to use the data? Or are there any alternative solutions that will allow me to create the proper FreeType face from a LOGFONT description? /Niels-Peter _______________________________________________ Freetype mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/freetype
