Skip to content

Commit 92dd6ba

Browse files
committed
-[MMCoreTextView initWithFrame:] doesn't initialize fontDescent
Fixes #883.
1 parent f8bd61b commit 92dd6ba

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/MacVim/MMCoreTextView.m

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ - (id)initWithFrame:(NSRect)frame
150150
// NOTE! It does not matter which font is set here, Vim will set its
151151
// own font on startup anyway. Just set some bogus values.
152152
font = [[NSFont userFixedPitchFontOfSize:0] retain];
153+
fontDescent = ceil(CTFontGetDescent((CTFontRef)font));
153154
cellSize.width = cellSize.height = 1;
154155

155156
// NOTE: If the default changes to 'NO' then the intialization of
@@ -301,18 +302,13 @@ - (NSRect)rectForColumnsInRange:(NSRange)range
301302

302303
- (void)setFont:(NSFont *)newFont
303304
{
304-
if (!(newFont && font != newFont))
305+
if (!newFont || [font isEqual:newFont])
305306
return;
306307

307308
double em = round(defaultAdvanceForFont(newFont));
308-
double pt = round([newFont pointSize]);
309-
310-
CTFontDescriptorRef desc = CTFontDescriptorCreateWithNameAndSize((CFStringRef)[newFont fontName], pt);
311-
CTFontRef fontRef = CTFontCreateWithFontDescriptor(desc, pt, NULL);
312-
CFRelease(desc);
313309

314310
[font release];
315-
font = (NSFont*)fontRef;
311+
font = [newFont retain];
316312

317313
float cellWidthMultiplier = [[NSUserDefaults standardUserDefaults]
318314
floatForKey:MMCellWidthMultiplierKey];
@@ -324,7 +320,7 @@ - (void)setFont:(NSFont *)newFont
324320
cellSize.width = columnspace + ceil(em * cellWidthMultiplier);
325321
cellSize.height = linespace + defaultLineHeightForFont(font);
326322

327-
fontDescent = ceil(CTFontGetDescent(fontRef));
323+
fontDescent = ceil(CTFontGetDescent((CTFontRef)newFont));
328324

329325
[fontCache removeAllObjects];
330326
}

0 commit comments

Comments
 (0)