[hb-info] If name not found, fall back to English

This commit is contained in:
Behdad Esfahbod 2023-01-22 10:06:05 -07:00
parent 7cae553592
commit 334f59c955
1 changed files with 45 additions and 24 deletions

View File

@ -31,6 +31,27 @@
const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_UPEM; const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_UPEM;
const unsigned SUBPIXEL_BITS = 0; const unsigned SUBPIXEL_BITS = 0;
static void
_hb_ot_name_get_utf8 (hb_face_t *face,
hb_ot_name_id_t name_id,
hb_language_t language,
unsigned int *text_size /* IN/OUT */,
char *text /* OUT */)
{
static hb_language_t en = hb_language_from_string ("en", -1);
unsigned len = *text_size;
if (!hb_ot_name_get_utf8 (face, name_id,
language,
&len, text))
{
len = *text_size;
hb_ot_name_get_utf8 (face, name_id,
en,
&len, text);
}
*text_size = len;
}
struct info_t struct info_t
{ {
@ -267,7 +288,7 @@ struct info_t
char name[16384]; char name[16384];
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, name_id, _hb_ot_name_get_utf8 (face, name_id,
language, language,
&name_len, name); &name_len, name);
@ -495,7 +516,7 @@ struct info_t
{ {
char name[16384]; char name[16384];
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, entries[i].name_id, _hb_ot_name_get_utf8 (face, entries[i].name_id,
language, language,
&name_len, name); &name_len, name);
@ -732,7 +753,7 @@ struct info_t
char name[64]; char name[64];
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, label_id, _hb_ot_name_get_utf8 (face, label_id,
language, language,
&name_len, name); &name_len, name);
@ -850,7 +871,7 @@ struct info_t
char name[64]; char name[64];
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, label_id, _hb_ot_name_get_utf8 (face, label_id,
language, language,
&name_len, name); &name_len, name);
@ -907,7 +928,7 @@ struct info_t
char name[64]; char name[64];
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, axis.name_id, _hb_ot_name_get_utf8 (face, axis.name_id,
language, language,
&name_len, name); &name_len, name);
@ -940,7 +961,7 @@ struct info_t
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_id_t name_id = hb_ot_var_named_instance_get_subfamily_name_id (face, i); hb_ot_name_id_t name_id = hb_ot_var_named_instance_get_subfamily_name_id (face, i);
hb_ot_name_get_utf8 (face, name_id, _hb_ot_name_get_utf8 (face, name_id,
language, language,
&name_len, name); &name_len, name);
@ -984,7 +1005,7 @@ struct info_t
char name[64]; char name[64];
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, name_id, _hb_ot_name_get_utf8 (face, name_id,
language, language,
&name_len, name); &name_len, name);
const char *type = ""; const char *type = "";
@ -1019,7 +1040,7 @@ struct info_t
char name[64]; char name[64];
unsigned name_len = sizeof name; unsigned name_len = sizeof name;
hb_ot_name_get_utf8 (face, name_id, _hb_ot_name_get_utf8 (face, name_id,
language, language,
&name_len, name); &name_len, name);