Filled in darwin/opentype.m.
This commit is contained in:
parent
39cec570d9
commit
72f5b680f2
|
@ -31,6 +31,7 @@ list(APPEND _LIBUI_SOURCES
|
||||||
darwin/map.m
|
darwin/map.m
|
||||||
darwin/menu.m
|
darwin/menu.m
|
||||||
darwin/multilineentry.m
|
darwin/multilineentry.m
|
||||||
|
darwin/opentype.m
|
||||||
darwin/progressbar.m
|
darwin/progressbar.m
|
||||||
darwin/radiobuttons.m
|
darwin/radiobuttons.m
|
||||||
darwin/scrollview.m
|
darwin/scrollview.m
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// 11 may 2017
|
// 11 may 2017
|
||||||
#include "uipriv_windows.hpp"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
struct uiOpenTypeFeatures {
|
struct uiOpenTypeFeatures {
|
||||||
xxxx;
|
NSMutableDictionary *tags;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiOpenTypeFeatures *uiNewOpenTypeFeatures(void)
|
uiOpenTypeFeatures *uiNewOpenTypeFeatures(void)
|
||||||
|
@ -10,13 +10,13 @@ uiOpenTypeFeatures *uiNewOpenTypeFeatures(void)
|
||||||
uiOpenTypeFeatures *otf;
|
uiOpenTypeFeatures *otf;
|
||||||
|
|
||||||
otf = uiNew(uiOpenTypeFeatures);
|
otf = uiNew(uiOpenTypeFeatures);
|
||||||
xxxx;
|
otf->tags = [NSMutableDictionary new];
|
||||||
return otf;
|
return otf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiFreeOpenTypeFeatures(uiOpenTypeFeatures *otf)
|
void uiFreeOpenTypeFeatures(uiOpenTypeFeatures *otf)
|
||||||
{
|
{
|
||||||
xxxxxx;
|
[otf->tags release];
|
||||||
uiFree(otf);
|
uiFree(otf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,28 +25,74 @@ uiOpenTypeFeatures *uiOpenTypeFeaturesClone(uiOpenTypeFeatures *otf)
|
||||||
uiOpenTypeFeatures *out;
|
uiOpenTypeFeatures *out;
|
||||||
|
|
||||||
out = uiNew(uiOpenTypeFeatures);
|
out = uiNew(uiOpenTypeFeatures);
|
||||||
xxxxxx;
|
out->tags = [otf->tags mutableCopy];
|
||||||
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?...
|
||||||
|
#define mkMapObject(tag) [NSNumber numberWithUnsignedLongLong:((unsigned long long) tag)]
|
||||||
|
#define mapObjectValue(num) ((uint32_t) [num unsignedLongLongValue])
|
||||||
|
|
||||||
void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value)
|
void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value)
|
||||||
{
|
{
|
||||||
|
NSNumber *tn, *vn;
|
||||||
|
|
||||||
|
tn = mkMapObject(mkTag(a, b, c, d));
|
||||||
|
vn = mkMapObject(value);
|
||||||
|
[otf->tags setObject:vn forKey:tn];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d)
|
void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d)
|
||||||
{
|
{
|
||||||
|
NSNumber *tn;
|
||||||
|
|
||||||
|
tn = mkMapObject(mkTag(a, b, c, d));
|
||||||
|
[otf->tags removeObjectForKey:tn];
|
||||||
}
|
}
|
||||||
|
|
||||||
int uiOpenTypeFeaturesGet(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t *value)
|
int uiOpenTypeFeaturesGet(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t *value)
|
||||||
{
|
{
|
||||||
|
NSNumber *tn, *vn;
|
||||||
|
|
||||||
|
tn = mkMapObject(mkTag(a, b, c, d));
|
||||||
|
vn = (NSNumber *) [otf->tags objectForKey:tn];
|
||||||
|
if (vn == nil)
|
||||||
|
return 0;
|
||||||
|
*value = mapObjectValue(vn);
|
||||||
|
// TODO release vn?
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiOpenTypeFeaturesForEach(uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data)
|
void uiOpenTypeFeaturesForEach(uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data)
|
||||||
{
|
{
|
||||||
|
[otf->tags enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
|
||||||
|
NSNumber *tn = (NSNumber *) key;
|
||||||
|
NSNumber *vn = (NSNumber *) value;
|
||||||
|
uint32_t tag;
|
||||||
|
uint8_t a, b, c, d;
|
||||||
|
|
||||||
|
tag = mapObjectValue(tn);
|
||||||
|
a = (uint8_t) ((tag >> 24) & 0xFF);
|
||||||
|
b = (uint8_t) ((tag >> 16) & 0xFF);
|
||||||
|
c = (uint8_t) ((tag >> 8) & 0xFF);
|
||||||
|
d = (uint8_t) (tag & 0xFF);
|
||||||
|
// TODO handle return value
|
||||||
|
(*f)((char) a, (char) b, (char) c, (char) d,
|
||||||
|
mapObjectValue(vn), data);
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
int uiOpenTypeFeaturesEqual(uiOpenTypeFeatures *a, uiOpenTypeFeatures *b)
|
int uiOpenTypeFeaturesEqual(uiOpenTypeFeatures *a, uiOpenTypeFeatures *b)
|
||||||
{
|
{
|
||||||
|
return [a->tags isEqualToDictionary:b->tags];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO put the internal function to produce a backend object from one here
|
// actual conversion to a feature dictionary is handled in aat.m; see there for details
|
||||||
|
|
Loading…
Reference in New Issue