Skip to content

[Feature]: Vector PDF export: embed real fonts so layout text stays editable in vector editors #1815

Closed

Description

@elpidioassinaturas

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).

  1. places.geojson: three points with a name property ("Alpha Town", "Beta City", "Gamma Village").
  2. 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"}'
    
  3. python -c "import fitz; print(fitz.open('out.pdf')[0].get_fonts())": both fonts are Type3. page.get_text() returns the labels, the title, the legend and the scale bar text, so the ToUnicode map works.
  4. Open out.pdf in VectorCraft 0.24: 99 paths, no text objects and no groups.

Proposal

  1. Embed the faces as TrueType/OpenType subsets (Type 0 / CIDFontType2 with Identity-H and ToUnicode) whenever the face file is available and its fsType allows embedding. Text is then live in every editor and PDF/A-friendly. Subsetting can come from a small pure-Rust crate (subsetter from the typst project, MIT/Apache-2.0, no C deps) and writing from pdf-writer, the crate RustGIS's PDF code could adopt for the font dictionaries only.
  2. 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.
  3. 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.
  4. 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.
  5. Option "pdf": {"text": "fonts" | "outlines"} on layout.export (default fonts); outlines keeps today's output for print shops that ask for outlined type.

Limits

Activity

  1. added a commit that references this issue on Nov 12, 2026
  2. elpidioassinaturas commented on Nov 14, 2026

    @elpidioassinaturas
    ContributorAuthor

    Done: real embedded fonts in #1828, layers (optional content groups) in #1834, halos in #1875, with #1938 on top. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions