Repository navigation
renderText: smooth outlines along the antialiased glyph edge - #78
Merged
Merged
Conversation
The outline was the distance to the nearest pixel at least half covered, so its edge followed that pixel staircase (bumpy at larger widths). Near the outline's edge, the distance now goes to the edge points of the pixels around the nearest covered one (3x3): from the pixel center along the coverage gradient to where a straight edge would cover it as much, like Gustavson's antialiased distance transform. The distance transform also returns the nearest sample for that. Against text rendered at 8x and scaled down, the mean error of the outline's coverage drops from about 0.3 to 0.07-0.1 (Source Sans, Open Sans, stroke widths 1-24). Distances beyond the outline are left out of the row pass, so it costs about as much as before (64px text, 3px outline: 6.6 -> 7.9 ms). effects target regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The outline from
renderText(strokeWidth) now follows the glyphs' antialiased edges instead of their pixel staircase. Wide strokes were visibly bumpy before.Cause
The outline came from the distance to the nearest pixel that is at least half covered. That treats the glyph as a binary mask, so the outer edge of the stroke traced the mask's stairs. The effect grew with the stroke width.
Fix
Measurements
strokeWidthbeyond the edge. Before, it was about half a pixel narrower.The
effectstarget is regenerated, because its outlined text changes.🤖 Generated with Claude Code
https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