From f0216eb45dd490e3abd535cfbb5caffe404cdf70 Mon Sep 17 00:00:00 2001 From: phatmann Date: Wed, 8 Jan 2014 16:22:49 -0800 Subject: [PATCH] Add standard way to get font out of NUISettings. --- NUI/Core/NUISettings.h | 1 + NUI/Core/NUISettings.m | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/NUI/Core/NUISettings.h b/NUI/Core/NUISettings.h index 0fd3d4cb..42286a98 100644 --- a/NUI/Core/NUISettings.h +++ b/NUI/Core/NUISettings.h @@ -43,6 +43,7 @@ + (UIEdgeInsets)getEdgeInsets:(NSString*)property withClass:(NSString*)className; + (UITextBorderStyle)getBorderStyle:(NSString*)property withClass:(NSString*)className; + (UITableViewCellSeparatorStyle)getSeparatorStyle:(NSString*)property withClass:(NSString*)className; ++ (UIFont*)getFontWithClass:(NSString*)className; + (UIColor*)getColor:(NSString*)property withClass:(NSString*)className; + (UIColor*)getColorFromImage:(NSString*)property withClass:(NSString*)className; + (UIImage*)getImage:(NSString*)property withClass:(NSString*)className; diff --git a/NUI/Core/NUISettings.m b/NUI/Core/NUISettings.m index b4ca59ad..126f33c3 100644 --- a/NUI/Core/NUISettings.m +++ b/NUI/Core/NUISettings.m @@ -185,6 +185,32 @@ + (UITableViewCellSeparatorStyle)getSeparatorStyle:(NSString*)property withClass return [NUIConverter toSeparatorStyle:[self get:property withClass:className]]; } ++ (UIFont*)getFontWithClass:(NSString*)className +{ + NSString *propertyName; + CGFloat fontSize; + UIFont *font = nil; + + propertyName = @"font-size"; + + if ([self hasProperty:propertyName withClass:className]) { + fontSize = [self getFloat:@"font-size" withClass:className]; + } else { + fontSize = [UIFont systemFontSize]; + } + + propertyName = @"font-name"; + + if ([self hasProperty:propertyName withClass:className]) { + NSString *fontName = [self get:propertyName withClass:className]; + font = [UIFont fontWithName:fontName size:fontSize]; + } else { + font = [UIFont systemFontOfSize:fontSize]; + } + + return font; +} + + (UIColor*)getColor:(NSString*)property withClass:(NSString*)className { return [NUIConverter toColor:[self get:property withClass:className]];