[cairo] UserFontFace vs FtFontFace management (cairomm)
Jonathon Jongsma
jonathon at quotidian.org
Thu Dec 11 18:39:27 PST 2008
On 12/03/2008 01:49 PM, Behdad Esfahbod wrote:
>> Perhaps there's a better way to design that interface, but as you can
>> see the idea was simply to pass the glyphs as a vector (array). So with
>> this interface the user has no way to return a negative value for
>> num_glyphs -- std::vector::size() maps to num_glyphs, and the size of an
>> array is always non-negative. So in order to provide a default
>> implementation for this virtual function that returned a -1 for
>> num_glyphs, It seems that I would either have to revert to using C-style
>> arrays, or I would need to add an additional sentinal argument to the
>> cairomm interface (e.g. 'bool& call_unicode_to_glyphs_instead' :).
>> Neither of these options seem especially satisfying to me.
>
> The C interface is now written in stone. What we can do is to add a special
> cairo_status_t value for this case that will be interpreted as UNIMPLEMENTED
> only when used in this context. That's possible if you don't find any other
> solutions.
>
> behdad
OK, so I think I've found an acceptable workaround for this. In
essence, my default text_to_glyphs virtual function sets a flag in the C
object's user_data, and if that user_data flag is set, I pass a negative
value back for num_glyphs. So this workaround seems acceptable for my
'internal' use, but there's no way for a user to do the same thing
(since I don't expose the user_data key for that flag, etc). And since
I don't have any experience with advanced text stuff, I need some advice
whether this is OK or not. Is it reasonable for a user to implement
both of these methods and want to use text_to_glyphs in some
circumstances and unicode_to_glyph in other circumstances (in other
words, in a C implementation, register both callbacks and sometimes
return -1 for num_glyphs and sometimes return actual glyphs)? Or for a
given UserFont, is a user *always* going to use either one or the other?
jonner
More information about the cairo
mailing list