EmbedFont(ReadOnlyMemory, Int32) Method

Definition

Namespace Broadside
Assembly Broadside.dll

Embeds a TrueType, OpenType, CFF or Type 1 program a PdfCanvas of this document can show any text its glyphs cover with, subset to the glyphs shown.

public PdfCanvasFont EmbedFont(ReadOnlyMemory<byte> program, int faceIndex = 0)

Parameters

program
ReadOnlyMemory<Byte>

The program: a TrueType or OpenType file (.ttf, .otf, with glyf or CFF outlines), a collection (.ttc, .otc) with faceIndex, a bare CFF program with Type 2 charstrings, or a Type 1 program (.pfa, .pfb).

faceIndex
Int32

The face of a collection; 0 for a single font.

Returns

PdfCanvasFont
The font. Calls with the same program memory and face return fonts over one font of the document.

Remarks

TrueType outlines embed as EmbedTrueTypeFont(ReadOnlyMemory<Byte>, Int32) does. CFF outlines embed as a Type 0 font (§9.7.6, Identity-H) over a CIDFontType0 (§9.7.4) whose CIDs are the program's glyph ids, with a W array, a ToUnicode CMap (§9.10.3) and a subset tag (§9.9.2); its CFF program (an OpenType program's CFF table) is FontFile3 with subtype CIDFontType0C (§9.9, Table 124), which needs PDF 1.3. A save subsets it to the glyphs shown and glyph 0 as a CID-keyed CFF font whose charset maps each CID to its glyph (§9.7.4.2), with the charstrings copied unchanged and only the subroutines they reach (Adobe Technical Notes #5176 and #5177); until then the document holds the whole program. A save raises an older document to the version the font needs. A mutation: the font's objects are added on the first call for a program.

A Type 1 program (Type 1 Font Format) is converted to a CFF program first and then embeds as one: each glyph's charstring becomes a Type 2 charstring drawing the same outline (subroutines, flex and multiple master blends resolved, seac accented characters composed), without hints. Its glyphs map to characters through their names (Adobe Glyph List, and the ITC Zapf Dingbats list for names such as a1).