bugThe FreeType Project - Bugs: bug #44412, Different results in linux and...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #44412: Different results in linux and windows from the FT_DivFix

Submitter:  Dimitrios Papadopoulos <dipapado>
Submitted:  Tue 03 Mar 2015 12:28:37 PM UTC
   
 
Severity:  3 - Normal Item Group:  Incorrect behaviour
Status:  Fixed Privacy:  Public
Assigned to:  podtelez Open/Closed:  Closed
Planned Release:  2.6.0

Jump to the original submission

Sat 21 Mar 2015 02:27:55 AM UTC, comment #9: 

I've shored up FT_Tan a bit too. I might still want to work on small rotations, but that is not urgent. Closing...

Alexei Podtelezhnikov <podtelez>
Group Member
Thu 12 Mar 2015 02:12:37 PM UTC, comment #8: 

It works, thanks :)

Dimitrios Papadopoulos <dipapado>
Wed 11 Mar 2015 07:33:14 PM UTC, comment #7: 

The rendering discrepancy should now be fixed in git. Please test.

Alexei Podtelezhnikov <podtelez>
Group Member
Mon 09 Mar 2015 05:47:27 PM UTC, comment #6: 

These are definitely two separate bugs under one roof:

1) Mishandling of 180 degree turns in ftstroke.c (ft_stroker_inside)

2) Ignorance about tangent singularities in fttrigon.c (FT_Tan)

I'll fix both shortly.

 

Alexei Podtelezhnikov <podtelez>
Group Member
Wed 04 Mar 2015 04:17:14 PM UTC, comment #5: 

I agree.  Fixing FT_Tan is certainly good.

Do you have time to work on this?  I'm assigning it to you :-)

Werner LEMBERG <wl>
Group administrator
Wed 04 Mar 2015 02:52:05 PM UTC, comment #4: 

Two ideas:

1) in ftstroker.c use this instead

      FT_Fixed  min_length = ft_pos_abs( FT_MulDiv( stroker->radius,
                                                    FT_Sin( theta ),
                                                    FT_Cos( theta ) ) );

2) in fttrigon.c fix FT_Tan, which should be more careful to avoid overflowing FT_DivFix by checking the arguments.

I begin to lean towards the second solution.

Alexei Podtelezhnikov <podtelez>
Group Member
Tue 03 Mar 2015 09:00:07 PM UTC, comment #3: 

Alexei, what exactly do you mean with `I'd rather fix the stroker'?

Werner LEMBERG <wl>
Group administrator
Tue 03 Mar 2015 06:37:06 PM UTC, comment #2: 

Never mind. FT_DivFix(16777216,-2) overflows 32 bits. Checking for this is an overhead. I'd rather fix the stroker.

Alexei Podtelezhnikov <podtelez>
Group Member
Tue 03 Mar 2015 05:44:59 PM UTC, comment #1: 

Please update to 2.5.5 or later. Things got  fixed. I suspect this is 32/64-bit issue

Alexei Podtelezhnikov <podtelez>
Group Member
Tue 03 Mar 2015 12:28:37 PM UTC, original submission:  

Using the FT_Glyph_Stroke gives different results under windows and linux.
More specific the following part it troubles me.

/* compute minimum required length of lines */
FT_Fixed  min_length = ft_pos_abs( FT_MulFix(stroker->radius,FT_Tan( theta ) ) );
(this is called by the ft_stroker_inside)


The stroker->radius = 32 and theta = 5898240 the FT_Tan returns under windows 0 and udner linux -2147483647.
The FT_Tan is calling the FT_DivFix(16777216, -2), i am expecting that the results are the same using or windows either linux.

The version which i am using is 2.5.3.

Under windows is called the
FT_EXPORT_DEF( FT_Long )
  FT_DivFix( FT_Long  a,
             FT_Long  b )
  {
    FT_Int32   s;
    FT_UInt32  q;


    s = 1;
    if ( a < 0 )
    {
      a = -a;
      s = -1;
    }
    if ( b < 0 )
    {
      b = -b;
      s = -s;
    }

    if ( b == 0 )
      /* check for division by 0 */
      q = 0x7FFFFFFFL;
    else
      /* compute result directly */
      q = (FT_UInt32)( ( ( (FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b );

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


and under linux is called the:

FT_EXPORT_DEF( FT_Long )
  FT_DivFix( FT_Long  a,
             FT_Long  b )
  {
    FT_Int32   s;
    FT_UInt32  q;


    /* XXX: this function does not allow 64-bit arguments */
    s  = (FT_Int32)a; a = FT_ABS( a );
    s ^= (FT_Int32)b; b = FT_ABS( b );

    if ( (FT_UInt32)b == 0 )
    {
      /* check for division by 0 */
      q = (FT_UInt32)0x7FFFFFFFL;
    }
    else if ( ( a >> 16 ) == 0 )
    {
      /* compute result directly */
      q = (FT_UInt32)( ( (FT_ULong)a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b;
    }
    else
    {
      /* we need more bits; we have to do it by hand */
      FT_Int64  temp, temp2;


      temp.hi  = (FT_Int32)( a >> 16 );
      temp.lo  = (FT_UInt32)a << 16;
      temp2.hi = 0;
      temp2.lo = (FT_UInt32)( b >> 1 );
      FT_Add64( &temp, &temp2, &temp );
      q = ft_div64by32( temp.hi, temp.lo, (FT_Int32)b );
    }

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

Font file upon request.

Dimitrios Papadopoulos <dipapado>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by podtelez (Posted a comment)
  • -email is unavailable- added by dipapado (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-03-21 podtelez StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2015-03-09 podtelez StatusNone In Progress
        Planned ReleaseNone 2.6.0
    2015-03-04 wl Assigned toNone podtelez

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code