summaryrefslogtreecommitdiff
path: root/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-01-04 17:23:13 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-01-04 17:23:13 +0100
commit13f2ea664a9c5e3fdf318ef75914e2e876b5aaef (patch)
treee8ea772741ca82f88f3cc881a44c4a763d5bb1de /src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
parentd3988f9bdcd3cf463113b43fb0f1f22724e69f42 (diff)
Cairo/Pango: compute character widths fast and string widths accurately
This commit has Fl_Cairo_Graphics_Driver compute string widths in 2 ways: 1) when the string contains several unicode characters, the width of the whole string is computed, accounting for kerning when it occurs; 2) when the string contains a single unicode character, its width is computed, memorised, and re-used next time it's necessary. The effect of this approach is - Fl_Text_Display is fast because it uses memorised single character widths repeatedly - Fl_Input is drawn accurately because the cursor position is determined by string widths, not by sums of character widths.
Diffstat (limited to 'src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H')
-rw-r--r--src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
index 0b5eee198..c6fa15403 100644
--- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
+++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.H
@@ -50,7 +50,7 @@ private:
bool *needs_commit_tag_; // NULL or points to whether cairo surface was drawn to
cairo_t *dummy_cairo_; // used to measure text width before showing a window
int linestyle_;
- int width_unscaled_(unsigned int c);
+ int do_width_unscaled_(const char* str, int n);
protected:
cairo_t *cairo_;
PangoContext *pango_context_;