Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions runtime/doc/gui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1135,10 +1135,18 @@ That's all. XLFDs are not used. For Chinese this is reported to work well: >

MacVim *macvim-guifont*

For MacVim you can use something like this: >
:set guifont=Menlo:h10
Fonts with spaces are set like this: >
In MacVim, you can specify fonts by either the full PostScript name or the
family name (both can be found in the Font Book app), followed by an optional
font size (which defaults to `h11`). Font names can also be completed in the
cmdline using |complete-set-option|.

Basic example of setting the font to Menlo with default size: >
:set guifont=Menlo
To set a font by its family name which contains spaces: >
:set guifont=DejaVu\ Sans\ Mono:h13
When specifying family names with spaces, you can also use underscores
instead: >
:set guifont=DejaVu_Sans_Mono:h13
To use bold/italic fonts, use the fully specified PostScript name of the
font, like so: >
:set guifont=Menlo-Bold:h13
Expand Down
16 changes: 10 additions & 6 deletions src/MacVim/gui_macvim.m
Original file line number Diff line number Diff line change
Expand Up @@ -1196,12 +1196,6 @@
parseFailed = YES;
}

if (!parseFailed) {
// Replace underscores with spaces.
fontName = [[fontName componentsSeparatedByString:@"_"]
componentsJoinedByString:@" "];
}

const BOOL isSystemFont = [fontName hasPrefix:MMSystemFontAlias];
if (isSystemFont) {
if (fontName.length > MMSystemFontAlias.length) {
Expand All @@ -1228,6 +1222,16 @@
|| isSystemFont
|| [NSFont fontWithName:fontName size:size])
return [[NSString alloc] initWithFormat:@"%@:h%d", fontName, size];

// If font loading failed, try to replace underscores with spaces for
// user convenience. This really only works if the name is a family
// name because PostScript names should not have spaces.
if ([fontName rangeOfString:@"_"].location != NSNotFound) {
fontName = [fontName stringByReplacingOccurrencesOfString:@"_" withString:@" "];
if ([NSFont fontWithName:fontName size:size]) {
return [[NSString alloc] initWithFormat:@"%@:h%d", fontName, size];
}
}
}

return NOFONT;
Expand Down
Loading