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.
This commit is contained in:
Ingo Weinhold 2013-12-22 04:44:03 +01:00
parent fe8787698c
commit 6af520e2a9
1 changed files with 2 additions and 2 deletions

View File

@ -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);