From 558153182fc2278dc377d2ee21cccea8257fd635 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Wed, 7 Jan 2009 14:19:27 +0100 Subject: [PATCH] New user default MMLoadDefaultFont When enabled the default font is loaded from within the app bundle each time MacVim is started (the default setting). Startup times are shorter if this is disabled. Note that if the default font has already been installed on the system then this may as well be disabled. --- runtime/doc/gui_mac.txt | 3 ++- src/MacVim/MMAppController.m | 6 +++++- src/MacVim/MMVimController.m | 8 ++++---- src/MacVim/Miscellaneous.h | 1 + src/MacVim/Miscellaneous.m | 1 + 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/runtime/doc/gui_mac.txt b/runtime/doc/gui_mac.txt index 2d450f20..d7b35535 100644 --- a/runtime/doc/gui_mac.txt +++ b/runtime/doc/gui_mac.txt @@ -1,4 +1,4 @@ -*gui_mac.txt* For Vim version 7.2. Last change: 2009 Jan 04 +*gui_mac.txt* For Vim version 7.2. Last change: 2009 Jan 07 VIM REFERENCE MANUAL by Bjorn Winckler @@ -260,6 +260,7 @@ Here is a list of relevant dictionary entries: KEY VALUE ~ MMCellWidthMultiplier width of a normal glyph in em units [float] MMDialogsTrackPwd open/save dialogs track the Vim pwd [bool] +MMLoadDefaultFont load font (disable for faster startup) [bool] MMLoginShellArgument login shell parameter [string] MMLoginShellCommand which shell to use to launch Vim [string] MMNoFontSubstitution disable automatic font substitution [bool] diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 2f53a884..8ccb82d8 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -190,6 +190,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [NSNumber numberWithBool:NO], MMVerticalSplitKey, [NSNumber numberWithInt:0], MMPreloadCacheSizeKey, [NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey, + [NSNumber numberWithBool:YES], MMLoadDefaultFontKey, nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dict]; @@ -1881,7 +1882,10 @@ fsEventCallback(ConstFSEventStreamRef streamRef, - (void)loadDefaultFont { - if (fontContainerRef) + // It is possible to set a user default to avoid loading the default font + // (this cuts down on startup time). + if (![[NSUserDefaults standardUserDefaults] boolForKey:MMLoadDefaultFontKey] + || fontContainerRef) return; // Load all fonts in the Resouces folder of the app bundle. diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index be3d28c8..8fc93e11 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -860,10 +860,10 @@ static BOOL isUnsafeMessage(int msgid); encoding:NSUTF8StringEncoding]; NSFont *font = [NSFont fontWithName:name size:size]; if (!font) { - // This should never happen, but if e.g. the default font was - // missing from the app bundle we might end up here. - NSLog(@"WARNING: Can't set font %@, using Cocoa default", name); - font = [NSFont userFixedPitchFontOfSize:0]; + // This should only happen if the default font was not loaded in + // which case we fall back on using the Cocoa default fixed width + // font. + font = [NSFont userFixedPitchFontOfSize:size]; } [windowController setFont:font]; diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index b92d9308..d19accd7 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -54,6 +54,7 @@ extern NSString *MMOpenLayoutKey; extern NSString *MMVerticalSplitKey; extern NSString *MMPreloadCacheSizeKey; extern NSString *MMLastWindowClosedBehaviorKey; +extern NSString *MMLoadDefaultFontKey; // Enum for MMUntitledWindowKey diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index a26259fc..4e071300 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -45,6 +45,7 @@ NSString *MMOpenLayoutKey = @"MMOpenLayout"; NSString *MMVerticalSplitKey = @"MMVerticalSplit"; NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize"; NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior"; +NSString *MMLoadDefaultFontKey = @"MMLoadDefaultFont"; -- 2.11.4.GIT