Retry to decode strings in the name table as UTF-16BE in some cases.
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/376
This commit is contained in:
parent
81a26a6b62
commit
34883cb414
|
@ -699,6 +699,7 @@ FcSfntNameTranscode (FT_SfntName *sname)
|
||||||
iconv_t cd;
|
iconv_t cd;
|
||||||
#endif
|
#endif
|
||||||
FcChar8 *utf8;
|
FcChar8 *utf8;
|
||||||
|
FcBool redecoded = FcFalse;
|
||||||
|
|
||||||
for (i = 0; i < NUM_FC_FT_ENCODING; i++)
|
for (i = 0; i < NUM_FC_FT_ENCODING; i++)
|
||||||
if (fcFtEncoding[i].platform_id == sname->platform_id &&
|
if (fcFtEncoding[i].platform_id == sname->platform_id &&
|
||||||
|
@ -709,6 +710,7 @@ FcSfntNameTranscode (FT_SfntName *sname)
|
||||||
return 0;
|
return 0;
|
||||||
fromcode = fcFtEncoding[i].fromcode;
|
fromcode = fcFtEncoding[i].fromcode;
|
||||||
|
|
||||||
|
retry:
|
||||||
/*
|
/*
|
||||||
* Many names encoded for TT_PLATFORM_MACINTOSH are broken
|
* Many names encoded for TT_PLATFORM_MACINTOSH are broken
|
||||||
* in various ways. Kludge around them.
|
* in various ways. Kludge around them.
|
||||||
|
@ -858,6 +860,13 @@ FcSfntNameTranscode (FT_SfntName *sname)
|
||||||
{
|
{
|
||||||
iconv_close (cd);
|
iconv_close (cd);
|
||||||
free (utf8);
|
free (utf8);
|
||||||
|
if (!redecoded)
|
||||||
|
{
|
||||||
|
/* Regard the encoding as UTF-16BE and try again. */
|
||||||
|
redecoded = FcTrue;
|
||||||
|
fromcode = "UTF-16BE";
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,6 +874,14 @@ FcSfntNameTranscode (FT_SfntName *sname)
|
||||||
*outbuf = '\0';
|
*outbuf = '\0';
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (!redecoded)
|
||||||
|
{
|
||||||
|
/* Regard the encoding as UTF-16BE and try again. */
|
||||||
|
redecoded = FcTrue;
|
||||||
|
fromcode = "UTF-16BE";
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Reference in New Issue