From: Detlef W. <det...@gm...> - 2017-05-24 18:34:37
|
Hi, since some days I have the problem, that pango does not render Umlauts anymore. Here is a short example: require 'gtk3' markup = '<span color="red">foooäöü</span>' win = Gtk::Window.new box = Gtk::Box.new :vertical win << box area = Gtk::DrawingArea.new win.set_default_size 200, 100 area.signal_connect(:draw) do |widget, context| layout = context.create_pango_layout layout.markup = markup context.move_to 25, 25 context.show_pango_layout layout end box.pack_start area, :expand => true, :fill => true label = Gtk::Label.new label.markup = markup box.pack_start label win.show_all Gtk.main It puts a Gtk::DrawingArea and a Gtk::Label in a window. The first renders the markup which contains German umlauts directly with Pango to a drawing context. The second one shows the same markup in a label. The first one is not displayed, but on it shows this warning: > Pango-WARNING **: pango_layout_set_markup_with_accel: Fehler in Zeile 1, Zeichen 42: »/« ist kein gültiges Zeichen, wenn es auf den schließenden Elementnamen »sp<« folgt; das erlaubte Zeichen ist »>« > from /home/det/.gem/ruby/2.3.0/gems/gobject-introspection-3.1.2/lib/gobject-introspection/loader.rb:566:in `block in define_method' > from /home/det/.gem/ruby/2.3.0/gems/pango-3.1.2/lib/pango/layout.rb:34:in `markup=' > from umlaut.rb:15:in `block in <main>' > from /home/det/.gem/ruby/2.3.0/gems/gobject-introspection-3.1.2/lib/gobject-introspection/loader.rb:110:in `invoke' > from /home/det/.gem/ruby/2.3.0/gems/gobject-introspection-3.1.2/lib/gobject-introspection/loader.rb:110:in `block in define_singleton_method' > from umlaut.rb:29:in `<main>' The label displays the markup without problems. Pango did it also right, since some days and some software updates ago. It is not only limited to umlauts, but - I think - to all characters which are not ASCII. I have checked the file with isutf8 and it is OK. Can anyone confirm this problem? I can get around the problem, if I substitute the problematic chars with its hex-values in a way like this: sprintf "&#x%x;", char.ord But this is nearly open end, if I don't want to limit the characters to use and very expensive in ruby. Then, in the warning is a reference to line 1 char 42. But the markup to display is only 32 chars long... What does this mean? After all I think, that it is a pango problem. Cheers, detlef |