From 15ffab0e78283ccca6eaee9bfed3106d2a6b78b8 Mon Sep 17 00:00:00 2001 From: rpowelll Date: Tue, 3 Sep 2013 16:17:46 +1000 Subject: [PATCH] Fix rendering on iOS 7 devices This fixes #5 The issue ended up being that UIFont's fontWithName:size: method handles nil arguments differently on iOS 7. On iOS 6 passing nil for the name meant the method would return nil, here it returns Helvetica. As the size here is also nil, we ended up getting 0pt Helvetica. --- RPSyntaxHighlighter/RPSyntaxTheme.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RPSyntaxHighlighter/RPSyntaxTheme.m b/RPSyntaxHighlighter/RPSyntaxTheme.m index f635e91..509c7b1 100644 --- a/RPSyntaxHighlighter/RPSyntaxTheme.m +++ b/RPSyntaxHighlighter/RPSyntaxTheme.m @@ -39,7 +39,8 @@ - (NSDictionary *)attributesForScope:(NSString *)scope UIColor *foregroundColor = [UIColor colorWithHexString:self.styles[scope][@"color"]]; UIColor *backgroundColor = [UIColor colorWithHexString:self.styles[scope][@"background"]]; - UIFont *font = [UIFont fontWithName:self.styles[scope][@"font"] size:[self.styles[scope][@"fontSize"] floatValue]]; + NSString *fontName = self.styles[scope][@"font"]; + CGFloat fontSize = [self.styles[scope][@"fontSize"] floatValue]; if (foregroundColor) { attributes[NSForegroundColorAttributeName] = foregroundColor; @@ -49,8 +50,8 @@ - (NSDictionary *)attributesForScope:(NSString *)scope attributes[NSBackgroundColorAttributeName] = backgroundColor; } - if (font) { - attributes[NSFontAttributeName] = font; + if (fontName) { + attributes[NSFontAttributeName] = [UIFont fontWithName:fontName size:fontSize]; } return attributes;