Seen with some fonts like FiraSans, github issue:
https://github.com/franko/lite-xl/issues/46
The fix works essentially by looking to the bounds of each glyph to
accurately ensure that there are no overlaps between the glyphs.
The construction of the font atlas was changed to make some related
improvements now that the bounds of each glyph are know. The main
changes are:
- no longer align glyph on the baseline but align them on their upper
bounds. We ensure this way that very tall fonts do not leak in the
upper part
- terminate the row based on x bounds of the glyph to be more accurate
- for each row keep trace of the y of the more larger along y of the
glyph. The value is used to start a new row to be sure that the new
now does not overlap with the previous one
- sort glyphs by y size before drawing them. In this way the space
utilization is better. The algorithm used is the very simple insert
sort. It behaves like O(n^2) with the number of characters but should
be ok since n is always small, typically below 128.
- compute the optimal image width and height for the given font's atlas
for optimal memory usage. As a bonus now the lite's code don't have to
try and repeat to get a good image size
Text looks more correct without the gamma correction. With gamma correction
text looks too bold in dark mode and too light in light mode. This
behavior is a sign that gamma correction is not the right thing to do.
The problem is seen with gamma at 1.5 used previously but is even worst
if a gamma value of 2.2, the theoretical value, is used.