vcl/source/control/edit.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
New commits: commit f72013ca65c7a33991d5fb124b919fe7cde269e2 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Aug 26 15:24:25 2021 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Aug 26 17:57:16 2021 +0200 use max of avg digit or 'average char' width to measure Edit space instead of the x-width this is similar to what gtk does Change-Id: I2806939a09b275a3060ddf693e2763238a4e075f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121118 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index c2329c45dc78..958b26e54dde 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2668,8 +2668,8 @@ Size Edit::CalcSize(sal_Int32 nChars) const { // width for N characters, independent from content. // works only correct for fixed fonts, average otherwise - Size aSz( GetTextWidth( "x" ), GetTextHeight() ); - aSz.setWidth( aSz.Width() * nChars ); + float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width()); + Size aSz(fUnitWidth * nChars, GetTextHeight()); aSz.AdjustWidth(ImplGetExtraXOffset() * 2 ); aSz = CalcWindowSize( aSz ); return aSz; @@ -2679,8 +2679,8 @@ sal_Int32 Edit::GetMaxVisChars() const { const vcl::Window* pW = mpSubEdit ? mpSubEdit : this; sal_Int32 nOutWidth = pW->GetOutputSizePixel().Width(); - sal_Int32 nCharWidth = GetTextWidth( "x" ); - return nCharWidth ? nOutWidth/nCharWidth : 0; + float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width()); + return nOutWidth / fUnitWidth; } namespace vcl