Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix missing fonts by falling back to Menlo or the system font #2

Merged
merged 1 commit into from

3 participants

@danielctull

Use Menlo if the user doesn't have Inconsolata installed. Use the system font if Menlo is not found.

@aaronvegh
Owner

I haven't had a chance to look at your code, but do you realize that Inconsolata is bundled with the application? It shouldn't matter whether it's installed on your system (in fact, it likely isn't).

@chwalters

I concur with Daniel - it doesn't work without changing the default font to something other than Inconsolata (for me). I tried something similar to Daniel - just falling back to systemFontOfSize: and I was able to use the app... Just my $0.02

@danielctull

Ah, I didn't see that, but for me it is not getting used.

@aaronvegh aaronvegh merged commit 05c1bab into from
@aaronvegh
Owner

I can't explain the fact that Inconsolata isn't working for you guys, but the code you've added looks like a safe route to take. I've merged it in. Thanks so much for your time with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 4, 2013
  1. @danielctull
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.