From d8ad3300c90964961ddc7a1d915b8998c4ee15ce Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 4 Mar 2018 15:53:46 -0500 Subject: [PATCH] Migrated aat.m back. --- darwin/OLD_attrstr.h | 14 -------------- darwin/{OLD_aat.m => aat.m} | 14 ++++++++++++-- darwin/attrstr.h | 4 ++++ darwin/opentype.m | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) rename darwin/{OLD_aat.m => aat.m} (96%) diff --git a/darwin/OLD_attrstr.h b/darwin/OLD_attrstr.h index abe80cee..2a637b84 100644 --- a/darwin/OLD_attrstr.h +++ b/darwin/OLD_attrstr.h @@ -10,17 +10,3 @@ extern void initUnderlineColors(void); extern void uninitUnderlineColors(void); typedef void (^backgroundBlock)(uiDrawContext *c, uiDrawTextLayout *layout, double x, double y); extern CFAttributedStringRef attrstrToCoreFoundation(uiDrawTextLayoutParams *p, NSArray **backgroundBlocks); - -// aat.m -typedef void (^aatBlock)(uint16_t type, uint16_t selector); -extern void openTypeToAAT(char a, char b, char c, char d, uint32_t value, aatBlock f); - -// opentype.m -// TODO this is only used by opentype.m and aat.m; figure out some better way to handle this -// TODO remove x8tox32() -#define x8tox32(x) ((uint32_t) (((uint8_t) (x)) & 0xFF)) -#define mkTag(a, b, c, d) \ - ((x8tox32(a) << 24) | \ - (x8tox32(b) << 16) | \ - (x8tox32(c) << 8) | \ - x8tox32(d)) diff --git a/darwin/OLD_aat.m b/darwin/aat.m similarity index 96% rename from darwin/OLD_aat.m rename to darwin/aat.m index 0c3fd5fa..05f0b268 100644 --- a/darwin/OLD_aat.m +++ b/darwin/aat.m @@ -1,9 +1,10 @@ // 14 february 2017 #import "uipriv_darwin.h" +#import "attrstr.h" // TODO explain the purpose of this file -static void boolspec(uint32_t value, uint16_t type, uint16_t ifTrue, uint16_t ifFalse, aatBlock f) +static void boolspec(uint32_t value, uint16_t type, uint16_t ifTrue, uint16_t ifFalse, uiprivAATBlock f) { // TODO are values other than 1 accepted for true by OpenType itself? (same for the rest of the file) if (value != 0) { @@ -13,8 +14,17 @@ static void boolspec(uint32_t value, uint16_t type, uint16_t ifTrue, uint16_t if f(type, ifFalse); } +// TODO remove the need for this +// TODO remove x8tox32() +#define x8tox32(x) ((uint32_t) (((uint8_t) (x)) & 0xFF)) +#define mkTag(a, b, c, d) \ + ((x8tox32(a) << 24) | \ + (x8tox32(b) << 16) | \ + (x8tox32(c) << 8) | \ + x8tox32(d)) + // TODO double-check drawtext example to make sure all of these are used properly (I already screwed dlig up by putting clig twice instead) -void openTypeToAAT(char a, char b, char c, char d, uint32_t value, aatBlock f) +void uiprivOpenTypeToAAT(char a, char b, char c, char d, uint32_t value, uiprivAATBlock f) { switch (mkTag(a, b, c, d)) { case mkTag('l', 'i', 'g', 'a'): diff --git a/darwin/attrstr.h b/darwin/attrstr.h index 537243bb..74be3a37 100644 --- a/darwin/attrstr.h +++ b/darwin/attrstr.h @@ -3,3 +3,7 @@ // opentype.m extern CFArrayRef uiprivOpenTypeFeaturesToCTFeatures(const uiOpenTypeFeatures *otf); + +// aat.m +typedef void (^uiprivAATBlock)(uint16_t type, uint16_t selector); +extern void uiprivOpenTypeToAAT(char a, char b, char c, char d, uint32_t value, uiprivAATBlock f); diff --git a/darwin/opentype.m b/darwin/opentype.m index de4bb093..079197ed 100644 --- a/darwin/opentype.m +++ b/darwin/opentype.m @@ -53,7 +53,7 @@ static uiForEach otfArrayForEachAAT(const uiOpenTypeFeatures *otf, char a, char p.array = (CFMutableArrayRef) data; p.tagIsNumber = YES; - openTypeToAAT(a, b, c, d, value, ^(uint16_t type, uint16_t selector) { + uiprivOpenTypeToAAT(a, b, c, d, value, ^(uint16_t type, uint16_t selector) { p.tagKey = kCTFontFeatureTypeIdentifierKey; p.tagType = kCFNumberSInt16Type; p.tagValue = (const SInt16 *) (&type);