Skip to content

Commit a7d149b

Browse files
authored
Merge pull request #957 from ychin/fix-font-initialization
Fix font initialization pulling in extra metadata
2 parents dc07a14 + 7fb3e24 commit a7d149b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/MacVim/MMCoreTextView.m

+7-2
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,14 @@ - (void)setFont:(NSFont *)newFont
301301
return;
302302

303303
double em = round(defaultAdvanceForFont(newFont));
304+
double pt = round([newFont pointSize]);
305+
306+
CTFontDescriptorRef desc = CTFontDescriptorCreateWithNameAndSize((CFStringRef)[newFont fontName], pt);
307+
CTFontRef fontRef = CTFontCreateWithFontDescriptor(desc, pt, NULL);
308+
CFRelease(desc);
304309

305310
[font release];
306-
font = [newFont retain];
311+
font = (NSFont*)fontRef;
307312

308313
float cellWidthMultiplier = [[NSUserDefaults standardUserDefaults]
309314
floatForKey:MMCellWidthMultiplierKey];
@@ -315,7 +320,7 @@ - (void)setFont:(NSFont *)newFont
315320
cellSize.width = columnspace + ceil(em * cellWidthMultiplier);
316321
cellSize.height = linespace + defaultLineHeightForFont(font);
317322

318-
fontDescent = ceil(CTFontGetDescent((CTFontRef)newFont));
323+
fontDescent = ceil(CTFontGetDescent(fontRef));
319324

320325
[fontCache removeAllObjects];
321326
}

0 commit comments

Comments
 (0)