Skip to content

Commit 72e6bbf

Browse files
authored
Merge pull request #927 from jjgod/883-fontDescent
-[MMCoreTextView initWithFrame:] doesn't initialize fontDescent
2 parents fc11e4b + 545bd21 commit 72e6bbf

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/MacVim/MMCoreTextView.m

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,13 @@ - (id)initWithFrame:(NSRect)frame
147147
}
148148
cgLayerLock = [NSLock new];
149149

150-
// NOTE! It does not matter which font is set here, Vim will set its
151-
// own font on startup anyway. Just set some bogus values.
152-
font = [[NSFont userFixedPitchFontOfSize:0] retain];
153-
cellSize.width = cellSize.height = 1;
154-
155150
// NOTE: If the default changes to 'NO' then the intialization of
156151
// p_antialias in option.c must change as well.
157152
antialias = YES;
158153

159154
drawData = [[NSMutableArray alloc] init];
160155
fontCache = [[NSMutableArray alloc] init];
156+
[self setFont:[NSFont userFixedPitchFontOfSize:0]];
161157

162158
helper = [[MMTextViewHelper alloc] init];
163159
[helper setTextView:self];
@@ -301,18 +297,13 @@ - (NSRect)rectForColumnsInRange:(NSRange)range
301297

302298
- (void)setFont:(NSFont *)newFont
303299
{
304-
if (!(newFont && font != newFont))
300+
if (!newFont || [font isEqual:newFont])
305301
return;
306302

307303
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);
313304

314305
[font release];
315-
font = (NSFont*)fontRef;
306+
font = [newFont retain];
316307

317308
float cellWidthMultiplier = [[NSUserDefaults standardUserDefaults]
318309
floatForKey:MMCellWidthMultiplierKey];
@@ -324,7 +315,7 @@ - (void)setFont:(NSFont *)newFont
324315
cellSize.width = columnspace + ceil(em * cellWidthMultiplier);
325316
cellSize.height = linespace + defaultLineHeightForFont(font);
326317

327-
fontDescent = ceil(CTFontGetDescent(fontRef));
318+
fontDescent = ceil(CTFontGetDescent((CTFontRef)newFont));
328319

329320
[fontCache removeAllObjects];
330321
}

0 commit comments

Comments
 (0)