These days I am concentrated in improving my English skill; particularly in listening and writing. Actually now I'm under increasing pressure because the score of the result of my last TOEFL exam was bad rather than insufficient. So I decided not to code programs too much as my hobby, but to write English essays more and more. I have less time to do all things what I like than usual.
To write English essays more efficiently, I wish such editors:
- Beautiful rendering with proportional fonts
- Rich functionalities
When I mentioned about "rich functionalities" in the context of text editing, it stands for Vim. But unfortunately Vim doesn't support proportional fonts but supports only monospaced fonts. Monospaced fonts are beautiful in programming languages, but in natural English language, they aren't.
So I wrote a patch for supporting proportional fonts on MacVim.
Building MacVim with my patch
First of all, fetch the MacVim source and build plain Vim.
$ git clone git://repo.or.cz/MacVim.git MacVimUjihisa
$ cd MacVimUjihisa/src
$ ./configure --enable-gui=macvim
$ make
Create the following patch file on a.patch
:
diff --git a/src/MacVim/MMTextStorage.m b/src/MacVim/MMTextStorage.m
index 0d272b2..0327a8f 100644
--- a/src/MacVim/MMTextStorage.m
+++ b/src/MacVim/MMTextStorage.m
@@ -656,12 +656,8 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
cellSize.width = ceilf(em * cellWidthMultiplier);
float pointSize = [newFont pointSize];
- NSDictionary *dict = [NSDictionary
- dictionaryWithObject:[NSNumber numberWithFloat:cellSize.width]
- forKey:NSFontFixedAdvanceAttribute];
NSFontDescriptor *desc = [newFont fontDescriptor];
- desc = [desc fontDescriptorByAddingAttributes:dict];
font = [NSFont fontWithDescriptor:desc size:pointSize];
[font retain];
@@ -680,21 +676,18 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
boldFont = [[NSFontManager sharedFontManager]
convertFont:font toHaveTrait:NSBoldFontMask];
desc = [boldFont fontDescriptor];
- desc = [desc fontDescriptorByAddingAttributes:dict];
boldFont = [NSFont fontWithDescriptor:desc size:pointSize];
[boldFont retain];
italicFont = [[NSFontManager sharedFontManager]
convertFont:font toHaveTrait:NSItalicFontMask];
desc = [italicFont fontDescriptor];
- desc = [desc fontDescriptorByAddingAttributes:dict];
italicFont = [NSFont fontWithDescriptor:desc size:pointSize];
[italicFont retain];
boldItalicFont = [[NSFontManager sharedFontManager]
convertFont:italicFont toHaveTrait:NSBoldFontMask];
desc = [boldItalicFont fontDescriptor];
- desc = [desc fontDescriptorByAddingAttributes:dict];
boldItalicFont = [NSFont fontWithDescriptor:desc size:pointSize];
[boldItalicFont retain];
}
@@ -714,32 +707,25 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
float pointSize = [newFont pointSize];
NSFontDescriptor *desc = [newFont fontDescriptor];
- NSDictionary *dictWide = [NSDictionary
- dictionaryWithObject:[NSNumber numberWithFloat:2*cellSize.width]
- forKey:NSFontFixedAdvanceAttribute];
- desc = [desc fontDescriptorByAddingAttributes:dictWide];
fontWide = [NSFont fontWithDescriptor:desc size:pointSize];
[fontWide retain];
boldFontWide = [[NSFontManager sharedFontManager]
convertFont:fontWide toHaveTrait:NSBoldFontMask];
desc = [boldFontWide fontDescriptor];
- desc = [desc fontDescriptorByAddingAttributes:dictWide];
boldFontWide = [NSFont fontWithDescriptor:desc size:pointSize];
[boldFontWide retain];
italicFontWide = [[NSFontManager sharedFontManager]
convertFont:fontWide toHaveTrait:NSItalicFontMask];
desc = [italicFontWide fontDescriptor];
- desc = [desc fontDescriptorByAddingAttributes:dictWide];
italicFontWide = [NSFont fontWithDescriptor:desc size:pointSize];
[italicFontWide retain];
boldItalicFontWide = [[NSFontManager sharedFontManager]
convertFont:italicFontWide toHaveTrait:NSBoldFontMask];
desc = [boldItalicFontWide fontDescriptor];
- desc = [desc fontDescriptorByAddingAttributes:dictWide];
boldItalicFontWide = [NSFont fontWithDescriptor:desc size:pointSize];
[boldItalicFontWide retain];
}
Then apply it:
$ patch -p2 < a.patch
$ xcodebuild
Then run it:
$ open build/Release/MacVim.app
Then fix its font config.
Known Bugs
- In insert mode, the location of cursor is far from correct
location.
- Vertical split is broken.
Handling screenwidth. Now Vim wraps in a strange position.
Now I don't have time to fix the problems.
This comment has been removed by a blog administrator.
ReplyDelete