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

Closed
opened 2026-01-31 00:41:35 +00:00 by claunia · 2 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
Author
Owner

@beviu commented on GitHub (Feb 20, 2020):

  Run0 = A @ 1
  Run1 = B @ 0.5
  Run2 = C @ 0.5
- Run3 = D @ 0.5
+ Run3 = D @ 1

(I think)

@beviu commented on GitHub (Feb 20, 2020): ```diff Run0 = A @ 1 Run1 = B @ 0.5 Run2 = C @ 0.5 - Run3 = D @ 0.5 + Run3 = D @ 1 ``` (I think)
Author
Owner

@lhecker commented on GitHub (Oct 10, 2024):

Since scaling glyphs resulted in complaints about the skewed look, we've since replaced the renderer with one that supports arbitrary overlaps and replaced the common box drawing glyphs with ones that are builtin and always "correct".

@lhecker commented on GitHub (Oct 10, 2024): Since scaling glyphs resulted in complaints about the skewed look, we've since replaced the renderer with one that supports arbitrary overlaps and replaced the common box drawing glyphs with ones that are builtin and always "correct".
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6554