And tied everyhting together, sort of.

This commit is contained in:
Pietro Gagliardi 2017-05-19 15:48:15 -04:00
parent 1a2dd1f16b
commit b7d34bf4f5
4 changed files with 29 additions and 15 deletions

View File

@ -18,7 +18,7 @@ static void boolspec(uint32_t value, uint16_t type, uint16_t ifTrue, uint16_t if
pcall(p, type, ifFalse); pcall(p, type, ifFalse);
} }
void openTypeToAAT(char a, char b, char c, char d, uint32_t value, void *data) static int foreach(char a, char b, char c, char d, uint32_t value, void *data)
{ {
struct openTypeAATParams *p = (struct openTypeAATParams *) data; struct openTypeAATParams *p = (struct openTypeAATParams *) data;
@ -394,4 +394,15 @@ void openTypeToAAT(char a, char b, char c, char d, uint32_t value, void *data)
pcall(p, kUpperCaseType, kUpperCasePetiteCapsSelector); pcall(p, kUpperCaseType, kUpperCasePetiteCapsSelector);
break; break;
} }
// TODO handle this properly
return 0;
}
void openTypeToAAT(uiOpenTypeFeatures *otf, void (*doAAT)(uint16_t type, uint16_t selector, void *data), void *data)
{
struct openTypeAATParams p;
p.doAAT = doAAT;
p.data = data;
uiOpenTypeFeaturesForEach(otf, foreach, &p);
} }

View File

@ -155,6 +155,7 @@ static void doAAT(uint16_t type, uint16_t selector, void *data)
fp->nFeatures++; fp->nFeatures++;
if (fp->nFeatures == maxFeatures) { if (fp->nFeatures == maxFeatures) {
// TODO // TODO
// TODO move this check to the top like in the drawtext example? and all the other instances of this?
} }
}); });
} }
@ -257,14 +258,15 @@ static int processAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t
if (spec->Value == uiDrawUnderlineColorCustom) if (spec->Value == uiDrawUnderlineColorCustom)
CFRelease(color); CFRelease(color);
break; break;
default: case uiAttributeFeatures:
// handle typographic features
ap.p = p; ap.p = p;
ap.start = start; ap.start = start;
ap.end = end; ap.end = end;
// TODO check if unhandled and complain openTypeToAAT((uiOpenTypeFeatures *) (spec->Value), doAAT, &ap);
specToAAT(spec, doAAT, &ap);
break; break;
default:
// TODO complain
;
} }
return 0; return 0;
} }

View File

@ -29,14 +29,6 @@ uiOpenTypeFeatures *uiOpenTypeFeaturesClone(uiOpenTypeFeatures *otf)
return out; return out;
} }
// TODO provide to aat.m too; remove x8tox32() when doing so
#define x8to32(x) ((uint32_t) (((uint8_t) (x)) & 0xFF))
#define mkTag(a, b, c, d) \
((x8tox32(a) << 24) | \
(x8tox32(b) << 16) | \
(x8tox32(c) << 8) | \
x8tox32(d))
// why are there no NSNumber methods for stdint.h or the equivalent core foundation types?... // why are there no NSNumber methods for stdint.h or the equivalent core foundation types?...
#define mkMapObject(tag) [NSNumber numberWithUnsignedLongLong:((unsigned long long) tag)] #define mkMapObject(tag) [NSNumber numberWithUnsignedLongLong:((unsigned long long) tag)]
#define mapObjectValue(num) ((uint32_t) [num unsignedLongLongValue]) #define mapObjectValue(num) ((uint32_t) [num unsignedLongLongValue])

View File

@ -152,5 +152,14 @@ typedef void (^backgroundBlock)(uiDrawContext *c, uiDrawTextLayout *layout, doub
extern CFAttributedStringRef attrstrToCoreFoundation(uiDrawTextLayoutParams *p, NSArray **backgroundBlocks); extern CFAttributedStringRef attrstrToCoreFoundation(uiDrawTextLayoutParams *p, NSArray **backgroundBlocks);
// aat.m // aat.m
typedef void (*specToAATEnumFunc)(uint16_t type, uint16_t selector, void *data); extern void openTypeToAAT(uiOpenTypeFeatures *otf, void (*doAAT)(uint16_t type, uint16_t selector, void *data), void *data);
extern int specToAAT(uiAttributeSpec *spec, specToAATEnumFunc f, void *data);
// 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 x8to32(x) ((uint32_t) (((uint8_t) (x)) & 0xFF))
#define mkTag(a, b, c, d) \
((x8tox32(a) << 24) | \
(x8tox32(b) << 16) | \
(x8tox32(c) << 8) | \
x8tox32(d))