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

 
 

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

Submitted by:  Dimitrios Papadopoulos <dipapado>
Submitted on:  Tue 03 Mar 2015 12:28:37 PM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: FixedPrivacy: Public
Assigned to: Alexei Podtelezhnikov <podtelez>Open/Closed: Closed
Planned Release: 2.6.0

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project MemberIn charge of this item.
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>
Project MemberIn charge of this item.
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>
Project MemberIn charge of this item.
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>
Project 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>
Project MemberIn charge of this item.
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>
Project 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>
Project MemberIn charge of this item.
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>
Project MemberIn charge of this item.
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.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 21 Mar 2015 02:27:55 AM UTCpodtelezStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Mon 09 Mar 2015 05:47:27 PM UTCpodtelezStatusNone=>In Progress
      Planned ReleaseNone=>2.6.0
    Wed 04 Mar 2015 04:17:14 PM UTCwlAssigned toNone=>podtelez

    Back to the top


    Powered by Savane 3.1-cleanup1