Repository navigation
Fill glyph patterns column by column - #2511
Open
nikosavola wants to merge 4 commits into
Open
nikosavola wants to merge 4 commits into
nikosavola wants to merge 4 commits into
Conversation
- random texts at all alignments, partly outside bitmaps of several widths, at two font resolutions - the expected values come from the code before the column-wise fill
- `fill_pattern` worked out the clipping and shift of each 32 pixel column again for every row, and looked up the scanline out of line for every word. The column work is now done once, and each row is one shift and one or two ORs - `Bitmap::scanline` returns existing scanlines inline, only the allocation stays out of line
nikosavola
force-pushed
the
pr-text-glyphs
branch
from
October 14, 2026 22:01
a04d540 to
073eac5
Compare
- fill_pattern advanced the pattern pointer by one word per skipped row, but a font row takes stride words - with the wide fonts (stride 2 and up) the rows seen of a cut-off glyph came from the wrong pattern rows, garbling the text
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.
Text labels take most of the render time when a layout has many of them, and most of that is
Bitmap::fill_pattern. It worked out the clipping and shift of each 32 pixel column again for every row of a glyph, and looked upscanlineout of line for every word. Now the column work is done once, and each row is one shift and one or two ORs.Bitmap::scanlineis inline for scanlines that already exist. Only the allocation stays out of line.In a headless render of a layout with many labels,
fill_patternwas 42% of the instructions and the scanline lookup another 13%. The render is now about 1.4 times faster, the instruction count drops from 10.0G to 6.3G, and the images are the same bit for bit.The first test draws random texts into bitmaps and checks a hash of all pixels. The expected value comes from the code before the change.
This also fixes a bug in the clipped path. When a glyph starts above the top edge of the bitmap,
fill_patternskipped the clipped rows by whole words instead of whole rows, so the pattern pointer went out of step and the text was garbled. Fonts with more than one word per row are affected. The step is now one row ofstridewords. The second test renders the same text into a short and a tall bitmap and checks that the clipped rows match the fully drawn one. That test fails on the code before the fix.