aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Style.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-03-17 14:58:11 +1100
committerNeil <nyamatongwe@gmail.com>2021-03-17 14:58:11 +1100
commit1b5dd62b71d8d9b657b0cd7c138c9dc523a07cc4 (patch)
treef25f7353ad23c041da607b07b5ddd247214ba90c /src/Style.h
parent7fbe52f835688967a6079582ed8839cb55d0f9ea (diff)
downloadscintilla-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/Style.h')
-rw-r--r--src/Style.h18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/Style.h b/src/Style.h
index 071d752ca..769386359 100644
--- a/src/Style.h
+++ b/src/Style.h
@@ -29,20 +29,6 @@ struct FontSpecification {
bool operator<(const FontSpecification &other) const noexcept;
};
-// Just like Font but only has a copy of the FontID so should not delete it
-class FontAlias : public Font {
-public:
- FontAlias() noexcept;
- // FontAlias objects can be copy or move constructed but not be assigned
- FontAlias(const FontAlias &) noexcept;
- FontAlias(FontAlias &&) noexcept;
- FontAlias &operator=(const FontAlias &) = delete;
- FontAlias &operator=(FontAlias &&) = delete;
- ~FontAlias() override;
- void MakeAlias(const Font &fontOrigin) noexcept;
- void ClearFont() noexcept;
-};
-
struct FontMeasurements {
unsigned int ascent;
unsigned int descent;
@@ -68,7 +54,7 @@ public:
bool changeable;
bool hotspot;
- FontAlias font;
+ std::shared_ptr<Font> font;
Style();
Style(const Style &source) noexcept;
@@ -83,7 +69,7 @@ public:
bool underline_, ecaseForced caseForce_,
bool visible_, bool changeable_, bool hotspot_) noexcept;
void ClearTo(const Style &source) noexcept;
- void Copy(const Font &font_, const FontMeasurements &fm_) noexcept;
+ void Copy(std::shared_ptr<Font> font_, const FontMeasurements &fm_) noexcept;
bool IsProtected() const noexcept { return !(changeable && visible);}
};