Skip to content

fix: keep text outline stable under zoom - #603

Closed
rokokol wants to merge 1 commit into
Satty-org:mainfrom
rokokol:fix/text-outline-zoom
Closed

fix: keep text outline stable under zoom#603
rokokol wants to merge 1 commit into
Satty-org:mainfrom
rokokol:fix/text-outline-zoom

Conversation

@rokokol

@rokokol rokokol commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #596.

The Alt text outline stroked each glyph with a miter-joined stroke. When the canvas is scaled (zoom), femtovg renders text through direct path-stroking of the real glyph contour instead of the glyph atlas, and two issues surfaced there:

  • the default miter join spikes at the sharp corners of glyph outlines, so the outline visually "explodes" the further you zoom in — this is the reported bug;
  • femtovg additionally scales the stroke width by its internal font_scale (a quantized canvas average scale) on top of the transform, so the outline grew disproportionately with zoom and no longer matched the exported image.

Neither is visible in the export because that path uses only a translation (no scale) and goes through the glyph atlas, where the stroke width is taken raw.

Fix: stroke the outline with round joins and divide the width back out by that same font_scale (mirroring quantize(avg_scale, 0.1).min(7.0)). The border stays smooth and keeps a constant thickness relative to the glyphs at every zoom level, matching the export.

Verified by hand: large text, strong zoom, both Inverted and Contrast outline modes — outline stays smooth and its thickness is stable across zoom and matches the saved PNG.

The Alt text outline stroked each glyph with a miter-joined stroke. When the
canvas is scaled (zoom), femtovg renders text through direct path-stroking of
the real glyph contour instead of the glyph atlas, where two issues surfaced:

- the default miter join spikes at the sharp corners of glyph outlines, so the
  outline visually "explodes" the further you zoom in (Satty-org#596);
- femtovg additionally scales the stroke width by its internal font_scale (a
  quantized canvas average scale) on top of the transform, so the outline grew
  disproportionately with zoom and no longer matched the exported image.

Stroke the outline with round joins and divide the width back out by that same
font_scale, so the border stays smooth and keeps a constant thickness relative
to the glyphs at every zoom level, matching the export.

Fixes Satty-org#596
@RobertMueller2

RobertMueller2 commented Aug 7, 2026

Copy link
Copy Markdown
Member

Thank you for the fix. Apparently there's a merge conflict here, did you base this of an older commit of yours?

@robertwidfen

Copy link
Copy Markdown
Collaborator

I debugged this a bit. The fix (idea) was working until #589 was merged which is upgrading femtovg from 0.25.0 to 0.26.0.

IMHO looks like a issue in femtovg.

Created a issue there - femtovg/femtovg#311 - maybe they can help.

@rokokol

rokokol commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Yes, I forgot to update my local repository before fix. And, looks like it's definitely problem with femtovg, thanks for the issue!

@robertwidfen

Copy link
Copy Markdown
Collaborator

I applied your original changes slightly modified in PR #605.

Can you try it?

It keeps the outline mostly stable - but the fix is odd. I do not understand the internals of femtovg. A fix in femtovg would be better. 🙃

robertwidfen added a commit to robertwidfen/Satty that referenced this pull request Aug 8, 2026
Fixes Satty-org#596 - partly.

But it is odd any should not be like this.

The value to switch scaling was manually determined.

See
- PR Satty-org#603
- femtovg/femtovg#311
@robertwidfen

robertwidfen commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

A fix in femtovg is coming: femtovg/femtovg#312

So I close this.

@rokokol

rokokol commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the silence, been busy lately. Glad to see things worked out in the end :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text outline "explodes" when zooming in

3 participants