More support for uiAttributeLanguage.
This commit is contained in:
parent
81b520249b
commit
85fd3b72af
|
@ -291,6 +291,32 @@ static int boolsEqual(struct attr *attr, uiAttributeSpec *spec)
|
||||||
return attr->spec.Value != 0 && spec->Value != 0;
|
return attr->spec.Value != 0 && spec->Value != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BCP 47 is ASCII-only
|
||||||
|
static int asciiStringsEqualCaseFold(const char *a, const char *b)
|
||||||
|
{
|
||||||
|
char c, d;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (*a == *b) {
|
||||||
|
if (*a == '\0')
|
||||||
|
return 1;
|
||||||
|
a++;
|
||||||
|
b++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
c = *a;
|
||||||
|
if (c >= 'A' && c <= 'Z')
|
||||||
|
c += 'a' - 'A';
|
||||||
|
d = *b;
|
||||||
|
if (d >= 'A' && d <= 'Z')
|
||||||
|
d += 'a' - 'A';
|
||||||
|
if (c != d)
|
||||||
|
return 0;
|
||||||
|
a++;
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int specsIdentical(struct attr *attr, uiAttributeSpec *spec)
|
static int specsIdentical(struct attr *attr, uiAttributeSpec *spec)
|
||||||
{
|
{
|
||||||
if (attr->spec.Type != spec->Type)
|
if (attr->spec.Type != spec->Type)
|
||||||
|
@ -298,6 +324,7 @@ static int specsIdentical(struct attr *attr, uiAttributeSpec *spec)
|
||||||
switch (attr->spec.Type) {
|
switch (attr->spec.Type) {
|
||||||
case uiAttributeFamily:
|
case uiAttributeFamily:
|
||||||
// TODO should we start copying these strings?
|
// TODO should we start copying these strings?
|
||||||
|
// TODO should this be case-insensitive?
|
||||||
return strcmp((char *) (attr->spec.Value), (char *) (spec->Value)) == 0;
|
return strcmp((char *) (attr->spec.Value), (char *) (spec->Value)) == 0;
|
||||||
case uiAttributeSize:
|
case uiAttributeSize:
|
||||||
// TODO use a closest match?
|
// TODO use a closest match?
|
||||||
|
@ -317,6 +344,8 @@ static int specsIdentical(struct attr *attr, uiAttributeSpec *spec)
|
||||||
attr->spec.A == spec->A;
|
attr->spec.A == spec->A;
|
||||||
case uiAttributeVerticalForms:
|
case uiAttributeVerticalForms:
|
||||||
return boolsEqual(attr, spec);
|
return boolsEqual(attr, spec);
|
||||||
|
case uiAttributeLanguage:
|
||||||
|
return asciiStringsEqualCaseFold((char *) (attr->spec.Value), (char *) (spec->Value));
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
// handles the rest
|
// handles the rest
|
||||||
|
|
|
@ -39,6 +39,7 @@ _UI_ENUM(uiAttribute) {
|
||||||
// TODO fallbacks (pango: enable or disable)
|
// TODO fallbacks (pango: enable or disable)
|
||||||
|
|
||||||
// TODO document that this will also enable language-specific font features (TODO on DirectWrite too?)
|
// TODO document that this will also enable language-specific font features (TODO on DirectWrite too?)
|
||||||
|
// TODO document that this should be strict BCP 47 form (A-Z, a-z, 0-9, and -) for maximum compatibility
|
||||||
uiAttributeLanguage, // BCP 47 string
|
uiAttributeLanguage, // BCP 47 string
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
Loading…
Reference in New Issue