Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fallback to Menlo (and then the system font) when the user doesn't ha…

…ve Inconsolata installed
  • Loading branch information...
commit 89be3338c9a4db8fd19a5346fe796bac65f942ad 1 parent 57bfcc6
@danielctull danielctull authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 NSRegexTester/INOAppDelegate.m
View
12 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
Please sign in to comment.
Something went wrong with that request. Please try again.