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:
Francesco Abbate
2021-03-06 16:18:24 +01:00
parent 913549a7b6
commit 9ff6a0325e
6 changed files with 61 additions and 19 deletions
+4 -2
View File
@@ -34,11 +34,13 @@ RenFont* ren_load_font(const char *filename, float size, unsigned int renderer_f
void ren_free_font(RenFont *font);
void ren_set_font_tab_width(RenFont *font, int n);
int ren_get_font_tab_width(RenFont *font);
int ren_get_font_width(RenFont *font, const char *text);
int ren_get_font_width(RenFont *font, const char *text, int *subpixel_scale);
int ren_get_font_height(RenFont *font);
int ren_get_font_subpixel_scale(RenFont *font);
int ren_font_subpixel_round(int width, int subpixel_scale, int orientation);
void ren_draw_rect(RenRect rect, RenColor color);
void ren_draw_image(RenImage *image, RenRect *sub, int x, int y, RenColor color);
int ren_draw_text(RenFont *font, const char *text, int x, int y, RenColor color);
void ren_draw_text(RenFont *font, const char *text, int x, int y, RenColor color);
#endif