freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: more FT2 Mac ponderings


From: Just van Rossum
Subject: Re: more FT2 Mac ponderings
Date: Sun, 5 Mar 2000 12:25:44 +0100

At 6:21 PM +0100 04-03-2000, Pavel Kankovsky wrote:
>On Wed, 1 Mar 2000, Just van Rossum wrote:
>
>> I know, but let me explain again why I don't want to do that:
>> - I need the src/base/ftsystem.c implementation *as is* to support flat
>>files
>> - I don't want to duplicate that code just to add one little switch which,
>> IMHO, can be *much* more comfortably be implemented as a compiler switch in
>> ft_stream_new().
>
>What about the preprocessor trick I mentioned in one of my previous posts?
>
>#define FT_New_Stream FT_New_Stream_Ansi
>#include "..../base/ftsystem.c"
>#undef FT_New_Stream
>
>... FT_New_Stream(...)
>{
>... FT_New_Stream_Ansi(...) ...
>}

That's right: I forgot about that, sorry. Kinda ugly, but that'll work.
I've actually used that exact same mechanism to wrap the main() functions
of ftlint.c and ftview.c in an argc/argv emulation layer...

However, as I wrote before, I've found a way to do it by "just implementing
a driver" after all, but I'm doing things that may or may not be 100%
kosher. In case anyone cares, here's what I did.

In my driver->interface.init_face() routine I do the following:
- check wether the driver can handle the file (using the stream->pathname
field for that since the stream itself is useless to me), bail out if it
can't.
- close the (stdio) stream
- reinitialize the stream as a memory stream, pointing to raw sfnt data in
memory (or to raw T1 data, but I haven't implemented that yet)
- reinitialize the face->driver field to the TrueType driver (or the T1
driver) instead my own driver (!)
- call face->driver->interface.init_face(), so as to delegate the real work
to a "real" driver.

My FOND_FaceRec is a union of TT_FaceRec and T1_FaceRec...

So far, this seems to work nicely, and it seems the "client" code doesn't
care that I've just changed the stream *and* the driver... There's only one
line somewhere after init_face() gets called that uses the original driver
variable, but I'll probably patch that to use face->driver instead.

Just





reply via email to

[Prev in Thread] Current Thread [Next in Thread]