You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
epaint should probably use unicode-segmentation to split strings with Unicode awareness. And ultimately the Glyph type needs to own a grapheme cluster instead of a char. I.e., the chr field might be changed to a String, Range, or even &'a str.
This should help improve written language integration, and will also fix bugs with text rendering. For example, if you insert an emoji with skin tone (which is composed of two Unicode code points) egui will render two Glyphs:
I discovered this issue as I was making a terminal-emulator-like project. I am rendering strings directly with Galleys and I have a need to count the number of fixed-width columns in each Galley row. char does not accurately map to a single cell in my "terminal" (as demonstrated above). But the Glyph type and its Row counterpart are the closest thing that egui exposes for getting the length of a row after it is broken into paragraphs by text layout.
The text was updated successfully, but these errors were encountered:
emilk
changed the title
epaint::text::Glyph should own a grapheme cluster, not a charepaint::text::Glyph should own a grapheme cluster, not a char
Jul 8, 2024
epaint
should probably useunicode-segmentation
to split strings with Unicode awareness. And ultimately theGlyph
type needs to own a grapheme cluster instead of achar
. I.e., thechr
field might be changed to aString
,Range
, or even&'a str
.This should help improve written language integration, and will also fix bugs with text rendering. For example, if you insert an emoji with skin tone (which is composed of two Unicode code points) egui will render two
Glyph
s:You can see the specific code points with the
escape_unicode()
method:Prints:
Additional context:
I discovered this issue as I was making a terminal-emulator-like project. I am rendering strings directly with
Galley
s and I have a need to count the number of fixed-width columns in eachGalley
row.char
does not accurately map to a single cell in my "terminal" (as demonstrated above). But theGlyph
type and itsRow
counterpart are the closest thing thategui
exposes for getting the length of a row after it is broken into paragraphs by text layout.The text was updated successfully, but these errors were encountered: