[cairo] UserFontFace vs FtFontFace management (cairomm)

Ian Britten britten at caris.com
Wed Dec 3 06:56:11 PST 2008


Jonathon Jongsma wrote:

>> As I've start trying to use it, I got wondering if it wouldn't
>> make more sense (and be more C++-like) for UserFontFace to be
>> an abstract class, with a pure-virtual 'render()' method, and
>> virtual 'init()', etc, methods?

> Yes, the interface is technically still open to change.
> Just for reference, my initial implementation was done as an abstract 
> class with virtual methods (as you suggest), but I ran into some 
> complications by going that route.

[ snip ]

> Did that explanation make any  sense?

Ya, I got the gist of it... I'm not familiar with the Cairo
font-specific issues you mention (And I see that Behdad has already
added some comments), but I can see the C++ issue you're discussing.

I'm afraid I don't have a simple/elegant solution :(
So, how about something ugly?  :)
[ Stop laughing, and bear with me for a second... ]

If something awkward/tricky needs to be done, I'd (personally) rather
deal with it in one spot, rather than many.  As such, I'd be willing
to put up with some warts when _deriving_ a custom class (Once),
rather than each and every time I need to actually _use_ the derived
class.

Thus, I'd be open to adding silly "isFooOverridden()=0" methods,
or anything else(*) that would give you the information you need,
if it meant keeping the general usage of the class clean and simple.
(*) Maybe a 'getFooMethod()' that returns a member pointer, with
  the default returns NULL?  Dunno - Just another hack thought...

At the moment, I'm trying to figure out where/how to manage the
extra attributes I'm going to need, and am not looking forward to
helper structures, manual memory management, void pointers, etc.
Having a derived "MyUserFont", with members, copy constructor,
destructor, etc, would be well worth almost any other cost I had
to pay when deriving the class.

Anyways, that's just my $0.02 - Use it as you best see fit  :)
I'll probably have to proceed with the current (1.7.0) stuff for
now, but wouldn't have any objection if you change+improve things
in a future version.

Ian


More information about the cairo mailing list