bugThe FreeType Project - Bugs: bug #30373, Cannot load some Type 1 fonts

 
 

bug #30373: Cannot load some Type 1 fonts

Submitted by:  Tor Andersson <ccxvii>
Submitted on:  Tue 06 Jul 2010 10:52:56 PM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: FixedPrivacy: Public
Assigned to: suzuki toshiya <mpsuzuki>Open/Closed: Closed
Planned Release: 2.3.13

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 02 Oct 2010 08:45:32 AM UTC, comment #9:

Since there aren't comments or complaints I assume that it works. Consequently, I'm closing this bug.

Werner LEMBERG <wl>
Project Administrator
Tue 31 Aug 2010 09:43:10 AM UTC, comment #8:

About 2 months will be passing after applying your patch,
could you test?

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Sat 10 Jul 2010 03:38:22 PM UTC, comment #7:

Thanks, your patch is applied.
Please test.

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Sat 10 Jul 2010 12:25:38 PM UTC, comment #6:

Better but not perfect.

My test file has another font that caused problems by
having no unicode characters at all, causing the code to
skip the "if ( encoding->count > 0 )" test, and return
FT_Err_No_Unicode_Glyph_Name. Explicitly setting error
to FT_Err_Ok after the test for FT_Err_No_Unicode_Glyph_Name
seems to solve the problem.

I end up with a font with zero charmaps, but that's another issue.
The font asks for /Standard encoding, but has no glyphs in that
character set, so no charmap is expected.

I've attached the CFF font and a patch.

