From b50d82d5dd2c07da8064c4accbedb523a51b500d Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 10 Jun 2020 13:00:05 +1000 Subject: Backport: Feature [feature-requests:1355]. Round instead of truncating for SCI_TEXTWIDTH. Backport of changeset 8297:3665e2c20cd4. --- src/Editor.cxx | 4 ++-- src/Editor.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index c1bc8d435..e655b7e82 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1819,11 +1819,11 @@ Sci::Position Editor::FormatRange(bool draw, const Sci_RangeToFormat *pfr) { return view.FormatRange(draw, pfr, surface, surfaceMeasure, *this, vs); } -int Editor::TextWidth(int style, const char *text) { +long Editor::TextWidth(uptr_t style, const char *text) { RefreshStyleData(); AutoSurface surface(this); if (surface) { - return static_cast(surface->WidthText(vs.styles[style].font, text, static_cast(strlen(text)))); + return Sci::lround(surface->WidthText(vs.styles[style].font, text, static_cast(strlen(text)))); } else { return 1; } diff --git a/src/Editor.h b/src/Editor.h index eb87c470d..626b67325 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -388,7 +388,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void RefreshPixMaps(Surface *surfaceWindow); void Paint(Surface *surfaceWindow, PRectangle rcArea); Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr); - int TextWidth(int style, const char *text); + long TextWidth(uptr_t style, const char *text); virtual void SetVerticalScrollPos() = 0; virtual void SetHorizontalScrollPos() = 0; -- cgit v1.2.3