Skip to content

Commit bc25430

Browse files
jszakmeisterb4winckler
authored andcommitted
Fix getfontname()
getfontname() would incorrectly return strings of the form "FONTNAME:SIZE", when it should be returning strings of the form "FONTNAME:hSIZE"--notice the "h" in the last form. To fix this, we change the internal representation of the font name and size to include the "h", and peel it off when actually setting the font.
1 parent b91903e commit bc25430

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/MacVim/MMBackend.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ - (void)setFont:(GuiFont)font wide:(BOOL)wide
991991
{
992992
NSString *fontName = (NSString *)font;
993993
float size = 0;
994-
NSArray *components = [fontName componentsSeparatedByString:@":"];
994+
NSArray *components = [fontName componentsSeparatedByString:@":h"];
995995
if ([components count] == 2) {
996996
size = [[components lastObject] floatValue];
997997
fontName = [components objectAtIndex:0];

src/MacVim/gui_macvim.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@
10171017
gui_macvim_font_with_name(char_u *name)
10181018
{
10191019
if (!name)
1020-
return (GuiFont)[[NSString alloc] initWithFormat:@"%@:%d",
1020+
return (GuiFont)[[NSString alloc] initWithFormat:@"%@:h%d",
10211021
MMDefaultFontName, MMDefaultFontSize];
10221022

10231023
NSString *fontName = [NSString stringWithVimString:name];
@@ -1055,7 +1055,7 @@
10551055
// can load it. Otherwise we ask NSFont if it can load it.
10561056
if ([fontName isEqualToString:MMDefaultFontName]
10571057
|| [NSFont fontWithName:fontName size:size])
1058-
return [[NSString alloc] initWithFormat:@"%@:%d", fontName, size];
1058+
return [[NSString alloc] initWithFormat:@"%@:h%d", fontName, size];
10591059
}
10601060

10611061
return NOFONT;

0 commit comments

Comments
 (0)