(file #20935, file #20936)

Tor Andersson <ccxvii>
Fri 09 Jul 2010 12:04:54 PM UTC, comment #5:

Werner, thank you for comment.
I've introduced new error `PSnames_Err_No_Unicode_Glyph_Name'.
b8ca6de3653b5c3d50e9fadc6a1d7b606deffbdb
fixes this issue.

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Thu 08 Jul 2010 07:51:32 PM UTC, comment #4:

Good idea. Please do so.

Werner LEMBERG <wl>
Project Administrator
Thu 08 Jul 2010 04:25:30 PM UTC, comment #3:

Werner,
BTW, the error `PSnames_Err_Invalid_Arguments' is slightly
difficult for the error-catcher to know what's wrong. If the
introduction of new FT_Err_XXX is arguable, I want to propose
to add new error to indicate the failure of the synthesis of
Unicode (or given encode) charmap. Please give me your
comment.

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Thu 08 Jul 2010 03:28:34 PM UTC, comment #2:

I'm sorry for my introduction of new bug in the commit.
My analysis is following:

1) it is possible that all glyph names in a PS font cannot
be related with Unicode. In the case of font.pfa, maybe
it is designed for mathematical glyphs, the glyph name
"/trianglerightsld" cannot be mapped to any Unicode character
by FT2.

2) Type1 & Type42 drivers tries to synthesize Unicode
charmap for first (as a fallback charmap) from the glyph
name list. The first FT_CMap_New() does such.
This synthesized Unicode charmap is a fallback, so FT2
proceeds to make more natural charmap from its encoding type.
The second FT_CMap_New() does such.

/* first of all, try to synthesize a Unicode charmap */
charmap.platform_id = 3;
charmap.encoding_id = 1;
charmap.encoding = FT_ENCODING_UNICODE;

FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );

/* now, generate an Adobe Standard encoding when appropriate */
charmap.platform_id = 7;
clazz = NULL;

switch ( type1->encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
charmap.encoding_id = TT_ADOBE_ID_STANDARD;
clazz = cmap_classes->standard;
break;

/* snip */

default:
;
}

if ( clazz )
error = FT_CMap_New( clazz, NULL, &charmap, NULL );

#if 0
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
#endif
}
}

Exit:
return error;
}

3) For a PS font including no glyphname that can be mapped
to Unicode, the first FT_CMap_New() returns an error
(PSnames_Err_Invalid_Argument). This is not fatal error,
if the second FT_CMap_New() finishes successfully.

However, if first FT_CMap_New() returns any memory-related
error (new FT_CMap record allocation, extending face->charmaps[],
etc etc), the second FT_CMap_New() should not be invoked
to avoid confusing the error.

I made a mistake which handles this non-fatal error
in first FT_CMap_New() as a fatal error.
Thus, following modification fixes this issue.
Soon I will commit it to GIT repository.

diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 1183b42..3f64595 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -499,7 +499,7 @@
charmap.encoding = FT_ENCODING_UNICODE;

error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
- if ( error )
+ if ( error && FT_Err_Invalid_Argument != error )
goto Exit;

/* now, generate an Adobe Standard encoding when appropriate */
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index de88465..97dc8e2 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -335,7 +335,7 @@
charmap.encoding = FT_ENCODING_UNICODE;

error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
- if ( error )
+ if ( error && FT_Err_Invalid_Argument != error )
goto Exit;

/* now, generate an Adobe Standard encoding when appropriate */

(file #20923)

suzuki toshiya <mpsuzuki>
Project AdministratorIn charge of this item.
Thu 08 Jul 2010 05:47:04 AM UTC, comment #1:

Yes, this commit causes the failure.

Toshiya-san, do you have time to fix it?

Werner LEMBERG <wl>
Project Administrator
Tue 06 Jul 2010 10:52:56 PM UTC, original submission:

I get error code 6 (invalid argument) when trying to open a
type 1 (pfa) font with the latest freetype. It looks like this
commit is the culprit:

commit a874c7ecca00b9a2b228537685a5aa4427e00b99
Author: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
Date: Sun Jul 4 12:08:41 2010 +0900

Check error value by `FT_CMap_New'.

* src/cff/cffobjs.c (cff_face_init): Check error value by
`FT_CMap_New'.
* src/pfr/pfrobjs.c (pfr_face_init): Ditto.
* src/type1/t1jobjs.c (T1_Face_Init): Ditto.
* src/type42/t42jobjs.c (T42_Face_Init): Ditto.

Tor Andersson <ccxvii>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #20935:  PBMHFF+TT9736o00-0333.cff added by ccxvii (1KiB - application/octet-stream)
file #20936:  empty-cmap-fix.patch added by ccxvii (1KiB - application/octet-stream)
file #20923:  fix-30373_20100709a.patch added by mpsuzuki (930B - text/x-patch)
file #20910:  font.pfa added by ccxvii (8KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mpsuzuki (Updated the item)
  • -unavailable- added by wl (Posted a comment)
  • -unavailable- added by ccxvii (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 15 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 02 Oct 2010 08:45:32 AM UTCwlStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Sat 10 Jul 2010 03:38:22 PM UTCmpsuzukiStatusIn Progress=>Ready For Test
    Sat 10 Jul 2010 02:01:45 PM UTCmpsuzukiStatusFixed=>In Progress
      Open/ClosedClosed=>Open
    Sat 10 Jul 2010 12:25:38 PM UTCccxviiAttached File-=>Added PBMHFF+TT9736o00-0333.cff, #20935
      Attached File-=>Added empty-cmap-fix.patch, #20936
    Fri 09 Jul 2010 12:04:54 PM UTCmpsuzukiStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.3.13
    Thu 08 Jul 2010 03:28:34 PM UTCmpsuzukiAttached File-=>Added fix-30373_20100709a.patch, #20923
      StatusConfirmed=>In Progress
    Thu 08 Jul 2010 12:02:45 PM UTCmpsuzukiStatusNone=>Confirmed
    Thu 08 Jul 2010 05:47:04 AM UTCwlAssigned toNone=>mpsuzuki
    Tue 06 Jul 2010 10:52:56 PM UTCccxviiAttached File-=>Added font.pfa, #20910

    Back to the top


    Powered by Savane 3.1-cleanup1