altium monkey v2026.11.26 · gobblerito
On This Page (14)

Text & Font Rendering

altium-monkey renders text across two distinct graphics pipelines because Altium's PCB editor and Schematic editor follow different Windows font and outline conventions:

Pipeline Comparison

AspectPCB Fabrication (board.fab())Schematic Paint IR (to_svg / to_paint_png)
Text kindsStroke (Default, Sans Serif, Serif), TrueType, Barcode (Code 39, Code 128, QR, Data Matrix)TrueType / OpenType schematic font table entries
Libraries usedfreetype-py (outlines), uharfbuzz (cmap/GSUB glyph IDs only), fontTools (metric patching), shapely (even-odd fill cleanup)fontTools (metrics), uharfbuzz (full GSUB/GPOS shaping), skia-python (exact SVG paths & PNG raster), optional Windows gdiplus
Host font discoveryWindows GDI installed TrueType fonts on Windows; standard Windows 11 catalog on Linux/macOS; explicit fonts={"files": ..., "folders": ...}Host system fonts + ALTIUM_FONT_DIRS, ALTIUM_FONT_MODE, ALTIUM_FONT_DISABLE_SYSTEM + bundled Croscore fallbacks
Environment variablesNone (configured via board.fab(fonts={...}))ALTIUM_FONT_DIRS, ALTIUM_FONT_MODE, ALTIUM_FONT_DISABLE_SYSTEM
Embedded fontsReads EmbeddedFonts6 (with .ttc repair); policy="altium" (default) or policy="embedded_first"Not applicable (schematics do not embed font binaries)
Outline representationDegenerate cubic flattening to straight-line polygons (flatten_tolerance = 0.05 ref px, max depth 8)SVG harfbuzz: exact quadratic/cubic Bezier <path> curves; SVG gdiplus: straight-line polylines (polygon_text_tolerance_mil = 0.5)
Bundled stand-insArimo (Arial), Tinos (Times New Roman), Cousine (Courier New) — patched in-memory to Windows cell metricsSame bundled Croscore fonts (OFL 1.1)

Part 1: PCB Text Rendering

Stroke, TrueType, And Barcode Text

PCB text in Altium uses one of three font kinds:

How Altium Chooses A TrueType Font

Altium draws PCB TrueType text through Windows GDI. By default (policy="altium"), altium-monkey mirrors the same four steps:

  1. Board embedded fonts: Registers fonts from EmbeddedFonts6 (up to the declared count or the first truncated/corrupt compressed stream, AOD-052) whose family is not already installed on the host. A board that embeds Arial on a machine with Arial installed still draws the installed Arial (AOD-033). Once a regular record for a family is registered, later embedded records for that family are ignored and bold/italic styles are synthesized from that face.
  2. Font acceptance check: Accepts a font when the board embeds it, when it is installed in the requested style, or when the installed family has only one face. OpenType PostScript (.otf) fonts do not count as installed TrueType fonts. Otherwise Altium replaces the font with Arial.
  3. Face selection: Among available faces of the family, selects the nearest weight (bold or regular), then nearest slant.
  4. Simulated bold and italic: If the chosen face is lighter than bold for bold text, it is emboldened; if upright for italic text, it is slanted.

When Altium Replaces A Font With Arial

Altium substitutes Arial (in the requested style) in three cases:

altium-monkey draws the same Arial replacement to match Altium's Gerber output and records font_replaced (AOD-048); Arial is always used as the substitution font (AOD-053). Unlike a long-running Altium GUI session, altium-monkey does not leak embedded fonts across separate boards (AOD-054).

Installed Fonts On Each Platform & Python Configuration

PlatformFonts counted as installed
WindowsStandard Windows 11 TrueType fonts plus every TrueType font installed on this machine
Linux and macOSStandard Windows 11 TrueType fonts
Any platformPlus any .ttf/.ttc files or folders passed via fonts={"files": ..., "folders": ...}

