[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] tt_face_get_name fails to find ASCII name
From: |
Kenichi Handa |
Subject: |
[Devel] tt_face_get_name fails to find ASCII name |
Date: |
Fri, 28 May 2004 11:23:33 +0900 (JST) |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) |
Dear Sirs,
I have a problem with using Freetype 2.1.7 for the Japanese
fonts HG-GothicB.ttf and HG-MinchoL.ttf that are contained
in Solaris 2.8.
They have this kind of nameRecords for their family names.
(nameRecord (1)
(platformID 1) (encodingID 0) (languageID 0) (nameID 1)
(length 10) (offset #x0063))
(nameRecord (9)
(platformID 3) (encodingID 1) (languageID 1041) (nameID 1)
(length 14) (offset #x016A))
The function tt_face_get_name (in src/sfnt/sfobjs.c) prefers
the second record even if it contains non-English name. So,
I'm now using the attached quick&dirty patch. Could you
please fix this problem in a cleaner way?
Regards,
---
Ken'ichi HANDA
address@hidden
diff -c /usr/local/work/freetype-2.1.7/src/sfnt/sfobjs.c /home/handa/sfobj.c
*** /usr/local/work/freetype-2.1.7/src/sfnt/sfobjs.c Thu Oct 30 06:43:51 2003
--- /home/handa/sfobj.c Fri May 28 11:00:41 2004
***************
*** 41,47 ****
/* convert a UTF-16 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
! FT_Memory memory )
{
FT_String* string;
FT_UInt len, code, n;
--- 41,48 ----
/* convert a UTF-16 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
! FT_Memory memory,
! int check_only)
{
FT_String* string;
FT_UInt len, code, n;
***************
*** 50,55 ****
--- 51,67 ----
len = (FT_UInt)entry->stringLength / 2;
+ if (check_only)
+ {
+ for ( n = 0; n < len; n++ )
+ {
+ code = FT_NEXT_USHORT( read );
+ if ( code > 127 )
+ return NULL;
+ }
+ return (FT_String *) 1;
+ }
+
if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
return NULL;
***************
*** 71,77 ****
/* convert a UCS-4 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_ucs4( TT_NameEntry entry,
! FT_Memory memory )
{
FT_String* string;
FT_UInt len, code, n;
--- 83,90 ----
/* convert a UCS-4 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_ucs4( TT_NameEntry entry,
! FT_Memory memory,
! int check_only)
{
FT_String* string;
FT_UInt len, code, n;
***************
*** 80,85 ****
--- 93,109 ----
len = (FT_UInt)entry->stringLength / 4;
+ if (check_only)
+ {
+ for ( n = 0; n < len; n++ )
+ {
+ code = (FT_UInt)FT_NEXT_ULONG( read );
+ if ( code > 127 )
+ return NULL;
+ }
+ return (FT_String *) 1;
+ }
+
if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
return NULL;
***************
*** 101,107 ****
/* convert an Apple Roman or symbol name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_other( TT_NameEntry entry,
! FT_Memory memory )
{
FT_String* string;
FT_UInt len, code, n;
--- 125,132 ----
/* convert an Apple Roman or symbol name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_other( TT_NameEntry entry,
! FT_Memory memory,
! int check_only )
{
FT_String* string;
FT_UInt len, code, n;
***************
*** 110,115 ****
--- 135,151 ----
len = (FT_UInt)entry->stringLength;
+ if (check_only)
+ {
+ for ( n = 0; n < len; n++ )
+ {
+ code = *read++;
+ if ( code > 127 )
+ return NULL;
+ }
+ return (FT_String *) 1;
+ }
+
if ( FT_MEM_NEW_ARRAY( string, len + 1 ) )
return NULL;
***************
*** 129,135 ****
typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry,
! FT_Memory memory );
/*************************************************************************/
--- 165,172 ----
typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry,
! FT_Memory memory,
! int check_only);
/*************************************************************************/
***************
*** 220,225 ****
--- 257,263 ----
}
}
+ Retry:
/* some fonts contain invalid Unicode or Macintosh formatted entries; */
/* we will thus favor names encoded in Windows formats if available */
/* */
***************
*** 231,241 ****
{
case TT_MS_ID_UNICODE_CS:
case TT_MS_ID_SYMBOL_CS:
! convert = tt_name_entry_ascii_from_utf16;
break;
case TT_MS_ID_UCS_4:
! convert = tt_name_entry_ascii_from_ucs4;
break;
default:
--- 269,279 ----
{
case TT_MS_ID_UNICODE_CS:
case TT_MS_ID_SYMBOL_CS:
! convert = tt_name_entry_ascii_from_utf16;
break;
case TT_MS_ID_UCS_4:
! convert = tt_name_entry_ascii_from_ucs4;
break;
default:
***************
*** 274,280 ****
}
}
! result = convert( rec, memory );
}
Exit:
--- 312,329 ----
}
}
! if (! convert (rec, memory, 1))
! {
! if (found_win >= 0)
! found_win = -1;
! else if (found_apple >= 0)
! found_apple = -1;
! else
! goto Exit;
! goto Retry;
! }
!
! result = convert( rec, memory, 0 );
}
Exit:
Diff finished. Fri May 28 11:00:57 2004
- [Devel] tt_face_get_name fails to find ASCII name,
Kenichi Handa <=