diff options
author | Neil <nyamatongwe@gmail.com> | 2021-09-28 12:53:58 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-09-28 12:53:58 +1000 |
commit | fe41a24534e1280f088835ea1813fa64120f4169 (patch) | |
tree | b25f80573180e44d01b078331022251792174f86 | |
parent | 810964f8e6b80fbfdb7f96b9a084acc4cbe5a3a1 (diff) | |
download | scintilla-mirror-fe41a24534e1280f088835ea1813fa64120f4169.tar.gz |
Fix bad layout of monospace text on Cocoa by adding separate field
monospaceCharacterWidth for width of monospaced characters.
-rw-r--r-- | src/PositionCache.cxx | 2 | ||||
-rw-r--r-- | src/Style.h | 1 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 2 |
3 files changed, 4 insertions, 1 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 073a62692..f24164636 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -906,7 +906,7 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns 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); + positions[i] = vstyle.styles[styleNumber].monospaceCharacterWidth * (i+1); } return; } diff --git a/src/Style.h b/src/Style.h index 23a1b265f..6cef6bb60 100644 --- a/src/Style.h +++ b/src/Style.h @@ -32,6 +32,7 @@ struct FontMeasurements { XYPOSITION descent = 1; XYPOSITION capitalHeight = 1; // Top of capital letter to baseline: ascent - internal leading XYPOSITION aveCharWidth = 1; + XYPOSITION monospaceCharacterWidth = 1; XYPOSITION spaceWidth = 1; bool monospaceASCII = false; int sizeZoomed = 2; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 84d165997..5273841ed 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -66,6 +66,7 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technolog measurements.capitalHeight = surface.Ascent(font.get()) - surface.InternalLeading(font.get()); measurements.aveCharWidth = surface.AverageCharWidth(font.get()); + measurements.monospaceCharacterWidth = measurements.aveCharWidth; measurements.spaceWidth = surface.WidthText(font.get(), " "); if (fs.checkMonospaced) { @@ -82,6 +83,7 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technolog const XYPOSITION scaledVariance = variance / measurements.aveCharWidth; constexpr XYPOSITION monospaceWidthEpsilon = 0.000001; // May need tweaking if monospace fonts vary more measurements.monospaceASCII = scaledVariance < monospaceWidthEpsilon; + measurements.monospaceCharacterWidth = minWidth; } else { measurements.monospaceASCII = false; } |