bugThe FreeType Project - Bugs: bug #43271, Broken CFF fonts

 
 

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

bug #43271: Broken CFF fonts

Submitter:  Denis Simuntis <outqb>
Submitted:  Sun 21 Sep 2014 02:42:52 PM UTC
   
 
Severity:  3 - Normal Item Group:  Incorrect behaviour
Status:  Fixed Privacy:  Public
Assigned to:  darnold Open/Closed:  Closed
Planned Release:  2.5.4

Jump to the original submission

Thu 02 Oct 2014 10:17:41 PM UTC, comment #7: 

Just to follow up, the fix was to change the overflow detection to use approximate logarithms (FT_MSB) and to clamp scaledStem.

Dave Arnold <darnold>
Group Member
Thu 02 Oct 2014 04:35:53 AM UTC, comment #6: 

This is fixed in the git repository.  Please test!  And thanks for the report.

Werner LEMBERG <wl>
Group administrator
Thu 25 Sep 2014 11:24:08 PM UTC, comment #5: 

Good catch.

In the original Adobe code, FixMul always detects overflow and clamps. When we moved to FreeType, we wanted to use the existing  FT_MulFix, which is non-clamping. Werner and I discussed this exact line at the time because it was identified as one place where the clamping behavior was required. We had a simple plan to handle this, but something seems to have gone wrong. I need to research it a bit more.

Dave Arnold <darnold>
Group Member
Wed 24 Sep 2014 06:58:40 PM UTC, comment #4: 

FT_DivFix is actually protected against the overflowing result: see ftcalc.c:301 in ft_div64by32. I am still not sure if this is the right approach though. It is not nice to be overflowing like this at very reasonable sizes. I think that the 1/1000th of a pixel as a huge overkill for the resolution in comparison to more common 1/64th in FreeType.

Alexei Podtelezhnikov <podtelez>
Group Member
Mon 22 Sep 2014 08:52:13 PM UTC, comment #3: 

Alexei, I haven't looked at why the results are wider than 32 bits (that might be another issue) but the fact is that overflow really occurs and it's not checked for properly. Once this is done correctly, font distortion goes away.

Denis Simuntis <outqb>
Mon 22 Sep 2014 08:33:06 PM UTC, comment #2: 

Dave, please have a look!

Werner LEMBERG <wl>
Group administrator
Mon 22 Sep 2014 05:07:20 PM UTC, comment #1: 

FT_MulFix does or emulates 64-bit calculations with 32-bit arguments and the result should 32-bits as well. Are you saying that the results are wider than 32-bits?

Who needs stem darkening at this huge sizes? (hint, hint at the proper patch)

Alexei Podtelezhnikov <podtelez>
Group Member
Sun 21 Sep 2014 02:42:52 PM UTC, original submission:  

Some CFF fonts get broken at particular sizes. The culprit function is cf2_computeDarkening(). It seems that scaledStem and stemWidthPer1000 are incorrectly checked for overflow. Examples of fonts that this problem can be reproduced with are "Adobe Garamond Pro Regular 601pt" and "Birch Std Regular 601pt". See attached screenshots showing the problem and the patch to fix it.

Denis Simuntis <outqb>

 

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

Attached Files
file #32156:  cf2font.c.patch added by outqb (2KiB - application/octet-stream)
file #32157:  Birch Std Regular 601.png added by outqb (28KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by darnold (Posted a comment)
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by podtelez (Posted a comment)
  • -email is unavailable- added by outqb (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-10-02 wl StatusNone Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.5.4
    2014-09-22 wl Assigned toNone darnold
    2014-09-21 outqb Attached File- Added Adobe Garamond Pro Regular 601.png, #32155
        Attached File- Added cf2font.c.patch, #32156
        Attached File- Added Birch Std Regular 601.png, #32157

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code