How to Build Code-Driven AI Illustrations With Exact Text
Make this article actionable
Send the article context into Vife Agent and turn it into a plan, checklist, or draft you can keep working on.
A process diagram for a client deck needed fourteen labels: four stage names, six system names with mixed capitalization, two dates and two figures. The first attempt came back attractive and wrong — a misspelled stage, a quarter that belonged to last year, and a number that had quietly changed in the third decimal. Regenerating it fixed the layout and broke the spelling somewhere else.
That is not a prompting failure. It is a format mismatch. A text-output model asked for SVG, HTML or canvas code returns words as characters in a font and shapes as coordinates you can move. A dedicated image model returns pixels, and the words inside those pixels are painted shapes rather than typeset text. Simon Willison made this argument on 28 November 2026, after producing an editable poster as SVG with Gemini 4 Neon: bitmap models "output text shapes directly from the model, which means you don't get the same guaranteed consistency that you would have with a real font-based typography system," they stay "inherently flat" so you cannot manipulate one element, and they show glitches when you zoom in (simonwillison.net). He still keeps image models for photorealistic work; for explanatory diagrams, editable posters, UI components and visualisations he prefers code (same post).
This workflow turns that argument into a repeatable job: one labeled graphic, produced as code, checked before it reaches a slide.
Step 1 — Sort the graphic into one of two buckets
Before writing anything, decide what kind of image you actually need.
| What the graphic must do | Right tool |
|---|---|
Carry exact words, numbers, units or product names | Code (SVG, HTML/CSS, canvas) |
Be edited next quarter by someone who is not a designer | Code |
Stay sharp at poster size and at 40 px in a table | Code (vector) |
Show one idea with boxes, arrows or a timeline | Code |
Look photographic, painterly or textured | Image model |
Reproduce a real person, place or product photo | Image model |
The rule of thumb: if a reviewer could reject the graphic because a single character is wrong, it should be code. If they would reject it because the light is wrong, it should be pixels. Willison's concession is the useful boundary here — "if you are generating photorealistic images then dedicated image models still have their place" (simonwillison.net).
Turn the useful parts into next steps
Vife Agent can convert this guide into a prioritized workflow with tasks, risks, and reusable prompts.
Step 2 — Write a spec block, not a prompt
A prompt describes a feeling. A spec fixes the things that must not drift. Paste a block like this and fill every line:
CANVAS: 1600 x 900 px, viewBox "0 0 1600 900"
USE: slide figure, shown at 800 px wide, also printed A4 landscape
PALETTE: #10233F text, #F4F1EA background, #C2452D accent, #7A8B99 secondary
FONT: system sans stack only — "Inter", "Helvetica Neue", Arial, sans-serif
LABELS (verbatim, do not shorten, do not translate):
1. Intake review
2. Invoice reconciliation
3. Q4 2026 close
4. 4.3 days median cycle time
...
LAYOUT: four stages left to right, equal gutters, labels under each stage,
one accent bar behind stage 3 only
MUST NOT: add extra labels, add icons with text, change any numberThree details earn their space. "USE" tells the model the final display size, which decides type sizes and stroke weights. "LABELS (verbatim)" turns proofreading into a string comparison instead of an opinion. "MUST NOT" closes the most common failure: a model that helpfully adds a legend nobody asked for.
Step 3 — Ask for one self-contained file
Ambiguity in the output format is where an hour disappears. Require:
- one
<svg>element with aviewBox, no fixedwidth/heightin the root; - text as
<text>elements, never converted to paths; - no external fonts, no
<image>embeds, no linked stylesheets; - one
<g id="...">per zone (header, stages, footer), so a later edit has a target; <title>and<desc>at the top;- no metadata blocks from the design tool.
If the model returns HTML with an embedded SVG and CSS, ask it to inline the styles and return only the SVG. If it returns a PNG "preview", you have lost the point.
Step 4 — Render it before you judge it
Models cannot see what they cannot render. Willison notes that AI Studio does not render SVGs, so the models there "can't spot visual mistakes without assistance" — he had to send screenshots back with instructions such as "the text here doesn't fit the pill, fix it" (simonwillison.net).
Do the same, and make it cheap: save the SVG, open it in a browser, take a screenshot at the display size, and send that image back with one sentence per defect. "Label 4 overlaps the arrow at x=980." "Stage 3 bar extends past the right margin." Vague feedback ("make it cleaner") produces a new set of defects.
Step 5 — Run the text-fit math
Overflow is the defect that survives proofreading, because the words are correct and merely unreadable. Two checks catch nearly all of it.
Estimate first: for a normal sans-serif, average character width is roughly 0.5 to 0.6 em. A 24 px label of 30 characters needs about 360–430 px of room. If the box is 380 px wide, it will clip.
Then make the file enforce the fit. For a single line that must stay inside a fixed band, textLength with lengthAdjust="spacingAndGlyphs" compresses or stretches the text to the exact width; for multi-line labels, set explicit tspan lines with dy rather than relying on wrapping, because SVG does not wrap text on its own. Leave at least 8 percent padding inside every box, and keep every text element's bounding box inside its zone group.
Step 6 — Check contrast at the size it will be seen
A label that passes on your monitor can vanish in a projected deck or a printed handout. Use a stated threshold rather than taste: WCAG 2.2 Success Criterion 1.4.3 requires at least 4.5:1 for text below 18 point (or below 14 point bold) and at least 3:1 for large text, and the ratios are thresholds, not guidance — a computed 4.499:1 does not meet 4.5:1 (w3.org, page updated 4 October 2026).
Check the accent colour against the background, not just the body text: a red bar behind white type is the classic failure. Also check stroke weights — a 1 px line that looks refined at 1600 px becomes a grey smear at 800 px.
Step 7 — Make the file usable by machines and by people
Because the artifact is code, accessibility is nearly free if you ask for it in Step 3: <title> and <desc> describe the figure, role="img" marks it, and the label strings remain real text that a screen reader, a search index or a later assistant can read. Then carry the description into the document itself as alt text — the caption in the deck and the alt text in the doc should say the same thing, in one sentence, without repeating every label.
Step 8 — Export one format per destination
- Documents and web: ship the SVG as-is. Keep the
viewBox; strip editor metadata. - Slides: export PNG at 2x the display size. Most deck tools rasterise SVG inconsistently, and a 2x PNG at 800 px display width is indistinguishable on a projector.
- Print: export vector PDF, and confirm the fonts are embedded. Converting text to outlines is a final-handoff decision, not a working one — it makes the file uneditable and unsearchable, which is exactly the property you chose this format for.
Willison's poster was editable in Inkscape, Adobe Illustrator or Boxy SVG after generation (simonwillison.net); the same holds for yours, which matters when a colleague has five minutes and one word to change.
Step 9 — Keep the spec, not just the file
Store the spec block next to the SVG, dated. Next quarter the update is a text edit — change the quarter, change one figure, ask for the diff — instead of a fresh generation that reintroduces old defects. If you regenerate, diff the label list first: the number of changed lines should equal the number of intended changes.
Checklist before it ships
- Every label matches the source string character for character, including capitalization and units.
- No label was shortened, translated or "tidied" by the model.
- Every number traces to a cell, a page or a sentence you can point at.
- No text element crosses its zone boundary at the display size.
- Body text meets 4.5:1 and large text meets 3:1 against its actual background.
- No external font, image or stylesheet reference remains in the file.
-
<title>and<desc>are present, and the document alt text matches them. - Zones carry
idattributes so the next edit has a target. - The PNG export was checked at 100 percent on the screen it will be shown on.
- The spec file is saved beside the asset with a date.
Common mistakes
Asking for "a diagram" and hoping. Without a verbatim label list, the model invents names that read plausibly and are wrong.
Accepting a screenshot as the deliverable. A PNG of an SVG throws away the editability you paid for.
Judging at 1600 px. Most review happens at 25 percent zoom, which is where clipped text and hairline strokes hide.
Letting the model add a legend. Extra elements are usually the model's attempt to be helpful and almost always break the layout budget.
Editing the render instead of the code. Once you start nudging pixels in an image editor, the next update is a manual job again.
When a pixel model is still the right tool
Photorealistic product shots, painterly hero art, texture, and anything where the light matters more than the letters belong to image models. So does a graphic that will never be edited and carries three words or fewer. The test is not which model is better; it is whether the failure mode you fear is a wrong character or a wrong atmosphere.
One caution worth keeping: no format fixes a wrong fact. Code gives you exact rendering of whatever string you supply — so the label list is the place to be careful, and the checklist is the place to prove it.

