On This Page (14)
- Pipeline Comparison
- Part 1: PCB Text Rendering
- Stroke, TrueType, And Barcode Text
- How Altium Chooses A TrueType Font
- Installed Fonts On Each Platform & Python Configuration
- Drawing A Font Absent From The Host (Croscore Stand-Ins)
- FreeType, HarfBuzz, GDI Calibration & Outline Flattening (PCB)
- Embedded Fonts & policy="embedded_first"
- The PCB Font Report
- Part 2: Schematic Paint IR Text Rendering
- Stage 1: Font Resolution & Metrics
- Stage 2A: Schematic SVG (SchPaintSvgOptions)
- Stage 2B: Schematic PNG (SchPaintPngOptions)
- Related Output Differences & Guides
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:
- PCB fabrication text (Gerber, IPC-2581, PCB SVG, and
render_pcb_text): renders Stroke, TrueType, and Barcode primitives into fabrication polygons and strokes, mirroring Windows GDI font selection and Altium's outline flattening. - Schematic Paint IR text (
.SchDoc,.SchLib, and compiled physical-page SVG/PNG): resolves fonts for display-list measurement and lowers text either as<text>elements, exact HarfBuzz/Skia Bezier paths, Windows GDI+ flattened polylines, or anti-aliased raster PNG glyphs.
Pipeline Comparison
| Aspect | PCB Fabrication (board.fab()) | Schematic Paint IR (to_svg / to_paint_png) |
|---|---|---|
| Text kinds | Stroke (Default, Sans Serif, Serif), TrueType, Barcode (Code 39, Code 128, QR, Data Matrix) | TrueType / OpenType schematic font table entries |
| Libraries used | freetype-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 discovery | Windows 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 variables | None (configured via board.fab(fonts={...})) | ALTIUM_FONT_DIRS, ALTIUM_FONT_MODE, ALTIUM_FONT_DISABLE_SYSTEM |
| Embedded fonts | Reads EmbeddedFonts6 (with .ttc repair); policy="altium" (default) or policy="embedded_first" | Not applicable (schematics do not embed font binaries) |
| Outline representation | Degenerate 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-ins | Arimo (Arial), Tinos (Times New Roman), Cousine (Courier New) — patched in-memory to Windows cell metrics | Same 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:
- Stroke (
font_type == 0): Altium's built-in vector stroke fonts (Default,Sans Serif, andSerif), bundled directly inaltium-monkeyso stroke text renders identically on every platform with zero host-font dependency. Characters map through Windows-1252 best-fit encoding (with"expanded to''); zero-length strokes are emitted as disks by default (AOD-001). Framed stroke text word-wraps with a0.2 × height_of_Eline gap, while unframed multiline text advances by1.68 × height_mm. - TrueType (
font_type == 1): Outline fonts drawn as filled contours (or inverted cutouts inside a solid box). Which font file is chosen depends on the board and the host machine. - Barcode (
font_type == 2): 1D Code 39 (fixing Altium's'H'/'h'encoding defect, AOD-011) and Code 128 (arbitrary-length ASCII; non-ASCII refused, AOD-012), plus 2D QR Code (ECC Level M, versions 1–40) and Data Matrix (ECC 200, square 10×10..144×144). Optional barcode captions (barcode_show_text=True) render as regular-style TrueType text using the same placement and font-selection rules below and are counted infab.view().fonts(). Low-levelBarcodeRendererandrender_pcb_text(altium_monkey.altium_text_to_polygon) acceptfont_policyandinstalled_fontsdirectly. Uncaptured barcode configurations (such as framed 2D barcodes whose justification is notLEFT_BOTTOM, rotated/solder-mask/>80-char/framed Code 39, or inverted Code 128 off overlay layers) emit atext_rule_unconfirmedwarning inFabView.
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:
- 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. - 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. - Face selection: Among available faces of the family, selects the nearest weight (bold or regular), then nearest slant.
- 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:
- The font is installed with multiple faces, none matching the requested style (for example, italic Tahoma has no italic face, so Altium draws Arial italic).
- The font is not installed and the board only embeds a different style (for example, only "Myriad Pro Bold" is embedded when text requests italic).
- The font is neither embedded nor installed (including
.otf-only installs).
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
| Platform | Fonts counted as installed |
|---|---|
| Windows | Standard Windows 11 TrueType fonts plus every TrueType font installed on this machine |
| Linux and macOS | Standard Windows 11 TrueType fonts |
| Any platform | Plus 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:
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 key | Type | Meaning |
|---|---|---|
policy | "altium" | "embedded_first" | Font selection policy ("altium" is the default) |
files | Sequence[str] | Extra .ttf/.ttc files counted as installed |
folders | Sequence[str] | Extra folders scanned for installed TrueType fonts |
standard_only | bool | Ignore 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):
- Installed file (caller-provided
files/foldersor Windows GDI file). - 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
fontToolsto match Windows cell metrics (usWinAscent,usWinDescent,usWeightClass, italic flags, andVDMXadvance tables), so character widths and placement match Altium. - Board's embedded copy: If the
.PcbDocembeds that font. Damaged embedded.ttccollections are repaired automatically on hosts without that font installed (AOD-034). - 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_approximatewarning 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:
- Glyph ID lookup (
uharfbuzz): Usesuharfbuzzsolely for Unicode → glyph ID mapping (cmapandGSUBsubstitutions).GPOS/ kerning offsets are deliberately ignored to match Altium's per-glyphGetGlyphOutlineWloop. - Unhinted outlines (
freetype-py): Loads outlines withFT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINTat a 256 pt reference size. Using unhinted outlines avoids GDI grid-fitting distortion at tiny silkscreen sizes (AOD-009). - GDI cell-height calibration: Scales glyphs to match Windows' negative
lfHeightcell formula (em = height × UPM / (usWinAscent + usWinDescent)), including GDI's 2,160-pixel reference cap and integer-pixelgmCellIncXadvances. - 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 // 50onglyfoutlines;+27design-unit advance onCFFoutlines) and italic shear (87 / 256onglyf,11556 / 65536 ≈ tan 10°onCFF). - 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.05reference pixels, maximum depth 8, vertex deduplication at0.001mm). Small outline differences relative to GDI's hinted Bezier curves occur mainly on curved strokes at very small text heights (AOD-009). - 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
shapelyso Gerber and IPC-2581 regions stay non-self-intersecting.
Embedded Fonts & policy="embedded_first"
To embed TrueType fonts inside a .PcbDoc in Altium Designer:
- Open Preferences → PCB Editor → True Type Fonts.
- Enable Embed TrueType fonts inside PCB documents.
- 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:
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:
[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
info: no action needed.warning: output differs from what the designer likely saw, depends on the host machine, or uses an approximate stand-in.error: text could not be drawn.
| Code | Severity | Meaning | Action |
|---|---|---|---|
font_drawn | info | Drawn in the font Altium draws | None |
font_stand_in | info | Drawn with a metric-compatible stand-in | None (Windows uses the installed font) |
font_embedded_copy_used | info | Drawn from the board's embedded copy | None |
font_policy_differs | info | embedded_first drew a different font than Altium | Use default "altium" policy to match Altium |
font_stand_in_approximate | warning | Drawn with an approximate class stand-in | Run on Windows, pass the font file, or embed in board |
font_replaced | warning | Altium replaces the font with Arial | Use a style the font provides, or embed in board |
font_default_face | warning | Font missing or unreadable; Windows draws Arial | Install or re-embed the font |
font_not_embedded | warning | Drawn from a non-standard host font not embedded in board | Embed the font in Altium |
font_rule_unconfirmed | warning | Drawn by a rule not yet captured against Altium | Review output visually |
font_embedded_fonts_end | warning | Embedded font table truncated or damaged | Re-embed fonts in Altium |
font_embedded_copy_unreadable | warning | Board's embedded copy could not be parsed | Re-embed from an installed copy |
font_file_missing | warning | Configured font file or folder does not exist | Check the fonts path |
text_font_missing | error | No font file could be read; text omitted | Reinstall altium-monkey |
text_without_ink | info | Characters have no outline in the font | None |
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 variable | Effect |
|---|---|
ALTIUM_FONT_DIRS | Extra search directories (OS path separator delimited) checked ahead of system fonts |
ALTIUM_FONT_MODE | Font resolution mode (e.g., strict or fallback-assisted) |
ALTIUM_FONT_DISABLE_SYSTEM | Set 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 / Backend | Output geometry | Platform | Notes |
|---|---|---|---|
text_mode="text" (default) | SVG <text> / <tspan> elements | All | Compact, 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> curves | All | Uses 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> polylines | Windows only | Uses Windows GDI+ GdipAddPathString + GdipFlattenPath. Curve chord error is controlled by polygon_text_tolerance_mil (default 0.5 mil). |
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:
harfbuzzemits exact Bezier curves (Q/CSVG path commands) shaped by HarfBuzz (GSUB+GPOS) and extracted from Skia without chordal flattening. It runs identically on Windows, Linux, and macOS.gdiplusruns Windows GDI+GdipFlattenPath, converting every curve into straight line segments (Lcommands) bounded bypolygon_text_tolerance_mil(0.5 mil default), and uses GDI+ text layout spacing.embed_bundled_fallback_fonts=Trueis not supported by the Paint IR A0 SVG adapter and raisesSchPaintRenderError; usetext_mode="paths"when an SVG must render identically on machines without host fonts.
Stage 2B: Schematic PNG (SchPaintPngOptions)
SchPaintPngRenderer / to_paint_png(...) supports two raster backends:
| Backend | Anti-aliasing & text modes | Platform |
|---|---|---|
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:
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")
)Related Output Differences & Guides
See the Altium output differences register for full captures and options:
- AOD-001 — zero-length stroke text segments drawn as disks
- AOD-009 — unhinted PCB TrueType outlines
- AOD-010 — Windows font aliases (
Helvetica,Times) - AOD-011 — Code 39 barcode
'H'/'h'encoding fix - AOD-012 — Code 128 text outside ASCII
- AOD-033 — installed font priority over embedded copy (matched)
- AOD-034 — repairing damaged embedded
.ttcfaces - AOD-048 — Arial substitution rules (matched)
- AOD-049 — drawing fonts absent from the host
- AOD-052 — truncated or corrupt
EmbeddedFonts6streams - AOD-053 — substitution font always Arial
- AOD-054 — no cross-board session font caching
- AOD-074 — TrueType Texts of no height
Related guides: Fab & FabView, Schematic Paint IR, and the interactive Stroke Font Demo.