freetype
[Top][All Lists]
Advanced

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

Re: [ft] Why is FT_F26Dot6 defined as a signed long


From: Wink Saville
Subject: Re: [ft] Why is FT_F26Dot6 defined as a signed long
Date: Thu, 14 Feb 2019 11:58:09 -0800

> > I'm curious why FT_F26Dot6 is a signed long and not a FT_Int32?  I
> > would have expected it to be a 32 bit fixed point value.
>
> The library is quite old; at the time of its inception, `long' was
> 32bit on most platforms, and C types like `int32_t' didn't exist yet
> (or were so new that just a very small set of compilers supported it
> then).

Got it, historical.

>
> On the other hand, using a 64bit entity has the advantage of tagging
> an unsigned 32bit value as `not set', for example, by assigning
> value -1 to it.

Interesting, but on a 32bit platform, with long == 32 bits, that wouldn't work.



After getting this email I tried changing FT_F2Dot14 to FT_Int16. And FT_F26Dot6
and FT_Fixed to FT_Int32. I "fixed" of all of the compiler warnings
I'd caused and
got it compile, but my test program failed with memory corruption issues when
loading a font.

Attached is git diff of the change on top of VER-2-9-1 if you care to
look. I suspect
the problem is associated with one or more of the changes from
FT_Long* to FT_Fixed*
in the lower level code.

I did find a possible latent bug. The routine af_wraper_compute as
defined in afwrap.c
has the a_delta parameter defined as a FT_Pos:

  FT_LOCAL_DEF( void )
  af_warper_compute( AF_Warper      warper,
                     AF_GlyphHints  hints,
                     AF_Dimension   dim,
                     FT_Fixed      *a_scale,
                     FT_Pos         *a_delta )

But in afwrap.h a_delta is a FT_Fixed:

  FT_LOCAL( void )
  af_warper_compute( AF_Warper      warper,
                     AF_GlyphHints  hints,
                     AF_Dimension   dim,
                     FT_Fixed      *a_scale,
                     FT_Fixed      *a_delta );

So at line 298 in update-types.patch I changed afwrap.h so a_delta is a FT_Pos:

diff --git a/src/autofit/afwarp.h b/src/autofit/afwarp.h
index 520b1be90..21defce8f 100644
--- a/src/autofit/afwarp.h
+++ b/src/autofit/afwarp.h
@@ -52,7 +52,7 @@ FT_BEGIN_HEADER
                      AF_GlyphHints  hints,
                      AF_Dimension   dim,
                      FT_Fixed      *a_scale,
-                     FT_Fixed      *a_delta );
+                     FT_Pos        *a_delta );

Any feed back welcome.

-- Wink

Attachment: update-types.patch
Description: Text Data


reply via email to

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