From d7a34e64d0e70bbca9246db9710c434eafd795e1 Mon Sep 17 00:00:00 2001 From: eugene Date: Mon, 30 Dec 2013 20:39:34 -0500 Subject: [PATCH 1/2] =?UTF-8?q?adding=20saving=20colour=20as=20a=20diction?= =?UTF-8?q?ary=20with=20=E2=80=9CName=E2=80=9D=20-=20font=20name=20and=20?= =?UTF-8?q?=E2=80=9CSize=E2=80=9D=20-=20font=20size.=20It=20simplify=20con?= =?UTF-8?q?figuration=20file=20and=20make=20it=20easier=20to=20copy/paste?= =?UTF-8?q?=20colours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/VSTheme.m | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/Source/VSTheme.m b/Source/VSTheme.m index ca8056e..1e8eda1 100644 --- a/Source/VSTheme.m +++ b/Source/VSTheme.m @@ -145,23 +145,38 @@ - (UIFont *)fontForKey:(NSString *)key { if (cachedFont != nil) return cachedFont; - NSString *fontName = [self stringForKey:key]; - CGFloat fontSize = [self floatForKey:[key stringByAppendingString:@"Size"]]; - - if (fontSize < 1.0f) - fontSize = 15.0f; - - UIFont *font = nil; + NSString *fontName; + CGFloat fontSize = 1.0; + UIFont *font = nil; + if ([[self objectForKey:key] isKindOfClass:[NSDictionary class]]) { + NSDictionary *fontObject = (NSDictionary*)[self objectForKey:key]; + if ([fontObject valueForKey:@"Size"]) { + fontSize = [[fontObject valueForKey:@"Size"] floatValue]; + } + if ([fontObject valueForKey:@"Name"]) { + fontName = [fontObject valueForKey:@"Name"]; + } + }else{ + fontName = [self stringForKey:key]; + fontSize = [self floatForKey:[key stringByAppendingString:@"Size"]]; + } + + if (fontSize < 1.0f){ + fontSize = 15.0f; + } - if (stringIsEmpty(fontName)) - font = [UIFont systemFontOfSize:fontSize]; - else - font = [UIFont fontWithName:fontName size:fontSize]; - - if (font == nil) - font = [UIFont systemFontOfSize:fontSize]; + if (stringIsEmpty(fontName)){ + font = [UIFont systemFontOfSize:fontSize]; + } + else{ + font = [UIFont fontWithName:fontName size:fontSize]; + } + + if (font == nil){ + font = [UIFont systemFontOfSize:fontSize]; + } - [self.fontCache setObject:font forKey:key]; + [self.fontCache setObject:font forKey:key]; return font; } From eaff540c9e6847b401d2220bc8221494f63eb0ed Mon Sep 17 00:00:00 2001 From: eugene Date: Mon, 13 Jan 2014 17:42:12 -0500 Subject: [PATCH 2/2] added colour to font settings --- Source/VSTheme.m | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/VSTheme.m b/Source/VSTheme.m index 1e8eda1..0d7b954 100644 --- a/Source/VSTheme.m +++ b/Source/VSTheme.m @@ -116,8 +116,21 @@ - (UIColor *)colorForKey:(NSString *)key { if (cachedColor != nil) return cachedColor; - NSString *colorString = [self stringForKey:key]; - UIColor *color = colorWithHexString(colorString); + UIColor *color; + if ([[self objectForKey:key] isKindOfClass:[NSDictionary class]]) { + NSDictionary *fontObject = (NSDictionary*)[self objectForKey:key]; + if ([fontObject valueForKey:@"Color"]) { + NSString *colorString; + colorString = [fontObject valueForKey:@"Color"]; + color = colorWithHexString(colorString); + }else{ + color = [UIColor blackColor]; + } + }else{ + NSString *colorString = [self stringForKey:key]; + color = colorWithHexString(colorString); + } + if (color == nil) color = [UIColor blackColor];