Coalesce adjacent glyph scale corrections to reduce total run count and split activity #6549

Open
opened 2026-01-31 00:41:27 +00:00 by claunia · 0 comments
Owner

Originally created by @miniksa on GitHub (Feb 20, 2020).

To correct the scaling factor of glyphs (the vertical height) to fit inside a single cell, a correction factor is added in CustomTextLayout.

This takes the form of filling the _glyphScaleCorrections vector as we do _CorrectGlyphRun and then turns into splits around each glyph in the parent _CorrectGlyphRuns.

This represents identifying when two or more adjacent characters need the same scale factor and reducing the number of corrections/splits created as the original algorithm is relatively naive.

Example:
If B and C both need a scale factor of 0.5...

A   B   C   D
1   .5  .5   1

_glyphScaleCorrections will have two values
IDX = 1, SCALE = 0.5 (for the B)
IDX = 2, SCALE = 0.5 (for the C)

and 4 runs will be created
Run0 = A @ 1
Run1 = B @ 0.5
Run2 = C @ 0.5
Run3 = D @ 0.5

The thought here is that we could collapse _glyphScaleCorrections into one record
IDX = 1, SCALE = 0.5, LEN = 2 (for the B and C together)

and then only 3 runs would be created
Run0 = A @ 1
Run1 = B C @ 0.5
Run2 = D @ 1

Originally created by @miniksa on GitHub (Feb 20, 2020). To correct the scaling factor of glyphs (the vertical height) to fit inside a single cell, a correction factor is added in `CustomTextLayout`. This takes the form of filling the `_glyphScaleCorrections` vector as we do `_CorrectGlyphRun` and then turns into splits around each glyph in the parent `_CorrectGlyphRuns`. This represents identifying when two or more adjacent characters need the same scale factor and reducing the number of corrections/splits created as the original algorithm is relatively naive. Example: If B and C both need a scale factor of 0.5... ``` A B C D 1 .5 .5 1 ``` `_glyphScaleCorrections` will have two values IDX = 1, SCALE = 0.5 (for the B) IDX = 2, SCALE = 0.5 (for the C) and 4 runs will be created Run0 = A @ 1 Run1 = B @ 0.5 Run2 = C @ 0.5 Run3 = D @ 0.5 The thought here is that we could collapse `_glyphScaleCorrections` into one record IDX = 1, SCALE = 0.5, LEN = 2 (for the B and C together) and then only 3 runs would be created Run0 = A @ 1 Run1 = B C @ 0.5 Run2 = D @ 1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6549