[cairo] UserFontFace vs FtFontFace management (cairomm)

Behdad Esfahbod behdad at behdad.org
Thu Dec 11 19:24:56 PST 2008


Jonathon Jongsma wrote:
> 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?

It's not completely unreasonable to to want to implement both.  Mostly in
cases where one is wrapping some other thing (say, a proxy API, binding, etc).
 Not a huge deal though.  After all, one can always use the C API directly.

Humm, lets add an error status for this.
CAIRO_STATUS_USER_FONT_METHOD_NOT_IMPLEMENTED it should be.  Anyone feeling
like doing that?

behdad


> jonner
> 


More information about the cairo mailing list