diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-21 14:00:26 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-21 14:00:26 +0100 |
| commit | 14a5f705c8e3385a637be3377f0800b30c38e589 (patch) | |
| tree | c8199a77311468cec3cc7fc2e0b168e60b39a109 /src/fl_utf8.cxx | |
| parent | 2f7d7adfcf4bec55fa5e007947e4a455e85d8930 (diff) | |
Improve handling of text containing context-dependent unicode points.
This commit makes platforms Windows and macOS compute string widths
with the same mechanism as what is in place for platforms Wayland/X11:
- the width of a string containing a single codepoint is computed and
memorized in the table of character widths;
- the width of a string containing several codepoints is computed as
such rather than as the sum of the widths of its composing characters.
The result is that FLTK text widgets input and draw correctly also
complex emojis encoded with context-dependent codepoints.
Function fl_utf8_remove_context_dependent() is no longer necessary.
Diffstat (limited to 'src/fl_utf8.cxx')
| -rw-r--r-- | src/fl_utf8.cxx | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx index 05e45ded3..6a69e0780 100644 --- a/src/fl_utf8.cxx +++ b/src/fl_utf8.cxx @@ -1630,30 +1630,3 @@ unsigned fl_utf8from_mb(char* dst, unsigned dstlen, const char* src, unsigned sr } /** @} */ - -#ifndef FL_DOXYGEN - -/* This function removes from an UTF-8 string its context-dependent codepoints - when there are any, and returns the length of the possibly shortened string. - */ -int fl_utf8_remove_context_dependent(char *text, int len) { - if (len > 1 && fl_utf_nb_char((const uchar*)text, len) > 1) { - // Some emojis are expressed by a series of Unicode points - char *p = text, *end = text + len; - while (p < end) { // loop over all unicode points of the series - int l_point; - unsigned u = fl_utf8decode(p, end, &l_point); // extract one such unicode point - if ((u >= 0xFE00 && u <= 0xFE0F) // variation selectors - || u == 0x200D // zero-width joiner - || (u >= 0x1F3FB && u <= 0x1F3FF) // EMOJI MODIFIERS FITZPATRICK TYPE - ) { // remove context-dependent unicode points - memmove((void*)p, p + l_point, (end - (p+l_point)) + 1); - end -= l_point; - len -= l_point; - } else p += l_point; // keep other unicode points - } - } - return len; -} - -#endif // ! FL_DOXYGEN |
