From 6af520e2a9e2f5e5c0c92c91ac71db69c7168964 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 22 Dec 2013 04:44:03 +0100 Subject: [PATCH] BControlLook::DrawLabel(): Fix off-by-one error * BFont::TruncateString() expects a pixel count (as opposed to a pixel distance). That would cause a tightly fitting string to be truncated. * Round the result of StringWidth() to avoid drawing at a non-integer location. --- src/kits/interface/ControlLook.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 6af77787af..7032239dc3 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -1889,7 +1889,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, } // label, possibly with icon - float availableWidth = rect.Width(); + float availableWidth = rect.Width() + 1; float width = 0; float textOffset = 0; float height = 0; @@ -1908,7 +1908,7 @@ BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon, view->GetFont(&font); font.TruncateString(&truncatedLabel, B_TRUNCATE_END, availableWidth); - width += font.StringWidth(truncatedLabel.String()); + width += ceilf(font.StringWidth(truncatedLabel.String())); font_height fontHeight; font.GetHeight(&fontHeight);