More stuff. I should probably write that OpenType features test now.

This commit is contained in:
Pietro Gagliardi 2017-06-10 03:37:17 -04:00
parent d63a5b23b1
commit f0813ac6e4
4 changed files with 10 additions and 3 deletions

View File

@ -372,6 +372,8 @@ static void applyAndFreeFontAttributes(struct foreachParams *p)
font = defaultFont;
CFRetain(font);
} else
// note that this handles the difference between NULL and empty uiOpenTypeFeatures properly as far as conversion to native data formats is concerned (NULL does not generate a features dictionary; empty just produces an empty one)
// TODO but what about from the OS's perspective on all OSs?
font = [cfa toCTFont];
CFAttributedStringSetAttribute(p->mas, range, kCTFontAttributeName, font);
CFRelease(font);

View File

@ -92,7 +92,7 @@ _UI_ENUM(uiDrawUnderlineColor) {
// a glyph shape to use.
//
// If a font does not support a certain feature, that feature will be
// ignored.
// ignored. (TODO verify this on all OSs)
//
// See the OpenType specification at
// https://www.microsoft.com/typography/otspec/featuretags.htm

View File

@ -154,7 +154,10 @@ static uiForEach processAttribute(uiAttributedString *s, uiAttributeSpec *spec,
}
break;
case uiAttributeFeatures:
// TODO make sure NULLs are handled properly on all platforms in this part of the code
// only generate an attribute if spec->Features is not NULL
// TODO state that this is allowed
if (spec->Features == NULL)
break;
featurestr = otfToPangoCSSString(spec->Features);
addattr(p, start, end,
FUTURE_pango_attr_font_features_new(featurestr));

View File

@ -174,7 +174,9 @@ static uiForEach processAttribute(uiAttributedString *s, uiAttributeSpec *spec,
}
break;
case uiAttributeFeatures:
// TODO make sure this behaves properly if spec->Features is NULL
// only generate an attribute if spec->Features is not NULL
if (spec->Features == NULL)
break;
dt = otfToDirectWrite(spec->Features);
hr = p->layout->SetTypography(dt, range);
if (hr != S_OK)