EmbedFontProgram

Text, Fonts

Description

Resolves the font name against installed system fonts and embeds the TrueType/OpenType font program into the PDF document.

Syntax

Delphi

Function TPDFlib.EmbedFontProgram(Const FontName: WideString): Integer;

Parameters

FontNameThe name of the font to embed (e.g., 'Arial').

Return values

0The font program could not be embedded
Non-zeroThe ID of the font or success indicator

Remarks

An installed font is used only when it is the requested family, spaces and case aside, and its face carries the requested bold and italic style, read from the BaseFont suffix such as ,Bold, -BoldMT or -Oblique. A substitute the system font mapper would pick, or a regular face that would only be emboldened on screen, is not embedded, so the font stays unembedded rather than receiving a program whose glyphs and widths differ

A glyf-based TrueType program goes into TrueType and CIDFontType2 fonts as FontFile2; a CIDFontType0 font receives only an OpenType CFF program, written as FontFile3 /OpenType. Installed fonts are read on Windows only, and Type 1 fonts are not embedded by this method

A CFF program is written as an OpenType font file, a stream type introduced in PDF 1.6, so a document below PDF 1.6 is raised to that version; when LockSaveVersion pins a lower version, saving fails with LastErrorCode 602 instead