Skip to content

Commit

Permalink
Fix rendering on iOS 7 devices
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhysforyou committed Sep 3, 2013
1 parent f00d36e commit 15ffab0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions RPSyntaxHighlighter/RPSyntaxTheme.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 15ffab0

Please sign in to comment.