EmbeddedFont

A TrueType font loaded for embedding into a PDF the writer produces.

This is the from-scratch writer's path to non-Latin / custom text. The whole font program is embedded as a Type0 / CIDFontType2 composite font with Identity-H encoding plus a /ToUnicode map, so the output renders and extracts arbitrary Unicode (including CJK). Embedding the full program, without subsetting, matches MuPDF's default pdf_add_cid_font behaviour.

Load once and reuse the handle across pages and documents:

val font = EmbeddedFont.load(myTtfBytes)
val pdf = PdfBuilder()
.page { text(font, 24.0, 72.0, 700.0, "日本語: Hello") }
.build()

Scope: only TrueType (glyf outline) fonts are supported. OpenType/CFF (.otf, sfnt tag "OTTO") and glyph subsetting are later milestones; load rejects CFF fonts with a clear error rather than embedding something broken.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

True for OpenType/CFF (.otf) fonts (embedded as CIDFontType0); false for TrueType.

Link copied to clipboard

PostScript name written as /BaseFont and /FontName.

Link copied to clipboard

When true, only the glyphs the document uses are embedded (a subset tag is added).