Xojo Conferences

DynaPDF Manual - Page 377

Previous Page 376   Index   Next Page 378

Function Reference
Page 377 of 766
This function is marked as obsolete since an extended version is available now. Please use
GetFontInfo() if possible.
The function returns the most important properties of a font. The parameter IFont must be a valid
pointer to a font object. Such a pointer is returned by GetPageText(), EnumDocFonts(), or by the
content parser (see ParseContent()). The parameter F must be a valid pointer to a TPDFFontObj
The font metrics such as Ascent, Descent, Widths, and so on are returned in font units. The values
must be scaled to the given font size as follows:
double scale
= FontSize / 1000.0;
double ascent
= font.Ascent
* scale;
double descent = font.Descent * scale;
The font’s encoding consists of exactly 256 Unicode values if set. The encoding is not set if a CID font
is selected.
The font flags describe certain properties of the font. The most important flags are the following:
// Fixed pitch font
// Serif style
// Symbol font
// Script style
// Non-symbolic font
// Italic style
0x40000 // Force Bold (Type1 fonts only)
The full set of available flags can be found in the PDF Reference.
The member FontFile provides a pointer to the font file buffer if the font is embedded and if it was
imported from an external PDF file. In this case and if the font type is not ftType1 the member
Length1 specifies the length of the font buffer.
Type1 fonts consist of three portions. Length1 specifies the length of the clear text portion, Length2
specifies the length of the eexec encrypted binary portion, and Length3 specifies the length of the
fixed content portion (512 zeros plus cleartomark). The latter portion is optional and mostly not set
in PDF fonts. The buffer length is the sum of the three lengths.
If the font was loaded from the system the parameter FontFile contains the file path to the font file.
The member Length1 is set to zero in this case.
Since DynaPDF the default string format for font file paths on Windows was changed to
UTF-16. You can make a type cast to UI16* on Windows, as long as the Ansi version of
AddFontSearchPath() will not be used.
The function does not use the exception handling of DynaPDF. No error message is set if the
function fails. However, the only possible error is out of memory if the parameters are valid.

Previous topic: GetFont (obsolete)

Next topic: GetFontInfo