Hello, sorry for the delay and thank your for your answer. 1.) What I do -- I am working on CLI a script that renders several rectangle objects with corresponding text strings into the cairo's SVGSurface.
So first, I use cairo to paint some rectangles and then I utilize pango to add a corresponding text string into the middle of every rectangle. So, no I dont use widgets. I use cairo (v 1.10.0), Pango (v 1.40.4) and PangoCairo. I know that there are some ways to utilize CSS, but not in Pango (as far as I know). 2.) So it looks like equivalents to functions like "pango_attr_family_new()" are not available in Python3. I currently use "Pango.parse_markup()" method for this. I suggest adding a third column (named something like "Python alternative") into the "Symbol Mapping" table (https://lazka.github.io/pgi-docs/Pango-1.0/mapping.html). So that for the "pango_attr_family_new()" and similar attr functions, there would be an alternative value "Pango.parse_markup()", "Pango.Layout.set_markup()" and "Pango.Layout.set_markup_with_accel()" (or just the first one). 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 workaround exists -- I compute the length of my text (len("saké")) and pass only an ascii version of the string. Fortunately "Pango.Layout.set_text()" works with an UTF strings. This bug of course makes "set_markup()" and "set_markup_with_accel()" methods de facto unusable. Thanks, S. Vlcek. On 05/05/2017 06:59 PM, infirit wrote: > Op 05/05/2017 om 05:32 PM schreef Slavomir Vlcek: >> 1.) Please could anyone tell me how to replace the c-based function >> "pango_attr_family_new()"? This is one of many functions >> that does not seem to have a python equivalent >> (according to http://lazka.github.io/pgi-docs/#Pango-1.0/mapping.html). > > There is an open bug on this [1]. There is however a alternative (better?) > way to style widgets in Gtk3, it is CSS. I recently modified a script to > show how it is done, see [2]. If you are not styling widgets please elaborate > what you are actually trying to do. >> 2.) By the way when I pass (unitialized) Pango.Attribute() instance >> to the insert() method, my script ends with SIGFAULT. >> >> attrs = Pango.AttrList() >> attr = Pango.Attribute() >> attrs.insert(attr) >> >> I guess that is not the correct behavior. > > Have not used Pango but reading the bug [1] it may be related to it. > > ~infirit > > [1] https://bugzilla.gnome.org/show_bug.cgi?id=646788 > [2] https://gist.github.com/infirit/cf4f531e03136b641471b079b8370ead _______________________________________________ python-hackers-list mailing list python-hackers-list@gnome.org https://mail.gnome.org/mailman/listinfo/python-hackers-list