From f0813ac6e422758c0f778bacc772f328e918a961 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 10 Jun 2017 03:37:17 -0400 Subject: [PATCH] More stuff. I should probably write that OpenType features test now. --- darwin/attrstr.m | 2 ++ ui_attrstr.h | 2 +- unix/attrstr.c | 5 ++++- windows/attrstr.cpp | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/darwin/attrstr.m b/darwin/attrstr.m index 4d166fb0..6975ca06 100644 --- a/darwin/attrstr.m +++ b/darwin/attrstr.m @@ -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); diff --git a/ui_attrstr.h b/ui_attrstr.h index b39b39a2..0024442c 100644 --- a/ui_attrstr.h +++ b/ui_attrstr.h @@ -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 diff --git a/unix/attrstr.c b/unix/attrstr.c index 4d384daf..245ae7f6 100644 --- a/unix/attrstr.c +++ b/unix/attrstr.c @@ -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)); diff --git a/windows/attrstr.cpp b/windows/attrstr.cpp index 9dceaea6..f180f74b 100644 --- a/windows/attrstr.cpp +++ b/windows/attrstr.cpp @@ -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)