Handled uiOpenTypeFeatures NULL equality. This only added more TODOs elsewhere :|
This commit is contained in:
parent
b73721905f
commit
d63a5b23b1
|
@ -113,13 +113,7 @@ struct foreachParams {
|
||||||
return NO;
|
return NO;
|
||||||
if (self.stretch != b.stretch)
|
if (self.stretch != b.stretch)
|
||||||
return NO;
|
return NO;
|
||||||
// TODO make this part of uiOpenTypeFeaturesEqual() on all platforms
|
// this also handles NULL cases
|
||||||
if (self.features == NULL && b.features == NULL)
|
|
||||||
return YES;
|
|
||||||
if (self.features != NULL && b.features == NULL)
|
|
||||||
return NO;
|
|
||||||
if (self.features == NULL && b.features != NULL)
|
|
||||||
return NO;
|
|
||||||
if (!uiOpenTypeFeaturesEqual(self.features, b.features))
|
if (!uiOpenTypeFeaturesEqual(self.features, b.features))
|
||||||
return NO;
|
return NO;
|
||||||
return YES;
|
return YES;
|
||||||
|
|
|
@ -87,6 +87,10 @@ void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeatures
|
||||||
|
|
||||||
int uiOpenTypeFeaturesEqual(const uiOpenTypeFeatures *a, const uiOpenTypeFeatures *b)
|
int uiOpenTypeFeaturesEqual(const uiOpenTypeFeatures *a, const uiOpenTypeFeatures *b)
|
||||||
{
|
{
|
||||||
|
if (a == NULL && b == NULL)
|
||||||
|
return 1;
|
||||||
|
if (a == NULL || b == NULL)
|
||||||
|
return 0;
|
||||||
return [a->tags isEqualToDictionary:b->tags];
|
return [a->tags isEqualToDictionary:b->tags];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,11 +142,8 @@ _UI_EXTERN int uiOpenTypeFeaturesGet(uiOpenTypeFeatures *otf, char a, char b, ch
|
||||||
_UI_EXTERN void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data);
|
_UI_EXTERN void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data);
|
||||||
|
|
||||||
// uiOpenTypeFeaturesEqual() returns nonzero if a is equal to b.
|
// uiOpenTypeFeaturesEqual() returns nonzero if a is equal to b.
|
||||||
// a is defined as equal to b if and only if both
|
// a is defined as equal to b if and only if both have exactly the same
|
||||||
// - contain the same tags, without any extras or missing tags
|
// tags with exactly the same values, or if both are NULL.
|
||||||
// either way, and
|
|
||||||
// - have each tag have the same values
|
|
||||||
// TODO what if either or both are NULL?
|
|
||||||
_UI_EXTERN int uiOpenTypeFeaturesEqual(const uiOpenTypeFeatures *a, const uiOpenTypeFeatures *b);
|
_UI_EXTERN int uiOpenTypeFeaturesEqual(const uiOpenTypeFeatures *a, const uiOpenTypeFeatures *b);
|
||||||
|
|
||||||
typedef struct uiAttributeSpec uiAttributeSpec;
|
typedef struct uiAttributeSpec uiAttributeSpec;
|
||||||
|
|
|
@ -154,7 +154,7 @@ static uiForEach processAttribute(uiAttributedString *s, uiAttributeSpec *spec,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case uiAttributeFeatures:
|
case uiAttributeFeatures:
|
||||||
// TODO handle NULLs properly on all platforms
|
// TODO make sure NULLs are handled properly on all platforms in this part of the code
|
||||||
featurestr = otfToPangoCSSString(spec->Features);
|
featurestr = otfToPangoCSSString(spec->Features);
|
||||||
addattr(p, start, end,
|
addattr(p, start, end,
|
||||||
FUTURE_pango_attr_font_features_new(featurestr));
|
FUTURE_pango_attr_font_features_new(featurestr));
|
||||||
|
|
|
@ -133,6 +133,11 @@ int uiOpenTypeFeaturesEqual(const uiOpenTypeFeatures *a, const uiOpenTypeFeature
|
||||||
guint i;
|
guint i;
|
||||||
int equal = 0;
|
int equal = 0;
|
||||||
|
|
||||||
|
if (a == NULL && b == NULL)
|
||||||
|
return 1;
|
||||||
|
if (a == NULL || b == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
ak = copySortedKeys(a->tags);
|
ak = copySortedKeys(a->tags);
|
||||||
bk = copySortedKeys(b->tags);
|
bk = copySortedKeys(b->tags);
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,7 @@ static uiForEach processAttribute(uiAttributedString *s, uiAttributeSpec *spec,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case uiAttributeFeatures:
|
case uiAttributeFeatures:
|
||||||
|
// TODO make sure this behaves properly if spec->Features is NULL
|
||||||
dt = otfToDirectWrite(spec->Features);
|
dt = otfToDirectWrite(spec->Features);
|
||||||
hr = p->layout->SetTypography(dt, range);
|
hr = p->layout->SetTypography(dt, range);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
|
|
|
@ -79,6 +79,10 @@ void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeatures
|
||||||
|
|
||||||
int uiOpenTypeFeaturesEqual(const uiOpenTypeFeatures *a, const uiOpenTypeFeatures *b)
|
int uiOpenTypeFeaturesEqual(const uiOpenTypeFeatures *a, const uiOpenTypeFeatures *b)
|
||||||
{
|
{
|
||||||
|
if (a == NULL && b == NULL)
|
||||||
|
return 1;
|
||||||
|
if (a == NULL || b == NULL)
|
||||||
|
return 0;
|
||||||
// TODO make sure this is correct
|
// TODO make sure this is correct
|
||||||
return *(a->tags) == *(b->tags);
|
return *(a->tags) == *(b->tags);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue