Useful to draw whitespaces with alternate characters and colors
without slowing down the text rendering.
A new API is implemented. A renderer.replacements object can be created
to list the replacements.
In turns the function renderer.draw_text and draw_text_subpixel now accept
two optional arguments for replacements.
This reverts commit 461266e97d.
Related to github issue #122.
The void *data field is not used but the glyphset index can
someting be equal to -1 and the unused field prevent faulty
writes before the allocated struct.
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.
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
Add a Meson option "portable" to choose between "portable" and unix-like
directories. Add information about this option in the README.
To determine the user's directory use the variable USERPROFILE only on
Windows and use HOME otherwise.
Implement the "portable" option in the package build script.
Create the user's config init file if lite user's config directory does
not exists.
No longer use the awkward package.searchers but instead add user's
config dir at the end of package path.
It basically works by setting the data directory to
$prefix/share/lite-xl
where $prefix is determined so that $prefix/bin corresponds to EXEDIR.
The packages 'user' and 'user.*' are loaded from the directory
'$HOME/.config/lite-xl'.
The problem was that when the editor had no events the cursor was not
blinking because the event loop was blocking on wait_event.
Now we no longer calls wait_event without a timeout if the windows has
the focus. When the window has the focus the timeout is set to 1 / fps
so that the cursor can blinks.
In addition we react to the "focus lost" event to ensure the documents
are redrawn without the cursor.
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.