In order to fix the issue with cursor positioning a subpixel-aware draw
text operation within rencache was required.
With this modification the cursor positioning problem is completely
resolved.
A new function renderer.draw_text_subpixel is introduced to perform
consecutive, inline, text drawings with subpixel accuracy.
In order to get right the cursor position on text on mouse clicks it is
needed to take into account text's subpixel positioning.
This fix mostly corrects the problem but cursor positioning is still
somewhat inaccurate for long lines due to repeated commands to draw a text
along a line. Repeated draw text calls make the subpixel information
lost and small errors will add-up.
Now toolbarview always compute up-to-date sizes and spacing to adapt to
changes in icon big font.
For treeview and toolbarview revert the goto_size approach to use the
original approach of rxi/lite. In order to make it work when user resizes
dragging the divider we use the view optional method set_target_size().
This latter changes the view's target size instead of changing its size
right away. The size is only changed by the lite's layout and animation
system.
Remove the config.treeview_size variable that was no longer working because
plugins are loaded before the user's config.
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