Glyphs and graphemes [was Re: Cult-like behaviour]
rosuav at gmail.com
Tue Jul 17 05:30:42 EDT 2018
On Tue, Jul 17, 2018 at 7:03 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>> On Tue, Jul 17, 2018 at 6:27 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> For me, the issue is where do I produce a line break in my text output?
>>> Currently, I'm just counting codepoints to estimate the width of the
>> Well, that's just flat out wrong, then. Counting graphemes isn't going
>> to make it any better. Grab a well-known library like Pango and let it
>> do your measurements for you, *in pixels*. Or better still, just poke
>> your text to a dedicated text-display widget and let it display it
> What I'd need is for the tty to tell me what column the cursor is
> visually. Or better yet, the tty would have to tell me where the column
> would be *after* I emit the next grapheme cluster.
Are you prepared for the possibility that emitting characters won't
change what column you're in? Start a new line, then emit one Arabic
character. What column are you in? Now emit three more Arabic
characters, completing the word. What column? Now emit a U+0020 SPACE.
What column? Now emit some Latin characters, followed by more Arabic.
Where are you?
More information about the Python-list