diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 1449fe7e2c..7ce71a4bb6 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -301,9 +301,14 @@ - (void)setFont:(NSFont *)newFont return; double em = round(defaultAdvanceForFont(newFont)); + double pt = round([newFont pointSize]); + + CTFontDescriptorRef desc = CTFontDescriptorCreateWithNameAndSize((CFStringRef)[newFont fontName], pt); + CTFontRef fontRef = CTFontCreateWithFontDescriptor(desc, pt, NULL); + CFRelease(desc); [font release]; - font = [newFont retain]; + font = (NSFont*)fontRef; float cellWidthMultiplier = [[NSUserDefaults standardUserDefaults] floatForKey:MMCellWidthMultiplierKey]; @@ -315,7 +320,7 @@ - (void)setFont:(NSFont *)newFont cellSize.width = columnspace + ceil(em * cellWidthMultiplier); cellSize.height = linespace + defaultLineHeightForFont(font); - fontDescent = ceil(CTFontGetDescent((CTFontRef)newFont)); + fontDescent = ceil(CTFontGetDescent(fontRef)); [fontCache removeAllObjects]; }