Permalink
Browse files

Merge pull request #2 from danielctull-forks/master

Fix missing fonts by falling back to Menlo or the system font
  • Loading branch information...
2 parents 57bfcc6 + 89be333 commit 05c1babaa7230a1fd391d58f9f93538f4d213a98 @aaronvegh committed Jan 4, 2013
Showing with 10 additions and 2 deletions.
  1. +10 −2 NSRegexTester/INOAppDelegate.m
@@ -13,7 +13,7 @@ @implementation INOAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self.regexOptions setFloatingPanel:YES];
- NSFont * defaultFont = [NSFont fontWithName:@"Inconsolata" size:14.0];
+ NSFont * defaultFont = [self defaultFont];
[self.testText setFont:defaultFont];
[self.matchText setFont:defaultFont];
[self.regexField setFont:defaultFont];
@@ -33,7 +33,8 @@ - (IBAction)testExpression:(id)sender
NSRange testRange = NSMakeRange(0, [[[self.testText textStorage] string] length]);
NSMutableAttributedString * resultString = [[NSMutableAttributedString alloc] initWithString:[[self.testText textStorage] string]];
- NSFont * defaultFont = [NSFont fontWithName:@"Inconsolata" size:14.0];
+ NSFont * defaultFont = [self defaultFont];
+
[resultString addAttribute:NSFontAttributeName value:defaultFont range:NSMakeRange(0, [[[self.testText textStorage] string] length])];
defaultFont = nil;
@@ -64,4 +65,11 @@ - (IBAction)showReference:(id)sender {
[self.referenceWindow makeKeyAndOrderFront:sender];
}
+- (NSFont *)defaultFont {
+ NSFont *defaultFont = [NSFont fontWithName:@"Inconsolata" size:14.0f];
+ if (!defaultFont) defaultFont = [NSFont fontWithName:@"Menlo" size:14.0f];
+ if (!defaultFont) defaultFont = [NSFont systemFontOfSize:14.0f];
+ return defaultFont;
+}
+
@end

0 comments on commit 05c1bab

Please sign in to comment.