EmbedTrueTypeFont(ReadOnlyMemory, Int32) Method

Definition

Namespace Broadside
Assembly Broadside.dll

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

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

Parameters

program
ReadOnlyMemory<Byte>

The TrueType (glyf) program: a .ttf file, or a TrueType collection (.ttc) with faceIndex.

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, so every canvas and page that shows the program shares one embedded subset.

Remarks

ISO 32000-2 §9.7.6 (a Type 0 font with the Identity-H CMap, §9.7.5.2: each character is a two-byte code), §9.7.4 (its CIDFontType2 descendant, whose CIDs are the program's glyph ids, with a W array and a CIDToGIDMap stream), §9.8 (the font descriptor, with metrics from the program's head, hhea, OS/2 and post tables), §9.9 (the program as FontFile2), §9.9.2 (a subset with a six-letter tag that names its glyph set) and §9.10.3 (a ToUnicode CMap mapping each glyph back to the character it was shown for, so the text extracts as written).

Each shown glyph is added to the subset as it is drawn; a save reduces the program to the glyphs shown, glyph 0 and the glyphs their composites are built from, renumbered, with the same bytes for the same glyphs on every run. Until then the document holds the whole program, so it renders and extracts before it is saved. A program whose fsType forbids subsetting is embedded whole. Needs PDF 1.2 (Type 0 fonts and ToUnicode); a save raises an older document. A mutation: the font's objects are added on the first call for a program.