From 23ec771c869b7e27176e220fa16d6b106c40893e Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 15 Apr 2016 14:23:16 -0400 Subject: [PATCH] Removed uiFontDescriptor.SmallCaps; on Windows this has to be applied to layouts. --- darwin/drawtext.m | 10 +++++----- ui.h | 1 - unix/draw.c | 5 ++++- windows/drawtext.cpp | 3 --- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/darwin/drawtext.m b/darwin/drawtext.m index 5e4b197a..c29f71be 100644 --- a/darwin/drawtext.m +++ b/darwin/drawtext.m @@ -76,6 +76,8 @@ static void addFontSizeAttr(CFMutableDictionaryRef attr, double size) CFRelease(n); } +#if 0 +TODO // See http://stackoverflow.com/questions/4810409/does-coretext-support-small-caps/4811371#4811371 and https://git.gnome.org/browse/pango/tree/pango/pangocoretext-fontmap.c for what these do // And fortunately, unlike the traits (see below), unmatched features are simply ignored without affecting the other features :D static void addFontSmallCapsAttr(CFMutableDictionaryRef attr) @@ -118,6 +120,7 @@ static void addFontSmallCapsAttr(CFMutableDictionaryRef attr) CFDictionaryAddValue(attr, kCTFontFeatureSettingsAttribute, outerArray); CFRelease(outerArray); } +#endif // Named constants for these were NOT added until 10.11, and even then they were added as external symbols instead of macros, so we can't use them directly :( // kode54 got these for me before I had access to El Capitan; thanks to him. @@ -376,17 +379,14 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc) cfdesc = CTFontDescriptorCreateWithAttributes(attr); // TODO release attr? cfdesc = matchTraits(cfdesc, desc->Weight, desc->Italic, desc->Stretch); +/*TODO attr = extractAttributes(cfdesc); CFRelease(cfdesc); - // and finally add the other attributes - if (desc->SmallCaps) - addFontSmallCapsAttr(attr); - // and NOW create the final descriptor cfdesc = CTFontDescriptorCreateWithAttributes(attr); // TODO release attr? - +*/ // specify the initial size again just to be safe font->f = CTFontCreateWithFontDescriptor(cfdesc, desc->Size, NULL); // TODO release cfdesc? diff --git a/ui.h b/ui.h index 676e732a..66aaf2bd 100644 --- a/ui.h +++ b/ui.h @@ -496,7 +496,6 @@ struct uiDrawTextFontDescriptor { double Size; uiDrawTextWeight Weight; uiDrawTextItalic Italic; - int SmallCaps; uiDrawTextStretch Stretch; }; diff --git a/unix/draw.c b/unix/draw.c index 6f1c7df8..9a56c14e 100644 --- a/unix/draw.c +++ b/unix/draw.c @@ -529,7 +529,7 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc) { uiDrawTextFont *font; PangoFontDescription *pdesc; - PangoVariant variant; +//TODO PangoVariant variant; PangoContext *context; font = uiNew(uiDrawTextFont); @@ -543,10 +543,13 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc) pangoWeights[desc->Weight]); pango_font_description_set_style(pdesc, pangoItalics[desc->Italic]); +#if 0 +TODO variant = PANGO_VARIANT_NORMAL; if (desc->SmallCaps) variant = PANGO_VARIANT_SMALL_CAPS; pango_font_description_set_variant(pdesc, variant); +#endif pango_font_description_set_stretch(pdesc, pangoStretches[desc->Stretch]); diff --git a/windows/drawtext.cpp b/windows/drawtext.cpp index 493e0fad..244c5995 100644 --- a/windows/drawtext.cpp +++ b/windows/drawtext.cpp @@ -172,8 +172,6 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc) if (!found) complain("invalid initial stretch %d passed to uiDrawLoadClosestFont()", desc->Stretch); - // TODO small caps - hr = family->GetFirstMatchingFont(weight, stretch, italic, @@ -321,7 +319,6 @@ uiDrawTextLayout *uiDrawNewTextLayout(const char *text, uiDrawTextFont *defaultF &(layout->format)); if (hr != S_OK) logHRESULT("error creating IDWriteTextFormat in uiDrawNewTextLayout()", hr); - // TODO small caps layout->bytesToCharacters = toUTF16Offsets(text, &wtext, &wlen); hr = dwfactory->CreateTextLayout(wtext, wlen,