File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -1135,10 +1135,18 @@ That's all. XLFDs are not used. For Chinese this is reported to work well: >
11351135
11361136MacVim *macvim-guifont*
11371137
1138- For MacVim you can use something like this: >
1139- :set guifont=Menlo:h10
1140- Fonts with spaces are set like this: >
1138+ In MacVim, you can specify fonts by either the full PostScript name or the
1139+ family name (both can be found in the Font Book app), followed by an optional
1140+ font size (which defaults to `h11` ). Font names can also be completed in the
1141+ cmdline using | complete-set-option | .
1142+
1143+ Basic example of setting the font to Menlo with default size: >
1144+ :set guifont=Menlo
1145+ To set a font by its family name which contains spaces: >
11411146 :set guifont=DejaVu\ Sans\ Mono:h13
1147+ When specifying family names with spaces, you can also use underscores
1148+ instead: >
1149+ :set guifont=DejaVu_Sans_Mono:h13
11421150 To use bold/italic fonts, use the fully specified PostScript name of the
11431151font, like so: >
11441152 :set guifont=Menlo-Bold:h13
Original file line number Diff line number Diff line change 11961196 parseFailed = YES ;
11971197 }
11981198
1199- if (!parseFailed) {
1200- // Replace underscores with spaces.
1201- fontName = [[fontName componentsSeparatedByString: @" _" ]
1202- componentsJoinedByString: @" " ];
1203- }
1204-
12051199 const BOOL isSystemFont = [fontName hasPrefix: MMSystemFontAlias];
12061200 if (isSystemFont) {
12071201 if (fontName.length > MMSystemFontAlias.length ) {
12281222 || isSystemFont
12291223 || [NSFont fontWithName: fontName size: size])
12301224 return [[NSString alloc ] initWithFormat: @" %@ :h%d " , fontName, size];
1225+
1226+ // If font loading failed, try to replace underscores with spaces for
1227+ // user convenience. This really only works if the name is a family
1228+ // name because PostScript names should not have spaces.
1229+ if ([fontName rangeOfString: @" _" ].location != NSNotFound ) {
1230+ fontName = [fontName stringByReplacingOccurrencesOfString: @" _" withString: @" " ];
1231+ if ([NSFont fontWithName: fontName size: size]) {
1232+ return [[NSString alloc ] initWithFormat: @" %@ :h%d " , fontName, size];
1233+ }
1234+ }
12311235 }
12321236
12331237 return NOFONT;
You can’t perform that action at this time.
0 commit comments