freetype-devel
[Top][All Lists]
Advanced

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

Re: [Devel] incorrect types for some arguments in the TrueType driver


From: Steve Hartwell
Subject: Re: [Devel] incorrect types for some arguments in the TrueType driver
Date: Sat, 17 Apr 2004 18:59:55 -0700

On Apr 17, 2004, at 2:44 PM, Graham Asher wrote:
This is a detail of TrueType. FreeType uses 32-bit values. For example,
FT_Get_Char_Index returns FT_UInt, and FT_Load_Glyph takes FT_UInt. For
consistency, drivers for specific typeface formats should accept this type.
They can reject any out-of-range values.

You are correct; in particular, since an FT_Slot_LoadFunc is defined as a pointer to a function whose glyph_index parameter is an FT_UInt, then indeed Load_Glyph() in ttdriver.c should have the same parameter type. On a machine which does not promote shorts to longs in function parameters, this mismatch will indeed cause problems in Load_Glyph().

But Load_Glyph() is still declared differently from an FT_Slot_LoadFunc, since its first parameter is a TT_GlyphSlot instead of a FT_GlyphSlot. They are "compatible" types (the former points to a struct which contains the latter), but not in the eyes of the gcc compiler.

In fact, the other pointers to functions in tt_driver_class are also being cast for the same reason. Since your friend's problem was due to long vs short parameter in Load_Glyph(), I thought it might be useful to see if anything else was mismatched, so I changed the declarations and definitions in my local copies of ttobjs.h, ttobjs.c, and ttdriver.c to match the function pointer types defined in FT_Driver_ClassRec, and made the FT_xxx -> TT_xxx casts in the body of the functions themselves.

Nothing dramatic :-) I noticed that the definition of Set_Pixel_Sizes() in ttdriver.c was missing two parameters (which are unused), but other than that, nothing that would cause your friend further problems AFAICT.

On the upside, the function pointers no longer need casting in tt_driver_class; I can send in the patch if anyone's interested.

Our test harness now runs perfectly on Palm OS, so these changes seem to
have had the desired effect.
Great!

Best regards,

Steve Hartwell





reply via email to

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