diff options
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r-- | src/PositionCache.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 714937dc1..fda736cc7 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -377,6 +377,14 @@ constexpr size_t AlignUp(size_t value, size_t alignment) noexcept { constexpr size_t alignmentLLC = 20; +constexpr bool GraphicASCII(char ch) noexcept { + return ch >= ' ' && ch <= '~'; +} + +bool AllGraphicASCII(std::string_view text) noexcept { + return std::all_of(text.cbegin(), text.cend(), GraphicASCII); +} + } @@ -895,6 +903,14 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns probe = probe2; } } + if (vstyle.styles[styleNumber].monospaceASCII) { + if (AllGraphicASCII(sv)) { + for (size_t i = 0; i < sv.length(); i++) { + positions[i] = vstyle.styles[styleNumber].aveCharWidth * (i+1); + } + return; + } + } const Font *fontStyle = vstyle.styles[styleNumber].font.get(); surface->MeasureWidths(fontStyle, sv, positions); if (probe < pces.size()) { |