Reduce LangTag from 3 language system tags to 1
This commit is contained in:
parent
155e92f259
commit
1ce11b4437
|
@ -895,20 +895,11 @@ def language_name_intersection (a, b):
|
||||||
def get_matching_language_name (intersection, candidates):
|
def get_matching_language_name (intersection, candidates):
|
||||||
return next (iter (c for c in candidates if not intersection.isdisjoint (get_variant_set (c))))
|
return next (iter (c for c in candidates if not intersection.isdisjoint (get_variant_set (c))))
|
||||||
|
|
||||||
maximum_tags = 0
|
|
||||||
for language, tags in sorted (ot.from_bcp_47.items ()):
|
for language, tags in sorted (ot.from_bcp_47.items ()):
|
||||||
if language == '' or '-' in language:
|
if language == '' or '-' in language:
|
||||||
continue
|
continue
|
||||||
print (' {\"%s\",\t{' % language, end='')
|
|
||||||
maximum_tags = max (maximum_tags, len (tags))
|
|
||||||
tag_count = len (tags)
|
|
||||||
for i, tag in enumerate (tags, start=1):
|
for i, tag in enumerate (tags, start=1):
|
||||||
if i > 1:
|
print (' {\"%s\",\t%s},\t/* ' % (language, hb_tag (tag)), end='')
|
||||||
print ('\t\t ', end='')
|
|
||||||
print (hb_tag (tag), end='')
|
|
||||||
if i == tag_count:
|
|
||||||
print ('}}', end='')
|
|
||||||
print (',\t/* ', end='')
|
|
||||||
bcp_47_name = bcp_47.names.get (language, '')
|
bcp_47_name = bcp_47.names.get (language, '')
|
||||||
bcp_47_name_candidates = bcp_47_name.split ('\n')
|
bcp_47_name_candidates = bcp_47_name.split ('\n')
|
||||||
intersection = language_name_intersection (bcp_47_name, ot.names[tag])
|
intersection = language_name_intersection (bcp_47_name, ot.names[tag])
|
||||||
|
@ -923,8 +914,6 @@ for language, tags in sorted (ot.from_bcp_47.items ()):
|
||||||
|
|
||||||
print ('};')
|
print ('};')
|
||||||
print ()
|
print ()
|
||||||
print ('static_assert (HB_OT_MAX_TAGS_PER_LANGUAGE == %iu, "");' % maximum_tags)
|
|
||||||
print ()
|
|
||||||
|
|
||||||
print ('/**')
|
print ('/**')
|
||||||
print (' * hb_ot_tags_from_complex_language:')
|
print (' * hb_ot_tags_from_complex_language:')
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -198,7 +198,7 @@ lang_matches (const char *lang_str, const char *spec)
|
||||||
struct LangTag
|
struct LangTag
|
||||||
{
|
{
|
||||||
char language[4];
|
char language[4];
|
||||||
hb_tag_t tags[HB_OT_MAX_TAGS_PER_LANGUAGE];
|
hb_tag_t tag;
|
||||||
|
|
||||||
int cmp (const char *a) const
|
int cmp (const char *a) const
|
||||||
{
|
{
|
||||||
|
@ -246,6 +246,7 @@ hb_ot_tags_from_language (const char *lang_str,
|
||||||
hb_tag_t *tags)
|
hb_tag_t *tags)
|
||||||
{
|
{
|
||||||
const char *s;
|
const char *s;
|
||||||
|
unsigned int tag_idx;
|
||||||
|
|
||||||
/* Check for matches of multiple subtags. */
|
/* Check for matches of multiple subtags. */
|
||||||
if (hb_ot_tags_from_complex_language (lang_str, limit, count, tags))
|
if (hb_ot_tags_from_complex_language (lang_str, limit, count, tags))
|
||||||
|
@ -254,7 +255,6 @@ hb_ot_tags_from_language (const char *lang_str,
|
||||||
/* Find a language matching in the first component. */
|
/* Find a language matching in the first component. */
|
||||||
s = strchr (lang_str, '-');
|
s = strchr (lang_str, '-');
|
||||||
{
|
{
|
||||||
const LangTag *lang_tag;
|
|
||||||
if (s && limit - lang_str >= 6)
|
if (s && limit - lang_str >= 6)
|
||||||
{
|
{
|
||||||
const char *extlang_end = strchr (s + 1, '-');
|
const char *extlang_end = strchr (s + 1, '-');
|
||||||
|
@ -263,12 +263,18 @@ hb_ot_tags_from_language (const char *lang_str,
|
||||||
ISALPHA (s[1]))
|
ISALPHA (s[1]))
|
||||||
lang_str = s + 1;
|
lang_str = s + 1;
|
||||||
}
|
}
|
||||||
lang_tag = hb_sorted_array (ot_languages).bsearch (lang_str);
|
if (hb_sorted_array (ot_languages).bfind (lang_str, &tag_idx))
|
||||||
if (lang_tag)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < *count && lang_tag->tags[i] != HB_TAG_NONE; i++)
|
while (tag_idx != 0 &&
|
||||||
tags[i] = lang_tag->tags[i];
|
0 == strcmp (ot_languages[tag_idx].language, ot_languages[tag_idx - 1].language))
|
||||||
|
tag_idx--;
|
||||||
|
for (i = 0;
|
||||||
|
i < *count &&
|
||||||
|
tag_idx + i < ARRAY_LENGTH (ot_languages) &&
|
||||||
|
0 == strcmp (ot_languages[tag_idx + i].language, ot_languages[tag_idx].language);
|
||||||
|
i++)
|
||||||
|
tags[i] = ot_languages[tag_idx + i].tag;
|
||||||
*count = i;
|
*count = i;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -417,7 +423,7 @@ hb_ot_tag_to_language (hb_tag_t tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH (ot_languages); i++)
|
for (i = 0; i < ARRAY_LENGTH (ot_languages); i++)
|
||||||
if (ot_languages[i].tags[0] == tag)
|
if (ot_languages[i].tag == tag)
|
||||||
return hb_language_from_string (ot_languages[i].language, -1);
|
return hb_language_from_string (ot_languages[i].language, -1);
|
||||||
|
|
||||||
/* Else return a custom language in the form of "x-hbotABCD" */
|
/* Else return a custom language in the form of "x-hbotABCD" */
|
||||||
|
@ -506,7 +512,7 @@ test_langs_sorted ()
|
||||||
for (unsigned int i = 1; i < ARRAY_LENGTH (ot_languages); i++)
|
for (unsigned int i = 1; i < ARRAY_LENGTH (ot_languages); i++)
|
||||||
{
|
{
|
||||||
int c = ot_languages[i].cmp (&ot_languages[i - 1]);
|
int c = ot_languages[i].cmp (&ot_languages[i - 1]);
|
||||||
if (c >= 0)
|
if (c > 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ot_languages not sorted at index %d: %s %d %s\n",
|
fprintf (stderr, "ot_languages not sorted at index %d: %s %d %s\n",
|
||||||
i, ot_languages[i-1].language, c, ot_languages[i].language);
|
i, ot_languages[i-1].language, c, ot_languages[i].language);
|
||||||
|
|
Loading…
Reference in New Issue