From 99cd246ed849450b41beefc0edc2f37e689a54db Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Tue, 10 Jul 2012 18:08:33 -0700 Subject: [PATCH] Fix clipping of text due to fractional pixels --- AppKit/CPTextField.j | 8 ++++++++ AppKit/_CPImageAndTextView.j | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index f02bb28fd..13171fd54 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1042,8 +1042,16 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); textSize = [text sizeWithFont:font inWidth:textSize.width]; } else + { textSize = [text sizeWithFont:font]; + // Account for possible fractional pixels at right edge + textSize.width += 1; + } + + // Account for possible fractional pixels at bottom edge + textSize.height += 1; + frameSize.height = textSize.height + contentInset.top + contentInset.bottom; if ([self isBezeled]) diff --git a/AppKit/_CPImageAndTextView.j b/AppKit/_CPImageAndTextView.j index adb34716f..5bb2f9b6d 100644 --- a/AppKit/_CPImageAndTextView.j +++ b/AppKit/_CPImageAndTextView.j @@ -680,9 +680,19 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0, { if (_lineBreakMode === CPLineBreakByCharWrapping || _lineBreakMode === CPLineBreakByWordWrapping) + { _textSize = [_text sizeWithFont:_font inWidth:textRectWidth]; + } else + { _textSize = [_text sizeWithFont:_font]; + + // Account for possible fractional pixels at right edge + _textSize.width += 1; + } + + // Account for possible fractional pixels at bottom edge + _textSize.height += 1; } if (_verticalAlignment === CPCenterVerticalTextAlignment)