* src/base/ftobjs.c (find_unicode_charmap): If search for a UCS-4

charmap fails, do the loop again while searching a UCS-2 charmap.
This favours MS charmaps over Apple ones.
This commit is contained in:
Werner Lemberg 2007-10-01 07:08:56 +00:00
parent 2be3f472dd
commit 74597ccd8f
2 changed files with 22 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2007-10-01 Werner Lemberg <wl@gnu.org>
* src/base/ftobjs.c (find_unicode_charmap): If search for a UCS-4
charmap fails, do the loop again while searching a UCS-2 charmap.
This favours MS charmaps over Apple ones.
2007-08-29 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* src/base/ftmac.c: Introduction of abstract "short" data types,

View File

@ -883,14 +883,13 @@
/* are limited to the BMP (said UCS-2 encoding.) */
/* */
/* This function is called from open_face() (just below), and also */
/* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE). */
/* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). */
/* */
static FT_Error
find_unicode_charmap( FT_Face face )
{
FT_CharMap* first;
FT_CharMap* cur;
FT_CharMap* unicmap = NULL; /* some UCS-2 map, if we found it */
/* caller should have already checked that `face' is valid */
@ -935,32 +934,32 @@
{
if ( cur[0]->encoding == FT_ENCODING_UNICODE )
{
unicmap = cur; /* record we found a Unicode charmap */
/* XXX If some new encodings to represent UCS-4 are added, */
/* they should be added here. */
/* XXX If some new encodings to represent UCS-4 are added, */
/* they should be added here. */
if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT &&
cur[0]->encoding_id == TT_MS_ID_UCS_4 ) ||
cur[0]->encoding_id == TT_MS_ID_UCS_4 ) ||
( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) )
/* Hurray! We found a UCS-4 charmap. We can stop the scan! */
cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) )
{
face->charmap = cur[0];
return 0;
return FT_Err_Ok;
}
}
}
/* We do not have any UCS-4 charmap. Sigh. */
/* Let's see if we have some other kind of Unicode charmap, though. */
if ( unicmap != NULL )
/* We do not have any UCS-4 charmap. */
/* Do the loop again and search for UCS-2 charmaps. */
cur = first + face->num_charmaps;
for ( ; --cur >= first; )
{
face->charmap = unicmap[0];
return 0;
if ( cur[0]->encoding == FT_ENCODING_UNICODE )
{
face->charmap = cur[0];
return FT_Err_Ok;
}
}
/* Chou blanc! */
return FT_Err_Invalid_CharMap_Handle;
}