return pFont; } GetFontData使得应用程序能够在自己的文档中内嵌TrueType字体,以确保这些文档能在没有相应字体的其他机器上显示。它的做法是允 许应用程序查询字体数据,然后写入到文档中作为文档的一部分,在文档被打于时再安装该字体以确保文档能以创建时同样的方式显示。比如,Windows NT/2000的假脱机程序在打印到远端服务器时会在假脱机文件中内嵌入TrueType字体以保证文档能在另一台机器上正确地打印。 一旦接受到TrueType字体的原始数据,它的头中的TableDirectory结构很容易分析。需要检查的只有版本号和表的数目,然后就可以检查单个的表。我们来看一些重要的和有趣的表。 1.字体头 字体头表(head表)中包含了TrueType字体的全局信息。下面是字体头表的结构。 typedef sturct {
Fixed Table;//x00010000 ro version 1.0 Fixed fontRevision;//Set by font manufacturer. ULONG checkSumAdjustment; ULONG magicNumer; //Set to 0x5f0f3cf5 USHORT flags; USHORT unitsPerEm; //Valid range is from 16 to 16384 longDT created; //International date (8-byte field). longDT modified; //International date (8-byte field). FWord xMin; //For all glyph bounding boxes. FWord yMin; //For all glyph bounding boxes. FWord xMax; //For all glyph bounding boxes. FWord xMax; //For all glyph bounding boxes. USHORT macStyle; USHORT lowestRecPPEM; //Smallest readable size in pixels. SHORT fontDirctionHint; SHORT indexToLocFormat; //0 for short offsets ,1 for long. SHORT glyphDataFormat; //0 for current format. }Table_head;