Reputation: 4731
I am using the external fonts capability for my application. As external fonts are not supported in 3.1 version I would like to define the font name in relation with the IOS that is executing the program. I have defined MY_FONT_NAME variable in a Constants.h file like this:
//#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
#ifdef __IPHONE_3_2
#define MY_FONT_NAME @"ExternalFontName"
#else
#define MY_FONT_NAME @"AppleGothic"
#endif
I have tried both, the first commented line and the second, without success but it always get the value of "externalFontName", even executing on a 3.1 device... and so, when I set the font in a label I get the error
'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: font != nil'
Anyone know what is the problem?? Thanks in advance
Upvotes: 3
Views: 240
Reputation: 767
Eva Madrazo is close. What you actually need is:
if ([[[UIDevice currentDevice] systemVersion]doubleValue] >= 3.2) {
because a string compare doesn't cut it.
Upvotes: 1
Reputation: 170317
Perhaps a better approach would be to use UIFont's +fontWithName:size:
to check the availability of the font, and / or examining the returned arrays from +familyNames
and
+fontNamesForFamilyName:
.
For example, I believe there are some fonts that are only present on the iPad running 3.2, even versus an iPhone running 4.0.
Upvotes: 1
Reputation: 4731
ok, I know, the macros are executed on compilation time, that is the problem.. so stupid! sorry :)
So I think I should use something like:
if ([[UIDevice currentDevice] systemVersion] >= @"3.2") {
return @"myExternalFontName";
} else {
return @"AppleGothic";
}
Or does anyone has a better solution? Thanks
Upvotes: 2