This content has been marked as final. Show 5 replies
You can use GetCharABCWidths() to get widths out of TrueType fonts. It's arguable that it is better to read the raw widths out of the .TTF file, but for Arial Unicode MS, life is complicated, because regular, bold, italic, etc. are all contained in the one file.
Yes I've tried with GetCharABCWidths() but the values returned were <100 but the values in the Horizontal Measurements Table are >1000 sometimes. It's there a formula to compute this? Or the HMT doesn't contain correct values? The table was extracted using TTFDump.exe provided by Microsoft.
You have to scale the TTF widths in the table you get using TTFDump.exe into PDF font units. The unitsPerEm value in the font dump tells you how many units there are per Em in the TTF. PDF uses 1000 units per EM. So a capital W might be more than 1000.
The scaling formula is (advance * 1000) / unitsPerEm. So, if units per Em in the TTF is 2048, and you see an advance of 1024 for a glyph, you scale that to 500 for PDF.
The widths you get from GetABCWidths() depend on the device context and the font size, so you would have to scale those also. In general, for PDF, I prefer the raw widths in the TTF. The table structure for the widths is really very simple to read.
Can u tell me how to extract the table from the font file?
Maybe a API function or a software.
Read the documentation: http://www.microsoft.com/typography/otspec/otff.htm
Write a couple of hundred lines of code (or pay someone to do that for you).