Re: How to create attributes in Pango



Op 15/05/17 om 15:28 schreef Slavomir Vlcek:
3.) However, the problem with these "markup" functions is that they are not able to crunch
    even a simple unicode string.

    This example fails with the Glib.Error for me:

    markup_text = "<span foreground=\"#ffffff\">" + "saké" + "</span>"
    ret, attrs, text, accel_char = Pango.parse_markup(markup_text, len(markup_text), "\u0000")

    GLib.Error: g-markup-error-quark: Error on line 1 char 48: '/' is not a valid character following the 
close element name 'span<'; the allowed character is '>' (2)

The problem I think is that the length meant here is the number of bytes
in markup_text. Calling len on the codepoints will return the number of
characters which, in this example, is one less as é is two bytes. With
len(markup_text.encode("UTF-8")) or -1 it works for me.

As for the docs, the docs maintainers is active here so I'll leave it to
him to comment on adding the column to the docs.

~infirit



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]