diff options
author | Neil <nyamatongwe@gmail.com> | 2021-03-17 14:58:11 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-03-17 14:58:11 +1100 |
commit | 1b5dd62b71d8d9b657b0cd7c138c9dc523a07cc4 (patch) | |
tree | f25f7353ad23c041da607b07b5ddd247214ba90c /src/ViewStyle.cxx | |
parent | 7fbe52f835688967a6079582ed8839cb55d0f9ea (diff) | |
download | scintilla-mirror-1b5dd62b71d8d9b657b0cd7c138c9dc523a07cc4.tar.gz |
Change Font to an interface and stop using FontID. Fonts are shared and
reference counted using std::shared_ptr. This optimizes memory and reduces
potential for allocation bugs.
Diffstat (limited to 'src/ViewStyle.cxx')
-rw-r--r-- | src/ViewStyle.cxx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index d05e82749..0a3451026 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -37,7 +37,6 @@ MarginStyle::MarginStyle(int style_, int width_, int mask_) noexcept : FontRealised::FontRealised() noexcept = default; FontRealised::~FontRealised() { - font.Release(); } void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs) { @@ -48,13 +47,13 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, cons const float deviceHeight = static_cast<float>(surface.DeviceHeightFont(sizeZoomed)); const FontParameters fp(fs.fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, fs.weight, fs.italic, fs.extraFontFlag, technology, fs.characterSet); - font.Create(fp); + font = Font::Allocate(fp); - ascent = static_cast<unsigned int>(surface.Ascent(font)); - descent = static_cast<unsigned int>(surface.Descent(font)); - capitalHeight = surface.Ascent(font) - surface.InternalLeading(font); - aveCharWidth = surface.AverageCharWidth(font); - spaceWidth = surface.WidthText(font, " "); + ascent = static_cast<unsigned int>(surface.Ascent(font.get())); + descent = static_cast<unsigned int>(surface.Descent(font.get())); + capitalHeight = surface.Ascent(font.get()) - surface.InternalLeading(font.get()); + aveCharWidth = surface.AverageCharWidth(font.get()); + spaceWidth = surface.WidthText(font.get(), " "); } ViewStyle::ViewStyle() : markers(MARKER_MAX + 1), indicators(INDICATOR_MAX + 1) { @@ -345,7 +344,7 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) { controlCharWidth = 0.0; if (controlCharSymbol >= 32) { const char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; - controlCharWidth = surface.WidthText(styles[STYLE_CONTROLCHAR].font, cc); + controlCharWidth = surface.WidthText(styles[STYLE_CONTROLCHAR].font.get(), cc); } CalculateMarginWidthAndMask(); |