freetype-devel
[Top][All Lists]
Advanced

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

[Devel] bug in FT_Div64by32, Arial font does not work


From: Martin Muskens
Subject: [Devel] bug in FT_Div64by32, Arial font does not work
Date: Fri, 24 Aug 2001 11:19:11 +0200

Hi all,

I found out that many fonts don't work (including the Arial) with the new
library because of the new routine "FT_Div64by32" in ftcalc.c.
I replaced that routine with the old one, and now everything works great.

I did not have the time yet to see what's going on, but I think in some
cases the routine continues to make recursive calls. ( unfortunately my
Codewarrior on Macintosh does not support "break execution" so someone
working on Visual C++ should be able to pinpoint the bug much faster. Well,
if I have time to spare I will port it to my NT and submit any fix I find.

Bye

#ifdef OLDROUTINE
  FT_EXPORT_DEF( FT_Int32 )  FT_Div64by32( FT_Int64*  x,
                                           FT_Int32   y )
  {
    FT_Int32   s;
    FT_UInt32  q, r, i, lo;


    s  = x->hi;
    if ( s < 0 )
    {
      x->lo = (FT_UInt32)-(FT_Int32)x->lo;
      x->hi = ~x->hi + !( x->lo );
    }
    s ^= y;  y = ABS( y );

    /* Shortcut */
    if ( x->hi == 0 )
    {
      if ( y > 0 )
        q = x->lo / y;
      else
        q = 0x7FFFFFFFL;

      return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
    }

    r  = x->hi;
    lo = x->lo;

    if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here
*/
      return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
                             /* Return Max/Min Int32 if division overflow.
*/
                             /* This includes division by zero!
*/
    q = 0;
    for ( i = 0; i < 32; i++ )
    {
      r <<= 1;
      q <<= 1;
      r  |= lo >> 31;

      if ( r >= (FT_UInt32)y )
      {
        r -= y;
        q |= 1;
      }
      lo <<= 1;
    }

    return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
  }
#else
  FT_EXPORT_DEF( FT_Int32 )
  FT_Div64by32( FT_Int64*  x,
                FT_Int32   y )
  {
    FT_Int32   s;
    FT_UInt32  q;


    s  = x->hi;
    if ( s < 0 )
    {
      x->lo = (FT_UInt32)-(FT_Int32)x->lo;
      x->hi = ~x->hi + !( x->lo );
    }
    s ^= y;  y = ABS( y );

    /* Shortcut */
    if ( x->hi == 0 )
    {
      if ( y > 0 )
        q = ( x->lo + ( y >> 1 ) ) / y;
      else
        q = 0x7FFFFFFFL;

      return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
    }

    q = ft_div64by32( x->hi, x->lo, y );

    return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
  }
#endif



reply via email to

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