Folded all CFNumber accesses into [self prepare] for error checking. This shouldn't make things *significantly* slower...
This commit is contained in:
parent
4e7fb5e264
commit
51f0e3dbe5
|
@ -78,6 +78,7 @@
|
||||||
- (BOOL)prepare
|
- (BOOL)prepare
|
||||||
{
|
{
|
||||||
CFNumberRef num;
|
CFNumberRef num;
|
||||||
|
Boolean success;
|
||||||
|
|
||||||
self->traits = NULL;
|
self->traits = NULL;
|
||||||
self->symbolic = 0;
|
self->symbolic = 0;
|
||||||
|
@ -87,12 +88,10 @@
|
||||||
self->styleName = NULL;
|
self->styleName = NULL;
|
||||||
self->didVariations = NO;
|
self->didVariations = NO;
|
||||||
self->variations = NULL;
|
self->variations = NULL;
|
||||||
self->didRegistrationScope = NO;
|
|
||||||
self->hasRegistrationScope = NO;
|
self->hasRegistrationScope = NO;
|
||||||
self->registrationScope = 0;
|
self->registrationScope = 0;
|
||||||
self->didPostScriptName = NO;
|
self->didPostScriptName = NO;
|
||||||
self->postScriptName = NULL;
|
self->postScriptName = NULL;
|
||||||
self->didFontFormat = NO;
|
|
||||||
self->fontFormat = 0;
|
self->fontFormat = 0;
|
||||||
self->didPreferredSubFamilyName = NO;
|
self->didPreferredSubFamilyName = NO;
|
||||||
self->preferredSubFamilyName = NULL;
|
self->preferredSubFamilyName = NULL;
|
||||||
|
@ -129,6 +128,24 @@
|
||||||
if (CFNumberGetValue(num, kCFNumberDoubleType, &(self->width)) == false)
|
if (CFNumberGetValue(num, kCFNumberDoubleType, &(self->width)) == false)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
|
// do these now for the sake of error checking
|
||||||
|
num = (CFNumberRef) CTFontDescriptorCopyAttribute(desc, kCTFontRegistrationScopeAttribute);
|
||||||
|
self->hasRegistrationScope = num != NULL;
|
||||||
|
if (self->hasRegistrationScope) {
|
||||||
|
success = CFNumberGetValue(num, kCFNumberSInt32Type, &(self->registrationScope));
|
||||||
|
CFRelease(num);
|
||||||
|
if (success == false)
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
num = (CFNumberRef) CTFontDescriptorCopyAttribute(self->desc, kCTFontFormatAttribute);
|
||||||
|
if (num == NULL)
|
||||||
|
return NO;
|
||||||
|
success = CFNumberGetValue(num, kCFNumberSInt32Type, &(self->fontFormat));
|
||||||
|
CFRelease(num);
|
||||||
|
if (success == false)
|
||||||
|
return NO;
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,25 +193,11 @@
|
||||||
|
|
||||||
- (BOOL)hasRegistrationScope
|
- (BOOL)hasRegistrationScope
|
||||||
{
|
{
|
||||||
if (!self->didRegistrationScope) {
|
|
||||||
CFNumberRef num;
|
|
||||||
|
|
||||||
self->didRegistrationScope = YES;
|
|
||||||
num = (CFNumberRef) CTFontDescriptorCopyAttribute(desc, kCTFontRegistrationScopeAttribute);
|
|
||||||
self->hasRegistrationScope = num != NULL;
|
|
||||||
if (self->hasRegistrationScope) {
|
|
||||||
if (CFNumberGetValue(num, kCFNumberSInt32Type, &(self->registrationScope)) == false) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
CFRelease(num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return self->hasRegistrationScope;
|
return self->hasRegistrationScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CTFontManagerScope)registrationScope
|
- (CTFontManagerScope)registrationScope
|
||||||
{
|
{
|
||||||
[self hasRegistrationScope];
|
|
||||||
return self->registrationScope;
|
return self->registrationScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,19 +219,6 @@
|
||||||
|
|
||||||
- (CTFontFormat)fontFormat
|
- (CTFontFormat)fontFormat
|
||||||
{
|
{
|
||||||
if (!self->didFontFormat) {
|
|
||||||
CFNumberRef num;
|
|
||||||
|
|
||||||
self->didFontFormat = YES;
|
|
||||||
num = (CFNumberRef) CTFontDescriptorCopyAttribute(self->desc, kCTFontFormatAttribute);
|
|
||||||
if (num == NULL) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
if (CFNumberGetValue(num, kCFNumberSInt32Type, &(self->fontFormat)) == false) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
CFRelease(num);
|
|
||||||
}
|
|
||||||
return self->fontFormat;
|
return self->fontFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,10 @@
|
||||||
CFStringRef styleName;
|
CFStringRef styleName;
|
||||||
BOOL didVariations;
|
BOOL didVariations;
|
||||||
CFDictionaryRef variations;
|
CFDictionaryRef variations;
|
||||||
BOOL didRegistrationScope;
|
|
||||||
BOOL hasRegistrationScope;
|
BOOL hasRegistrationScope;
|
||||||
CTFontManagerScope registrationScope;
|
CTFontManagerScope registrationScope;
|
||||||
BOOL didPostScriptName;
|
BOOL didPostScriptName;
|
||||||
CFStringRef postScriptName;
|
CFStringRef postScriptName;
|
||||||
BOOL didFontFormat;
|
|
||||||
CTFontFormat fontFormat;
|
CTFontFormat fontFormat;
|
||||||
BOOL didPreferredSubFamilyName;
|
BOOL didPreferredSubFamilyName;
|
||||||
CFStringRef preferredSubFamilyName;
|
CFStringRef preferredSubFamilyName;
|
||||||
|
|
Loading…
Reference in New Issue