The standard Windows 11 set covers the core TrueType families shipped with Windows 11 (Arial, Bahnschrift, Calibri, Cambria, Cascadia, Comic Sans MS, Consolas, Courier New, Georgia, Impact, Lucida Console/Sans Unicode, Microsoft Sans Serif, Palatino Linotype, Segoe UI/Print/Script, Tahoma, Times New Roman, Trebuchet MS, Verdana, Symbol/Webdings/Wingdings, and standard Windows East Asian / script families). Microsoft Office-only fonts (such as Arial Narrow or Century Gothic) and Linux/macOS system fonts (such as DejaVu Sans or Helvetica) are not counted as standard Windows fonts.

Pass fonts to board.fab(...) (or any board.to_* shortcut). PCB rendering reads no environment variables:

python
from altium_monkey import AltiumPcbDoc

board = AltiumPcbDoc.from_file("board.PcbDoc")

# Machine fonts (default) plus extra font files and folders:
fab = board.fab(
    fonts={
        "files": ["fonts/Eurostile-Bold.ttf"],
        "folders": ["fonts"],
    }
)

# Standard Windows 11 list only (identical behavior across machines):
portable_fab = board.fab(
    fonts={
        "standard_only": True,
        "files": ["fonts/Eurostile-Bold.ttf"],
    }
)

# Board-only reproducibility (prefer embedded copies over host installs):
board_only_fab = board.fab(fonts={"policy": "embedded_first"})
fonts keyTypeMeaning
policy"altium" | "embedded_first"Font selection policy ("altium" is the default)
filesSequence[str]Extra .ttf/.ttc files counted as installed
foldersSequence[str]Extra folders scanned for installed TrueType fonts
standard_onlyboolIgnore host-installed fonts and judge against standard Windows 11 only

Drawing A Font Absent From The Host (Croscore Stand-Ins)

Once face selection decides which font Altium draws, altium-monkey locates glyph outlines in this order when the host lacks the Windows font file (for example on Linux or macOS, AOD-049):

  1. Installed file (caller-provided files/folders or Windows GDI file).
  2. Metric-compatible bundled stand-in: Arimo (Arial), Tinos (Times New Roman), and Cousine (Courier New) — shipped under SIL OFL 1.1 and patched in-memory per process via fontTools to match Windows cell metrics (usWinAscent, usWinDescent, usWeightClass, italic flags, and VDMX advance tables), so character widths and placement match Altium.
  3. Board's embedded copy: If the .PcbDoc embeds that font. Damaged embedded .ttc collections are repaired automatically on hosts without that font installed (AOD-034).
  4. Approximate class stand-in: Arimo (other sans), Tinos (other serif), or Cousine (other monospace) drawn at the Windows font's cell height with a font_stand_in_approximate warning because glyph widths differ. Symbol and East Asian fonts have no stand-in; embed them in the board or run on Windows.

FreeType, HarfBuzz, GDI Calibration & Outline Flattening (PCB)

