From dcbc339899911e1a3a743de1c0c25d0c253dd39a Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 15 Aug 2024 19:02:46 +1000 Subject: Add SCI_STYLESETSTRETCH to support condensed and expanded text styles. --- src/Editor.cxx | 7 +++++++ src/Platform.h | 7 +++++-- src/Style.cxx | 3 +++ src/Style.h | 1 + src/ViewStyle.cxx | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index a185d7f08..356f73baa 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -5953,6 +5953,9 @@ void Editor::StyleSetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::StyleSetWeight: vs.styles[wParam].weight = static_cast(lParam); break; + case Message::StyleSetStretch: + vs.styles[wParam].stretch = static_cast(lParam); + break; case Message::StyleSetItalic: vs.styles[wParam].italic = lParam != 0; break; @@ -6022,6 +6025,8 @@ sptr_t Editor::StyleGetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) { return vs.styles[wParam].weight > FontWeight::Normal; case Message::StyleGetWeight: return static_cast(vs.styles[wParam].weight); + case Message::StyleGetStretch: + return static_cast(vs.styles[wParam].stretch); case Message::StyleGetItalic: return vs.styles[wParam].italic ? 1 : 0; case Message::StyleGetEOLFilled: @@ -7580,6 +7585,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::StyleSetBack: case Message::StyleSetBold: case Message::StyleSetWeight: + case Message::StyleSetStretch: case Message::StyleSetItalic: case Message::StyleSetEOLFilled: case Message::StyleSetSize: @@ -7600,6 +7606,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::StyleGetBack: case Message::StyleGetBold: case Message::StyleGetWeight: + case Message::StyleGetStretch: case Message::StyleGetItalic: case Message::StyleGetEOLFilled: case Message::StyleGetSize: diff --git a/src/Platform.h b/src/Platform.h index b0d12888d..585ddd14c 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -108,6 +108,7 @@ struct FontParameters { Scintilla::Technology technology; Scintilla::CharacterSet characterSet; const char *localeName; + Scintilla::FontStretch stretch; constexpr FontParameters( const char *faceName_, @@ -117,7 +118,8 @@ struct FontParameters { Scintilla::FontQuality extraFontFlag_= Scintilla::FontQuality::QualityDefault, Scintilla::Technology technology_= Scintilla::Technology::Default, Scintilla::CharacterSet characterSet_= Scintilla::CharacterSet::Ansi, - const char *localeName_=localeNameDefault) noexcept : + const char *localeName_=localeNameDefault, + Scintilla::FontStretch stretch_=Scintilla::FontStretch::Normal) noexcept : faceName(faceName_), size(size_), @@ -126,7 +128,8 @@ struct FontParameters { extraFontFlag(extraFontFlag_), technology(technology_), characterSet(characterSet_), - localeName(localeName_) + localeName(localeName_), + stretch(stretch_) { } diff --git a/src/Style.cxx b/src/Style.cxx index fcde6398e..228b3db74 100644 --- a/src/Style.cxx +++ b/src/Style.cxx @@ -27,6 +27,7 @@ bool FontSpecification::operator==(const FontSpecification &other) const noexcep weight == other.weight && italic == other.italic && size == other.size && + stretch == other.stretch && characterSet == other.characterSet && extraFontFlag == other.extraFontFlag && checkMonospaced == other.checkMonospaced; @@ -41,6 +42,8 @@ bool FontSpecification::operator<(const FontSpecification &other) const noexcept return !italic; if (size != other.size) return size < other.size; + if (stretch != other.stretch) + return stretch < other.stretch; if (characterSet != other.characterSet) return characterSet < other.characterSet; if (extraFontFlag != other.extraFontFlag) diff --git a/src/Style.h b/src/Style.h index da8159d6c..19679cd04 100644 --- a/src/Style.h +++ b/src/Style.h @@ -15,6 +15,7 @@ struct FontSpecification { const char *fontName; int size; Scintilla::FontWeight weight = Scintilla::FontWeight::Normal; + Scintilla::FontStretch stretch = Scintilla::FontStretch::Normal; bool italic = false; Scintilla::CharacterSet characterSet = Scintilla::CharacterSet::Default; Scintilla::FontQuality extraFontFlag = Scintilla::FontQuality::QualityDefault; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index f20645251..921463931 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -66,7 +66,7 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technolog const float deviceHeight = static_cast(surface.DeviceHeightFont(measurements.sizeZoomed)); const FontParameters fp(fs.fontName, deviceHeight / FontSizeMultiplier, fs.weight, - fs.italic, fs.extraFontFlag, technology, fs.characterSet, localeName); + fs.italic, fs.extraFontFlag, technology, fs.characterSet, localeName, fs.stretch); font = Font::Allocate(fp); // floor here is historical as platform layers have tweaked their values to match. -- cgit v1.2.3