DynaPDF Manual - Page 565

Previous Page 564   Index   Next Page 566

Function Reference
Page 565 of 839
Return values:
If the function succeeds the return value is a CMap handle, a value greater or equal zero. If the
function fails the return value is a negative error code. The CMap handle is required to load a CID
font with this CMap.
LoadFont
Syntax:
SI32 pdfLoadFont(
const PPDF* IPDF,
// Instance pointer
const void* Buffer, // Font file buffer
UI32 BufSize,
// Buffer size in bytes
TFStyle Style,
// Font style
double Size,
// Font size
LBOOL Embed,
// If true, the font will be embedded
TCodepage CP)
// Code page
The function loads a font from a file buffer and activates it in the graphics state if the function was
called within an open page or template. Supported font formats are TrueType, OpenType, and
Type1 fonts in PFB or PFA format.
It is also possible to load fonts directly from a font file with LoadFontEx(). This function is preferred
because it is more flexible and reduces the memory usage.
The function returns the font handle on success. The font handle is required whenever the font
should be set again with ChangeFont(), e.g. when opening a new page or if the font was changed to
another one.
The function does not check whether the font was already loaded in a previous call. The caller must
make sure that no unnecessary duplicates will be loaded. However, if the font should be used with
different code pages, a separate copy of the font is required for each code page.
The parameter Style sets the style flags fsUnderlined, fsStriked, or fsVerticalLayout only. It is also
possible to emulate font styles with manually loaded fonts. Use the function ChangeFontStyleEx() if
a font style should be emulated.
If the font name is known by the caller then it is also possible to set this font later with SetFont().
However, for proper behaviour manually loaded fonts should always be set with ChangeFont().
If SetFont() is used then there is no guarantee that the function loads exactly this font because the
function tries to load the best match according to the provided parameters.
Note that a font that was loaded with this function can only be used with the code page that was
used to load the font. If the code page must be changed then you must load a further copy of the
font. To reduce the memory usage, it is recommended to use LoadFontEx() instead, because this
function loads only required parts of the font file and it provides generally a better resource
handling.
 

Previous topic: Working with External CMaps

Next topic: TrueType Collections, LoadFontEx