Introduce subpixel text positioning within rencache

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.
This commit is contained in:
Francesco Abbate
2021-03-06 18:12:02 +01:00
parent 9ff6a0325e
commit 3426bc5d73
6 changed files with 51 additions and 24 deletions
+3 -2
View File
@@ -309,11 +309,12 @@ end
function DocView:draw_line_text(idx, x, y)
local tx, ty = x, y + self:get_line_text_y_offset()
local font = self:get_font()
local subpixel_scale = font:subpixel_scale()
local tx, ty = subpixel_scale * x, y + self:get_line_text_y_offset()
for _, type, text in self.doc.highlighter:each_token(idx) do
local color = style.syntax[type]
tx = renderer.draw_text(font, text, tx, ty, color)
tx = renderer.draw_text_subpixel(font, text, tx, ty, color)
end
end