From bc25430228c051330c0fa9b76b1c965c87f22d1f Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Fri, 11 Oct 2013 10:59:33 -0400 Subject: [PATCH] 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. --- src/MacVim/MMBackend.m | 2 +- src/MacVim/gui_macvim.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 05b8f7a109..7a4cded10f 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -991,7 +991,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font); { NSString *fontName = (NSString *)font; float size = 0; - NSArray *components = [fontName componentsSeparatedByString:@":"]; + NSArray *components = [fontName componentsSeparatedByString:@":h"]; if ([components count] == 2) { size = [[components lastObject] floatValue]; fontName = [components objectAtIndex:0]; diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index 2259f68a62..73751a0571 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -1017,7 +1017,7 @@ gui_mch_set_font(GuiFont font) gui_macvim_font_with_name(char_u *name) { if (!name) - return (GuiFont)[[NSString alloc] initWithFormat:@"%@:%d", + return (GuiFont)[[NSString alloc] initWithFormat:@"%@:h%d", MMDefaultFontName, MMDefaultFontSize]; NSString *fontName = [NSString stringWithVimString:name]; @@ -1055,7 +1055,7 @@ gui_macvim_font_with_name(char_u *name) // can load it. Otherwise we ask NSFont if it can load it. if ([fontName isEqualToString:MMDefaultFontName] || [NSFont fontWithName:fontName size:size]) - return [[NSString alloc] initWithFormat:@"%@:%d", fontName, size]; + return [[NSString alloc] initWithFormat:@"%@:h%d", fontName, size]; } return NOFONT;