Mostly fix problem of offset with cursor positioning when using mouse
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.
This commit is contained in:
+3
-1
@@ -130,10 +130,12 @@ void rencache_draw_rect(RenRect rect, RenColor color) {
|
||||
|
||||
|
||||
int rencache_draw_text(RenFont *font, const char *text, int x, int y, RenColor color) {
|
||||
int subpixel_scale;
|
||||
RenRect rect;
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
rect.width = ren_get_font_width(font, text);
|
||||
int w = ren_get_font_width(font, text, &subpixel_scale);
|
||||
rect.width = ren_font_subpixel_round(w, subpixel_scale, 0);
|
||||
rect.height = ren_get_font_height(font);
|
||||
|
||||
if (rects_overlap(screen_rect, rect)) {
|
||||
|
||||
Reference in New Issue
Block a user