[cairo] cairo_ft_font_face_create_for_ft_face Subtlety
ldo at geek-central.gen.nz
Fri Mar 20 21:35:08 PDT 2015
The doc for cairo_ft_font_face_create_for_ft_face
says it “creates a new font face ... from a pre-opened FreeType face”.
What it doesn’t say is that, if you give it the same FT_Face twice, it
will return the same font_face_t.
You need to watch out for this, because the set_user_data dance will be
incorrect if you blindly do it every time. You need to call
get_user_data first to check if you have already attached a destroy
callback to this font_face_t, and skip doing it again if so.
I discovered this in the process of messing about with Multiple
Master/TrueType GX fonts. It looks like Cairo’s caching interferes
somewhat with the behaviour of these: to get around this, you have to
load the same font multiple times so that you can set different values
for the design coordinates on each copy.
More information about the cairo