bugThe FreeType Project - Bugs: bug #26944, handling CFF CID charsets with...

 
 

bug #26944: handling CFF CID charsets with double entries

Submitted by:  bram tassyns <bramt>
Submitted on:  Fri 03 Jul 2009 07:38:43 AM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: FixedPrivacy: Public
Assigned to: Werner LEMBERG <wl>Open/Closed: Closed
Planned Release: 2.3.10

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sun 05 Jul 2009 12:56:42 PM UTC, comment #3:

Applied, thanks, with using `/* */' as comment delimiters.

Werner LEMBERG <wl>
Project AdministratorIn charge of this item.
Fri 03 Jul 2009 09:42:56 AM UTC, comment #2:

Of course i pasted to old version instead of the new one in the last post :(. Sry.

static FT_Error
cff_charset_compute_cids( CFF_Charset charset,
FT_UInt num_glyphs,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_UInt i;
FT_Long signedIndex;
FT_UShort max_cid = 0;

if ( charset->max_cid > 0 )
goto Exit;

for ( i = 0; i < num_glyphs; i++ )
if ( charset->sids[i] > max_cid )
max_cid = charset->sids[i];
max_cid++;

if ( FT_NEW_ARRAY( charset->cids, max_cid ) )
goto Exit;

// When multiple GIDs map to the same CID,
// we choose the lowest GID. This is not
// described in any spec, but it matches
// adobe's behaviour.
for ( signedIndex = num_glyphs-1; signedIndex >= 0 ; --signedIndex )
charset->cids[charset->sids[signedIndex]] = (FT_UShort)signedIndex;

charset->max_cid = max_cid;
charset->num_glyphs = num_glyphs;

Exit:
return error;
}

bram tassyns <bramt>
Fri 03 Jul 2009 09:40:00 AM UTC, comment #1:

Sry, the posted fix didn't build on windows (i'm mac user :s), here's an updated version:

static FT_Error
cff_charset_compute_cids( CFF_Charset charset,
FT_UInt num_glyphs,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_UInt i;
FT_UShort max_cid = 0;

if ( charset->max_cid > 0 )
goto Exit;

for ( i = 0; i < num_glyphs; i++ )
if ( charset->sids[i] > max_cid )
max_cid = charset->sids[i];
max_cid++;

if ( FT_NEW_ARRAY( charset->cids, max_cid ) )
goto Exit;

// When multiple GIDs map to the same CID,
// we choose the lowest GID. This is not
// described in any spec, but it matches
// adobe's behaviour.
for ( FT_Long j = num_glyphs-1; j >= 0 ; --j )
charset->cids[charset->sids[j]] = (FT_UShort)j;

charset->max_cid = max_cid;
charset->num_glyphs = num_glyphs;

Exit:
return error;
}

bram tassyns <bramt>
Fri 03 Jul 2009 07:38:43 AM UTC, original submission:

This isn't really a bug, but rather a difference in freetype's handling of an unspecified case and adobe's handling of it.

For our applications we usually take adobe's handling as a reference (unless we can proof that it's wrong of course :D). I don't know freetype's stance in this, but i think it would be nice if it behaves the same way.

So here's the issue. The attached font defines CID 92 to GIDs 21 and 22 (e and accent). FreeType currently chooses the higest GID (as did adobe up till acrobat 7). But more recent adobe versions (8,9) choose the lowest GID in this case. The fix for this is pretty small:

cffload.c: line 753

for ( i = 0; i < num_glyphs; i++ )
charset->cids[charset->sids[i]] = (FT_UShort)i;

->

// When multiple GIDs map to the same CID,
// we choose the lowest GID. This is not
// described in any spec, but it matches
// adobe's behaviour.
for ( FT_Long j = num_glyphs-1; j >= 0 ; --j )
charset->cids[charset->sids[j]] = (FT_UShort)j;

bram tassyns <bramt>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #18359:  CV_atelier-PS_small05.pdf added by bramt (16KiB - application/pdf)
file #18360:  OverlappingCharSet.cff added by bramt (4KiB - application/octet-stream)

 

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 bramt (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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 05 Jul 2009 12:56:42 PM UTCwlStatusNone=>Fixed
      Assigned toNone=>wl
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.3.10
    Fri 03 Jul 2009 07:38:43 AM UTCbramtAttached File-=>Added CV_atelier-PS_small05.pdf, #18359
      Attached File-=>Added OverlappingCharSet.cff, #18360

    Back to the top


    Powered by Savane 3.1-cleanup1