- Default font is now DejaVu (copyright in About box) - Fall back on Monaco if the default font is not in the app bundle - The default font is activated locally for each process (so that it is only available within MacVim)

git-svn-id: http://macvim.googlecode.com/svn/trunk@270 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
Bjorn Winckler
2007-09-23 13:27:51 +00:00
parent bda8171879
commit 891c4e6bf3
10 changed files with 98 additions and 58 deletions
+3 -1
View File
@@ -24,4 +24,6 @@ Toolbar icons borrowed from the {\field{\*\fldinst{HYPERLINK "http://www.everald
\
Vim icons made by {\field{\*\fldinst{HYPERLINK "http://www.cs.princeton.edu/~mtwebb/vim_icon/vim_icons.html"}}{\fldrslt Matthew Webb}}.\
\
The Bitstream Vera\'aa font is \'a9 2003 Bitstream, Inc.}
DejaVu is the default font in MacVim.\
\
The Bitstream Vera\'aa font is \'a9 2003 by Bitstream, Inc. The Arev font is \'a9 2006 by Tavmjong Bah. The DejaVu changes to these fonts are in the public domain.}
+3 -2
View File
@@ -16,8 +16,9 @@
@interface MMAppController : NSObject <MMAppProtocol> {
NSMutableArray *vimControllers;
NSString *openSelectionString;
NSMutableArray *vimControllers;
NSString *openSelectionString;
ATSFontContainerRef fontContainerRef;
}
- (void)removeVimController:(id)controller;
+9 -26
View File
@@ -34,7 +34,6 @@ static NSTimeInterval MMTerminateTimeout = 3;
@interface MMAppController (Private)
- (MMVimController *)keyVimController;
- (MMVimController *)topmostVimController;
+ (void)loadFonts;
@end
@interface NSMenu (MMExtras)
@@ -68,13 +67,13 @@ static NSTimeInterval MMTerminateTimeout = 3;
NSArray *types = [NSArray arrayWithObject:NSStringPboardType];
[NSApp registerServicesMenuSendTypes:types returnTypes:types];
[self loadFonts];
}
- (id)init
{
if ((self = [super init])) {
fontContainerRef = loadFonts();
vimControllers = [NSMutableArray new];
// NOTE! If the name of the connection changes here it must also be
@@ -289,7 +288,13 @@ static NSTimeInterval MMTerminateTimeout = 3;
}
}
// NOTE! Is this a correct way of releasing the MMAppController?
if (fontContainerRef) {
ATSFontDeactivate(fontContainerRef, NULL, kATSOptionFlagsDefault);
fontContainerRef = 0;
}
// TODO: Is this a correct way of releasing the MMAppController?
// (It doesn't seem like dealloc is ever called.)
[NSApp setDelegate:nil];
[self autorelease];
}
@@ -548,28 +553,6 @@ static NSTimeInterval MMTerminateTimeout = 3;
return nil;
}
+ (void)loadFonts
{
// This loads all fonts from the Resources folder.
// (Code taken from cocoadev.com)
NSString *fontsFolder;
if (fontsFolder = [[NSBundle mainBundle] resourcePath]) {
NSURL *fontsURL;
if (fontsURL = [NSURL fileURLWithPath:fontsFolder]) {
FSRef fsRef;
FSSpec fsSpec;
CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
NULL) == noErr) {
ATSFontActivateFromFileSpecification(&fsSpec,
kATSFontContextGlobal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, NULL);
}
}
}
}
@end
+1
View File
@@ -51,6 +51,7 @@
NSMutableDictionary *clientProxyDict;
NSMutableDictionary *serverReplyDict;
NSString *alternateServerName;
ATSFontContainerRef fontContainerRef;
}
+ (MMBackend *)sharedInstance;
+19 -3
View File
@@ -21,9 +21,8 @@ static float MMFlushTimeoutInterval = 0.1f;
static unsigned MMServerMax = 1000;
//static NSTimeInterval MMEvaluateExpressionTimeout = 3;
// NOTE: The Bitstream Vera font is bundled with the application and loaded
// during initialization of MMAppController.
static NSString *MMDefaultFontName = @"Bitstream Vera Sans Mono";
// NOTE: The default font is bundled with the application.
static NSString *MMDefaultFontName = @"DejaVu Sans Mono";
static float MMDefaultFontSize = 12.0f;
// TODO: Move to separate file.
@@ -78,6 +77,8 @@ enum {
- (id)init
{
if ((self = [super init])) {
fontContainerRef = loadFonts();
queue = [[NSMutableArray alloc] init];
#if MM_USE_INPUT_QUEUE
inputQueue = [[NSMutableArray alloc] init];
@@ -413,6 +414,12 @@ enum {
//NSLog(@"%@ %s", [self className], _cmd);
[[NSNotificationCenter defaultCenter] removeObserver:self];
[connection invalidate];
if (fontContainerRef) {
ATSFontDeactivate(fontContainerRef, NULL, kATSOptionFlagsDefault);
fontContainerRef = 0;
}
}
- (void)selectTab:(int)index
@@ -800,6 +807,15 @@ enum {
}
NSFont *font = [NSFont fontWithName:fontName size:size];
if (!font && MMDefaultFontName == fontName) {
// If for some reason the MacVim default font is not in the app
// bundle, then fall back on the system default font.
size = 0;
font = [NSFont userFixedPitchFontOfSize:size];
fontName = [font displayName];
}
if (font) {
//NSLog(@"Setting font '%@' of size %.2f", fontName, size);
int len = [fontName
+5
View File
@@ -208,4 +208,9 @@ extern NSString *MMOpenFilesInTabsKey;
// Loads all fonts in the Resouces folder of the app bundle and returns a font
// container reference (which should be used to deactivate the loaded fonts).
ATSFontContainerRef loadFonts();
// vim: set ft=objc:
+34
View File
@@ -81,3 +81,37 @@ NSString *MMBaselineOffsetKey = @"MMBaselineOffset";
NSString *MMTranslateCtrlClickKey = @"MMTranslateCtrlClick";
NSString *MMTopLeftPointKey = @"MMTopLeftPoint";
NSString *MMOpenFilesInTabsKey = @"MMOpenFilesInTabs";
ATSFontContainerRef
loadFonts()
{
// This loads all fonts from the Resources folder. The fonts are only
// available to the process which loaded them, so loading has to be done
// once for MacVim and an additional time for each Vim process. The
// returned container ref should be used to deactiave the font.
//
// (Code taken from cocoadev.com)
ATSFontContainerRef fontContainerRef = 0;
NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
if (fontsFolder) {
NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
if (fontsURL) {
FSRef fsRef;
FSSpec fsSpec;
CFURLGetFSRef((CFURLRef)fontsURL, &fsRef);
if (FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec,
NULL) == noErr) {
ATSFontActivateFromFileSpecification(&fsSpec,
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
kATSOptionFlagsDefault, &fontContainerRef);
}
}
}
return fontContainerRef;
}
+16 -16
View File
@@ -15,6 +15,10 @@
1D1474B00C5678370038FA2B /* MMTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D1474AE0C5678370038FA2B /* MMTextView.m */; };
1D1474B60C56796D0038FA2B /* MMVimController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D1474B40C56796D0038FA2B /* MMVimController.m */; };
1D1474BC0C567A910038FA2B /* MMWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D1474BA0C567A910038FA2B /* MMWindowController.m */; };
1D3D19110CA690FF0004A0A5 /* DejaVuSansMono-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1D3D190D0CA690FF0004A0A5 /* DejaVuSansMono-Bold.ttf */; };
1D3D19120CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1D3D190E0CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf */; };
1D3D19130CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1D3D190F0CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf */; };
1D3D19140CA690FF0004A0A5 /* DejaVuSansMono.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1D3D19100CA690FF0004A0A5 /* DejaVuSansMono.ttf */; };
1D493D580C5247BF00AB718C /* Vim in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1D493D570C5247BF00AB718C /* Vim */; };
1D493DBA0C52534300AB718C /* PSMTabBarControl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1D493DB90C52533B00AB718C /* PSMTabBarControl.framework */; };
1D71ACB40BC702AB002F2B60 /* doc-bm-c.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1D71ACA90BC702AB002F2B60 /* doc-bm-c.icns */; };
@@ -35,10 +39,6 @@
1DD704310BA9F9C2008679E9 /* SpecialKeys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1DD704300BA9F9C2008679E9 /* SpecialKeys.plist */; };
1DD9F5E50C85D60500E8D5A5 /* SystemColors.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */; };
1DDBEB6D0C7434150036EEDD /* EmptyWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDBEB6B0C7434150036EEDD /* EmptyWindow.nib */; };
1DE5F2520CA5B0B8005A40E4 /* VeraMoBd.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1DE5F24E0CA5B0B8005A40E4 /* VeraMoBd.ttf */; };
1DE5F2530CA5B0B8005A40E4 /* VeraMoBI.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1DE5F24F0CA5B0B8005A40E4 /* VeraMoBI.ttf */; };
1DE5F2540CA5B0B8005A40E4 /* VeraMoIt.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1DE5F2500CA5B0B8005A40E4 /* VeraMoIt.ttf */; };
1DE5F2550CA5B0B8005A40E4 /* VeraMono.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1DE5F2510CA5B0B8005A40E4 /* VeraMono.ttf */; };
1DE608B40C587FDA0055263D /* runtime in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1DE602470C587FD10055263D /* runtime */; };
1DE8CC620C5E2AAD003F56E3 /* Actions.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1DE8CC610C5E2AAD003F56E3 /* Actions.plist */; };
1DED78600C6DE43D0079945F /* vimrc in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1DED785F0C6DE43D0079945F /* vimrc */; };
@@ -141,6 +141,10 @@
1D1474B40C56796D0038FA2B /* MMVimController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MMVimController.m; sourceTree = "<group>"; };
1D1474B90C567A910038FA2B /* MMWindowController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MMWindowController.h; sourceTree = "<group>"; };
1D1474BA0C567A910038FA2B /* MMWindowController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MMWindowController.m; sourceTree = "<group>"; };
1D3D190D0CA690FF0004A0A5 /* DejaVuSansMono-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "DejaVuSansMono-Bold.ttf"; path = "dejavu-ttf-2.20/DejaVuSansMono-Bold.ttf"; sourceTree = "<group>"; };
1D3D190E0CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "DejaVuSansMono-BoldOblique.ttf"; path = "dejavu-ttf-2.20/DejaVuSansMono-BoldOblique.ttf"; sourceTree = "<group>"; };
1D3D190F0CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "DejaVuSansMono-Oblique.ttf"; path = "dejavu-ttf-2.20/DejaVuSansMono-Oblique.ttf"; sourceTree = "<group>"; };
1D3D19100CA690FF0004A0A5 /* DejaVuSansMono.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = DejaVuSansMono.ttf; path = "dejavu-ttf-2.20/DejaVuSansMono.ttf"; sourceTree = "<group>"; };
1D493D570C5247BF00AB718C /* Vim */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = Vim; path = ../Vim; sourceTree = SOURCE_ROOT; };
1D493DB30C52533B00AB718C /* PSMTabBarControl.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PSMTabBarControl.xcodeproj; path = PSMTabBarControl/PSMTabBarControl.xcodeproj; sourceTree = "<group>"; };
1D71ACA90BC702AB002F2B60 /* doc-bm-c.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "doc-bm-c.icns"; sourceTree = "<group>"; };
@@ -162,10 +166,6 @@
1DD704300BA9F9C2008679E9 /* SpecialKeys.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = SpecialKeys.plist; sourceTree = "<group>"; };
1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = SystemColors.plist; sourceTree = "<group>"; };
1DDBEB6C0C7434150036EEDD /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/EmptyWindow.nib; sourceTree = "<group>"; };
1DE5F24E0CA5B0B8005A40E4 /* VeraMoBd.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = VeraMoBd.ttf; path = "ttf-bitstream-vera-1.10/VeraMoBd.ttf"; sourceTree = "<group>"; };
1DE5F24F0CA5B0B8005A40E4 /* VeraMoBI.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = VeraMoBI.ttf; path = "ttf-bitstream-vera-1.10/VeraMoBI.ttf"; sourceTree = "<group>"; };
1DE5F2500CA5B0B8005A40E4 /* VeraMoIt.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = VeraMoIt.ttf; path = "ttf-bitstream-vera-1.10/VeraMoIt.ttf"; sourceTree = "<group>"; };
1DE5F2510CA5B0B8005A40E4 /* VeraMono.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = VeraMono.ttf; path = "ttf-bitstream-vera-1.10/VeraMono.ttf"; sourceTree = "<group>"; };
1DE602470C587FD10055263D /* runtime */ = {isa = PBXFileReference; lastKnownFileType = folder; name = runtime; path = ../../runtime; sourceTree = SOURCE_ROOT; };
1DE8CC610C5E2AAD003F56E3 /* Actions.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Actions.plist; sourceTree = "<group>"; };
1DED785F0C6DE43D0079945F /* vimrc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = vimrc; sourceTree = "<group>"; };
@@ -352,10 +352,10 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
1DE5F24E0CA5B0B8005A40E4 /* VeraMoBd.ttf */,
1DE5F24F0CA5B0B8005A40E4 /* VeraMoBI.ttf */,
1DE5F2500CA5B0B8005A40E4 /* VeraMoIt.ttf */,
1DE5F2510CA5B0B8005A40E4 /* VeraMono.ttf */,
1D3D190D0CA690FF0004A0A5 /* DejaVuSansMono-Bold.ttf */,
1D3D190E0CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf */,
1D3D190F0CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf */,
1D3D19100CA690FF0004A0A5 /* DejaVuSansMono.ttf */,
1DD9F5E40C85D60500E8D5A5 /* SystemColors.plist */,
1DE8CC610C5E2AAD003F56E3 /* Actions.plist */,
1DD04DEB0C529C5E006CDC2B /* Credits.rtf */,
@@ -483,10 +483,10 @@
1DE8CC620C5E2AAD003F56E3 /* Actions.plist in Resources */,
1DDBEB6D0C7434150036EEDD /* EmptyWindow.nib in Resources */,
1DD9F5E50C85D60500E8D5A5 /* SystemColors.plist in Resources */,
1DE5F2520CA5B0B8005A40E4 /* VeraMoBd.ttf in Resources */,
1DE5F2530CA5B0B8005A40E4 /* VeraMoBI.ttf in Resources */,
1DE5F2540CA5B0B8005A40E4 /* VeraMoIt.ttf in Resources */,
1DE5F2550CA5B0B8005A40E4 /* VeraMono.ttf in Resources */,
1D3D19110CA690FF0004A0A5 /* DejaVuSansMono-Bold.ttf in Resources */,
1D3D19120CA690FF0004A0A5 /* DejaVuSansMono-BoldOblique.ttf in Resources */,
1D3D19130CA690FF0004A0A5 /* DejaVuSansMono-Oblique.ttf in Resources */,
1D3D19140CA690FF0004A0A5 /* DejaVuSansMono.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+6 -8
View File
@@ -368,9 +368,9 @@
</array>
<key>TableOfContents</key>
<array>
<string>1D50F01D0CA5B246007DB9E5</string>
<string>1DD15C5B0CA69E1F00C745CE</string>
<string>1CE0B1FE06471DED0097A5F4</string>
<string>1D50F01E0CA5B246007DB9E5</string>
<string>1DD15C5C0CA69E1F00C745CE</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@@ -504,8 +504,8 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>1C0AD2B3069F1EA900FABCE6</string>
<string>1D16B9EF0BA33E3800A69B33</string>
<string>1C0AD2B3069F1EA900FABCE6</string>
<string>/Users/winckler/Projects/vim7/src/MacVim/MacVim.xcodeproj</string>
</array>
<key>WindowString</key>
@@ -547,8 +547,6 @@
<string>194pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@@ -588,7 +586,7 @@
<key>TableOfContents</key>
<array>
<string>1D16B9EF0BA33E3800A69B33</string>
<string>1D50F01F0CA5B246007DB9E5</string>
<string>1DD15C5D0CA69E1F00C745CE</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
@@ -960,9 +958,9 @@
<key>TableOfContents</key>
<array>
<string>1C0AD2B3069F1EA900FABCE6</string>
<string>1D50F0200CA5B246007DB9E5</string>
<string>1DD15C570CA69E1700C745CE</string>
<string>1CD0528B0623707200166675</string>
<string>1D50F0210CA5B246007DB9E5</string>
<string>1DD15C580CA69E1700C745CE</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.run</string>
+2 -2
View File
@@ -438,8 +438,8 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
PBXPerProjectTemplateStateSaveDate = 212185620;
PBXWorkspaceStateSaveDate = 212185620;
PBXPerProjectTemplateStateSaveDate = 212246019;
PBXWorkspaceStateSaveDate = 212246019;
};
sourceControlManager = 1D16B9DD0BA33BB000A69B33 /* Source Control */;
userBuildSettings = {