Repository navigation
Description
Problem
Since #1342, layouts export as vector PDF. Text goes out as PDF Type 3 fonts whose glyphs are their outlines, with a ToUnicode map, so the text can be searched and copied in a PDF viewer. #1342 left embedding the real font files for later ("would need a font subsetter").
Finishing a map in a vector editor shows the cost. Opened in VectorCraft 0.24 (vector editors generally import Type 3 glyphs as drawings, since the font has no outline program they can edit), a 850 × 550 pt layout with 337 text items arrives as 3,814 loose paths, about 1,640 of them glyphs, one path each (the rest are the map's own lines and polygons): no text objects, no groups per label, nothing named. Fixing a typo, changing a font size or selecting "all city names" means picking glyphs by colour and position. To give the labels a halo I had to classify glyphs by fill colour and by the hexagon under each one in a script, then group them by id.
Reproduction
Run on a build of main from before #1828 (current builds embed the fonts).
places.geojson: three points with anameproperty ("Alpha Town", "Beta City", "Gamma Village").-
rustgis-cli run --new --cmd 'layer.addData={"path":"places.geojson"}' --cmd 'labels.enable={"on":true}' --cmd 'labels.field={"field":"name"}' --cmd 'map.zoomFull={}' --cmd 'layout.new={"name":"Demo"}' --cmd 'layout.export={"layout":"Demo","path":"out.pdf"}' python -c "import fitz; print(fitz.open('out.pdf')[0].get_fonts())": both fonts areType3.page.get_text()returns the labels, the title, the legend and the scale bar text, so the ToUnicode map works.- Open
out.pdfin VectorCraft 0.24: 99 paths, no text objects and no groups.
Proposal
- Embed the faces as TrueType/OpenType subsets (Type 0 / CIDFontType2 with Identity-H and ToUnicode) whenever the face file is available and its
fsTypeallows embedding. Text is then live in every editor and PDF/A-friendly. Subsetting can come from a small pure-Rust crate (subsetterfrom the typst project, MIT/Apache-2.0, no C deps) and writing frompdf-writer, the crate RustGIS's PDF code could adopt for the font dictionaries only. - Keep Type 3 as the fallback for what a real font can't reproduce: synthetic italics or bold, variable-font instances without a static file, faces whose licence forbids embedding. A notice names the faces that fell back.
- Halos stay as they are now (stroked outlines drawn under the text). With real fonts they become text render mode 2 (fill and stroke) on a copy below, so an editor sees them as text too.
- Structure for editors: wrap each layout element and each map layer's labels in marked content with an optional content group named after the element or layer (
/OC /Labels:<layer>). Illustrator, Inkscape, Affinity and VectorCraft import OCGs as layers, so "city names" arrives as one layer instead of hundreds of glyphs. - Option
"pdf": {"text": "fonts" | "outlines"}onlayout.export(defaultfonts);outlineskeeps today's output for print shops that ask for outlined type.
Limits
- Fonts that refuse embedding (
fsType= 2) stay Type 3, as above. - Editors without the font installed substitute one when editing. The look is unchanged as long as nothing is edited.
- The PNG and PDF exports must still match. Test: render both and diff, as [Feature]: Vector PDF export: layouts, reports and map frames as vectors #1342's tests do.
Activity
fix(render): review round 1 for embedded PDF fonts (opengeos#1815)
fix(render): review round 1 for PDF layers (opengeos#1815)
test(render): CFF faces embed as CIDFontType0 with the right glyphs (o…
fix(render): PDF labels keep their placement order (opengeos#1815, la…
fix(engine): refuse an unknown key in layout.export's "pdf" (opengeos…
docs: attribute the CFF test font (opengeos#1815)
fix(render): name the collection face that draws the text in the noti…
fix(render): a layout element's PDF layer carries its id (opengeos#1815…
feat(render): layers in vector PDFs (#1815, layers) (#1834)
test(engine): the outlined-faces notice, none, one, two and eleven (o…
fix(render): a halo of no width draws nothing (opengeos#1815, halos)
docs: every reason a face is set in outlines (opengeos#1815)
feat(render): embed real fonts in a layout's vector PDF (#1815, part …
fix(render): a subset tag follows its face file (opengeos#1815, halos)
fix(render): an SVG halo copy is hidden from screen readers (opengeos…
fix(render): the subset tag hashes every byte (opengeos#1815, halos)
feat(render): a label's halo is text in vector PDFs (#1815, halos) (#…
fix(engine): the PDF fonts test allows a variable system font set as …
elpidioassinaturas commentedon Nov 14, 2026
Done: real embedded fonts in #1828, layers (optional content groups) in #1834, halos in #1875, with #1938 on top. Closing.