font = doc:LoadFont(name[, weight, slant, embed])
doc:LoadFont()
loads a font using Hollywood and registers it in the document object. If the optional
embed
argument is set to True
, the glyph data of the font is embedded, otherwise only the matrix data is included
in the PDF file.
Note that only TrueType fonts can be used with this method. You cannot use bitmap fonts in PDF documents.
The optional arguments weight
and slant
can be used to specify a font weight and slant. The following
can be passed in the weight
parameter:
#FONTWEIGHT_THIN #FONTWEIGHT_EXTRALIGHT #FONTWEIGHT_ULTRALIGHT #FONTWEIGHT_LIGHT #FONTWEIGHT_BOOK #FONTWEIGHT_NORMAL (default) #FONTWEIGHT_REGULAR #FONTWEIGHT_MEDIUM #FONTWEIGHT_SEMIBOLD #FONTWEIGHT_DEMIBOLD #FONTWEIGHT_BOLD #FONTWEIGHT_EXTRABOLD #FONTWEIGHT_ULTRABOLD #FONTWEIGHT_HEAVY #FONTWEIGHT_BLACK #FONTWEIGHT_EXTRABLACK #FONTWEIGHT_ULTRABLACK |
The following constants can be passed in the slant
parameter:
#FONTSLANT_ROMAN (default) #FONTSLANT_ITALIC #FONTSLANT_OBLIQUE |
When doc:LoadTTFont() succeeds, it returns the name of a font. Otherwise, it returns Nil
and the error handler is called.
#FONTWEIGHT_NORMAL
)#FONTSLANT_ROMAN
)True
, the glyph data of the font is embedded, otherwise only the matrix data is included in PDF file#HPDF_INVALID_DOCUMENT
- An invalid document handle was set.
#HPDF_FAILED_TO_ALLOC_MEM
- Memory allocation failed.
#HPDF_FONT_EXISTS
- The font of the same name has already been registered.
#HPDF_TTF_INVALID_CMAP
- Failed to load .ttf file.
#HPDF_TTF_INVALID_FORMAT
- Failed to load .ttf file.
#HPDF_TTF_MISSING_TABLE
- Failed to load .ttf file.
#HPDF_TTF_CANNOT_EMBEDDING_FONT
- The font doesn't allow embedding.