-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[introspection] Enable hb-cairo #4150
base: main
Are you sure you want to change the base?
Conversation
This is not working for me, though. If I try something like
But my installation is botched, so it might be only me. |
Build also have the following warnings:
|
Fixed these. |
This seems to be a |
Did you link to harfbuzz-cairo? |
I get a weirder error:
|
Linking with libharfbuzz_cairo fixes this one, but now I get:
|
Humm we're just passing pointers around. Is there an annotation that says it's an opaque pointer? |
cairo-1.0.gir seems to know what cairo.FontFace is, so I wonder what we are still missing. |
I get a similar error while using Pango as well: import gi
gi.require_version('cairo', '1.0')
gi.require_version('Pango', '1.0')
gi.require_version('PangoCairo', '1.0')
from gi.repository import cairo, Pango, PangoCairo
desc = Pango.font_description_from_string ("Sans Bold 27")
fontmap = PangoCairo.FontMap.get_default ()
context = fontmap.create_context ()
font = context.load_font (desc)
PangoCairo.Font.get_scaled_font (font)
So I’m starting to think either using cairo types from GI is broken, or we need some magic incantation to get it to work. |
If I'm reading this right, looks like cairo gi bindings are handwritten, and very incomplete to my eyes: Eg. the simplest function,
indeed, when I try to call that function, which should take three parameters, I get this error in Python:
Did cairo GI bindings ever work? |
I don’t really know, it seems like you can use some cairo with gtk, but probably that is the subset that was ever tested? |
No. Cairo does not have introspection data, outside of the small hand-written GIR that is only used to expose the boxed types of cairo-gobject needed to introspect GTK. Every language that provides a Cairo binding has to have a native binding. Of course, since the Cairo introspection data is handwritten, it can get out of sync. |
So is there anyway we can get hb-cairo introspection to work, namely the error in #4150 (comment) above? |
You should install pycairo and import it: import cairo
from gi.repository import Pango, PangoCairo instead of using: from gi.repository import cairo, Pango, PangoCairo This is typically how Cairo is used in Python. |
I tried that already, and I still get the same error: import cairo
import gi
gi.require_version('Pango', '1.0')
gi.require_version('PangoCairo', '1.0')
from gi.repository import Pango, PangoCairo
desc = Pango.font_description_from_string ("Sans Bold 27")
fontmap = PangoCairo.FontMap.get_default ()
context = fontmap.create_context ()
font = context.load_font (desc)
PangoCairo.Font.get_scaled_font (font)
|
Then that's a pygobject and/or pycairo bug: |
Sounds similar to this issue https://gitlab.gnome.org/GNOME/pygobject/-/issues/16, so likely a pygobject issue. |
However, CairoFontFace does have a record in: Same error when you search, other people (mostly on Ubuntu) solved by installing cairo gobject... But that doesn't seem to be my problem here. |
Yes, but based on this commit (which fixes the |
Wonder if this is not enough: |
That only really helps for properties and signal handlers, not for function arguments and return values, unless those arguments take a |
I see. Thanks. Okay, I'm binding font-face and scaled-font now. |
I confirm it works with my MR: |
Excellent! |
Now, there is still this warning while building HarfBuzz:
|
Yeah that one needs more work |
It's not even bound in cairo-gobject. So needs to go there first. Then in gobject-introspection handcoded cairo-1.0.gir.in, then in pygobject. I'll try to take a look. |
https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/468 |
https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/392 |
It's not clear to me how to teach GI that an array of cairo_glyph_t returned needs to be freed using cairo_glyph_free... |
With this, I don't get those warnings anymore. |
Not sure. My bad probably. Testing again. |
I don't get a warning. But the function is not exported to Python either. |
It has introspectable="0" attribute. |
Binding |
So, what should we do with this? |
I don’t know. I lost track of what is working and what is not. |
No description provided.