PCB fabrication outputs (Gerber, IPC-2581, PCB SVG) require closed polygons rather than live font references. altium-monkey's PCB TrueType renderer reproduces Windows GDI / Altium geometry in six stages:

  1. Glyph ID lookup (uharfbuzz): Uses uharfbuzz solely for Unicode → glyph ID mapping (cmap and GSUB substitutions). GPOS / kerning offsets are deliberately ignored to match Altium's per-glyph GetGlyphOutlineW loop.
  2. Unhinted outlines (freetype-py): Loads outlines with FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT at a 256 pt reference size. Using unhinted outlines avoids GDI grid-fitting distortion at tiny silkscreen sizes (AOD-009).
  3. GDI cell-height calibration: Scales glyphs to match Windows' negative lfHeight cell formula (em = height × UPM / (usWinAscent + usWinDescent)), including GDI's 2,160-pixel reference cap and integer-pixel gmCellIncX advances.
  4. Simulated bold and italic: When the selected face lacks native bold or italic, applies GDI-equivalent synthesis — horizontal/vertical emboldening (Dh = ppem // 50 + 1, Dv = ppem // 50 on glyf outlines; +27 design-unit advance on CFF outlines) and italic shear (87 / 256 on glyf, 11556 / 65536 ≈ tan 10° on CFF).
  5. Curve flattening: Promotes TrueType quadratic B-splines to Altium's degenerate cubic form (p0, p0, p1, p2) and flattens curves with recursive De Casteljau subdivision (flatten_tolerance = 0.05 reference pixels, maximum depth 8, vertex deduplication at 0.001 mm). Small outline differences relative to GDI's hinted Bezier curves occur mainly on curved strokes at very small text heights (AOD-009).
  6. Bold self-crossing cleanup & even-odd fill: Removes tiny self-intersecting ear loops generated by heavy simulated emboldening (dropping sub-loops ≤ 70% of the contour perimeter) and resolves overlapping contours with even-odd fill via shapely so Gerber and IPC-2581 regions stay non-self-intersecting.

Embedded Fonts & policy="embedded_first"

To embed TrueType fonts inside a .PcbDoc in Altium Designer:

  1. Open Preferences → PCB Editor → True Type Fonts.
  2. Enable Embed TrueType fonts inside PCB documents.
  3. Save the board on a machine with those fonts installed.

Because Altium prefers host-installed fonts over embedded copies (AOD-033), opt into board.fab(fonts={"policy": "embedded_first"}) when output must depend only on the board itself. Under embedded_first, altium-monkey uses the board's embedded copy first (synthesizing bold/italic from the nearest embedded face if needed) and records font_policy_differs (info) whenever that differs from what Altium draws. Inspect embedded font payloads with board.asset_inventory() or the pcbdoc_extract_embedded_fonts example.

The PCB Font Report

Inspect every TrueType font and style used on a board through board.fab().view().fonts() (FabFontReport), whose .entries (FabFontUse) expose structured fields (family, texts, layers, altium, altium_face, severity, code) alongside human-readable message and advice strings:

python
from altium_monkey import AltiumPcbDoc

board = AltiumPcbDoc.from_file("board.PcbDoc")

# Structured report from FabView (family, texts, layers, Altium font source):
view_report = board.fab().view().fonts()
for entry in view_report.entries:
    print(entry.family, entry.texts, entry.altium, entry.altium_face)

# Concise one-line summaries with actionable advice:
for entry in view_report.entries:
    line = (
        f"{entry.message} {entry.advice}"
        if isinstance(entry.advice, str) and entry.advice
        else entry.message
    )
    print(f"[{entry.severity}] {line}")

Example formatted output on Windows:

text
[info] Arial bold, 12 texts (Top Overlay, Bottom Overlay): drawn from the installed Arial Bold, as Altium draws it.
[warning] Tahoma italic, 3 texts (Top Overlay): Altium replaces it with Arial italic, because Tahoma is installed without an italic face. Drawn in Arial italic, as Altium draws it. To keep Tahoma, make these texts regular or bold.
[warning] Eurostile bold, 2 texts (Top Overlay): drawn from this machine's installed Eurostile Bold. It is not a standard Windows font and the board does not embed it, so Altium replaces it with Arial bold on a machine without it. Embed the font in the board in Altium.

Diagnostic Codes

CodeSeverityMeaningAction
font_drawninfoDrawn in the font Altium drawsNone
font_stand_ininfoDrawn with a metric-compatible stand-inNone (Windows uses the installed font)
font_embedded_copy_usedinfoDrawn from the board's embedded copyNone
font_policy_differsinfoembedded_first drew a different font than AltiumUse default "altium" policy to match Altium
font_stand_in_approximatewarningDrawn with an approximate class stand-inRun on Windows, pass the font file, or embed in board
font_replacedwarningAltium replaces the font with ArialUse a style the font provides, or embed in board
font_default_facewarningFont missing or unreadable; Windows draws ArialInstall or re-embed the font
font_not_embeddedwarningDrawn from a non-standard host font not embedded in boardEmbed the font in Altium
font_rule_unconfirmedwarningDrawn by a rule not yet captured against AltiumReview output visually
font_embedded_fonts_endwarningEmbedded font table truncated or damagedRe-embed fonts in Altium
font_embedded_copy_unreadablewarningBoard's embedded copy could not be parsedRe-embed from an installed copy
font_file_missingwarningConfigured font file or folder does not existCheck the fonts path
text_font_missingerrorNo font file could be read; text omittedReinstall altium-monkey
text_without_inkinfoCharacters have no outline in the fontNone

Part 2: Schematic Paint IR Text Rendering

Schematic rendering (.SchDoc, .SchLib, and compiled physical pages) splits text handling into metric resolution during Paint IR A0 scene construction and glyph lowering inside the SVG or PNG backend.

Stage 1: Font Resolution & Metrics

The schematic font resolver (altium_monkey.altium_font_resolver) maps each schematic font table entry (SchFontSpec) to an actual font file and reads ascent, descent, and glyph advances via fontTools (respecting OS/2 USE_TYPO_METRICS when set).

Unlike PCB rendering, schematic font discovery supports host system fonts and three environment variables:

Environment variableEffect
ALTIUM_FONT_DIRSExtra search directories (OS path separator delimited) checked ahead of system fonts
ALTIUM_FONT_MODEFont resolution mode (e.g., strict or fallback-assisted)
ALTIUM_FONT_DISABLE_SYSTEMSet to disable host OS system font scanning (for reproducible CI renders using bundled Croscore stand-ins)

When a requested family is absent on the host, the resolver falls back to Windows Microsoft Sans Serif (on Windows) or the bundled Croscore stand-ins (Arimo, Tinos, Cousine).

Stage 2A: Schematic SVG (SchPaintSvgOptions)

SchPaintSvgOptions provides two text modes and two outline backends:

Mode / BackendOutput geometryPlatformNotes
text_mode="text" (default)SVG <text> / <tspan> elementsAllCompact, selectable text; appearance depends on viewer fonts. Pass outline_font_families=(...) to selectively outline specific families only.
text_mode="paths", text_path_backend="harfbuzz" (default for "paths")Exact quadratic & cubic Bezier SVG <path> curvesAllUses uharfbuzz (full GSUB/GPOS shaping) + skia.Font.getPath(). Smooth at any zoom; polygon_text_tolerance_mil has no effect in this backend.
text_mode="paths", text_path_backend="gdiplus"Flattened straight-line SVG <path> polylinesWindows onlyUses Windows GDI+ GdipAddPathString + GdipFlattenPath. Curve chord error is controlled by polygon_text_tolerance_mil (default 0.5 mil).
python
from altium_monkey import AltiumSchDoc, SchPaintSvgOptions

schdoc = AltiumSchDoc("sheet.SchDoc")

# Compact viewer-rendered text (default)
svg_text = schdoc.to_svg(options=SchPaintSvgOptions(text_mode="text"))

# Self-contained cross-platform Bezier glyph paths (HarfBuzz + Skia)
svg_paths = schdoc.to_svg(
    options=SchPaintSvgOptions(text_mode="paths", text_path_backend="harfbuzz")
)

# Windows-only GDI+ flattened polylines for strict GDI+ comparison
svg_gdiplus = schdoc.to_svg(
    options=SchPaintSvgOptions(
        text_mode="paths",
        text_path_backend="gdiplus",
        polygon_text_tolerance_mil=0.5,
    )
)

Why harfbuzz and gdiplus paths differ slightly:

Stage 2B: Schematic PNG (SchPaintPngOptions)

SchPaintPngRenderer / to_paint_png(...) supports two raster backends:

BackendAnti-aliasing & text modesPlatform
backend="skia" (default)Grayscale kAntiAlias. text_mode="text" draws directly via Skia drawString (no HarfBuzz shaping); text_mode="paths" shapes via HarfBuzz and draws skia.Path outlines.All
backend="gdiplus"Grayscale TextRenderingHintAntiAlias (4). Supports text_mode="text" only (text_mode="paths" raises ValueError).Windows only

Configure output resolution with dpi (default 96.0) or paired width_px / height_px:

python
from altium_monkey import AltiumSchDoc, SchPaintPngOptions

schdoc = AltiumSchDoc("sheet.SchDoc")
png_bytes = schdoc.to_paint_png(
    png_options=SchPaintPngOptions(dpi=192.0, backend="skia", text_mode="paths")
)

See the Altium output differences register for full captures and options:

Related guides: Fab & FabView, Schematic Paint IR, and the interactive Stroke Font Demo.

altium-monkey v2026.11.26 · gobblerito·Docs updated 2026.11.29 17:55 UTC (0665053)