Skip to content

Commit b433f3a

Browse files
Round up char size earlier to avoid discrepancies in line height. Fixes bug 146.
1 parent 3d6b723 commit b433f3a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

PTYTextView.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,15 @@ - (void)setFont:(NSFont*)aFont nafont:(NSFont *)naFont horizontalSpacing:(float)
464464
NSFontManager* fontManager = [NSFontManager sharedFontManager];
465465
#endif
466466
NSSize sz = [PTYTextView charSizeForFont:aFont horizontalSpacing:1.0 verticalSpacing:1.0];
467-
467+
sz.width = ceil(sz.width);
468+
sz.height = ceil(sz.height);
469+
468470
charWidthWithoutSpacing = sz.width;
469471
charHeightWithoutSpacing = sz.height;
470472
horizontalSpacing_ = horizontalSpacing;
471473
verticalSpacing_ = verticalSpacing;
472-
charWidth = charWidthWithoutSpacing * horizontalSpacing;
473-
lineHeight = charHeightWithoutSpacing * verticalSpacing;
474+
charWidth = ceil(charWidthWithoutSpacing * horizontalSpacing);
475+
lineHeight = ceil(charHeightWithoutSpacing * verticalSpacing);
474476
[font release];
475477
[aFont retain];
476478
font=aFont;
@@ -977,9 +979,9 @@ - (void)drawRect:(NSRect)rect
977979
float g = ((float)((i + 33) % 100)) / 100;
978980
float b = ((float)((i + 66) % 100)) / 100;
979981
[[NSColor colorWithDeviceRed:r green:g blue:b alpha:1] set];
980-
#endif
981-
982+
#else
982983
[defaultBGColor set];
984+
#endif
983985
NSRectFill(excessRect);
984986

985987
#if 0
@@ -2736,7 +2738,7 @@ - (void) _drawCursor
27362738
else
27372739
showCursor = YES;
27382740

2739-
if(CURSOR) {
2741+
if (CURSOR) {
27402742
if (showCursor && x1 < WIDTH && x1 >= 0 && yStart >= 0 && yStart < HEIGHT) {
27412743
curX = floor(x1 * charWidth + MARGIN);
27422744
curY = (yStart + [dataSource numberOfLines] - HEIGHT + 1) * lineHeight - cursorHeight;

0 commit comments

Comments
 (0)