Open YakoYakoYokuYoku opened 1 year ago
I was toying with PyCairo to see if it had the capability to display emojis from the OpenMoji SVG-in-OT font.
import cairo import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk def draw(da, ctx): ctx.move_to(80, 80) ctx.set_font_size(40.0) ctx.show_text("Hello, World!") extent = ctx.text_extents("Hello, World!") ctx.rel_move_to(extent.x_bearing, 0) ctx.select_font_face("OpenMoji") ctx.show_text(" 🌎") def main(): win = Gtk.Window() win.connect("destroy", lambda w: Gtk.main_quit()) win.set_default_size(450, 180) drawingarea = Gtk.DrawingArea() win.add(drawingarea) drawingarea.connect("draw", draw) win.show_all() Gtk.main() if __name__ == "__main__": main()
But things didn't work out as it doesn't render the globe and it throws a context save and restore mismatch error.
Traceback (most recent call last): File "test.py", line 13, in draw ctx.show_text(" 🌎") cairo.Error: Context.restore() without matching Context.save() (test.py:2278413): Gtk-WARNING **: 12:05:02.802: drawing failure for widget 'GtkDrawingArea': cairo_restore() without matching cairo_save() (test.py:2278413): Gtk-WARNING **: 12:05:02.802: drawing failure for widget 'GtkWindow': cairo_restore() without matching cairo_save()
Though if I use Noto Color Emoji instead no error is emitted and I can see the globe. Any ideas?
Noto Color Emoji
This looks like an issue in the cairo library itself, not pycairo the python binding to cairographics.
I was toying with PyCairo to see if it had the capability to display emojis from the OpenMoji SVG-in-OT font.
But things didn't work out as it doesn't render the globe and it throws a context save and restore mismatch error.
Though if I use
Noto Color Emoji
instead no error is emitted and I can see the globe. Any ideas?