Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions src/MacVim/MMCoreTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,13 @@ - (id)initWithFrame:(NSRect)frame
}
cgLayerLock = [NSLock new];

// NOTE! It does not matter which font is set here, Vim will set its
// own font on startup anyway. Just set some bogus values.
font = [[NSFont userFixedPitchFontOfSize:0] retain];
cellSize.width = cellSize.height = 1;

// NOTE: If the default changes to 'NO' then the intialization of
// p_antialias in option.c must change as well.
antialias = YES;

drawData = [[NSMutableArray alloc] init];
fontCache = [[NSMutableArray alloc] init];
[self setFont:[NSFont userFixedPitchFontOfSize:0]];

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

- (void)setFont:(NSFont *)newFont
{
if (!(newFont && font != newFont))
if (!newFont || [font isEqual: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 = (NSFont*)fontRef;
font = [newFont retain];

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

fontDescent = ceil(CTFontGetDescent(fontRef));
fontDescent = ceil(CTFontGetDescent((CTFontRef)newFont));

[fontCache removeAllObjects];
}
Expand Down