1 // Scintilla source code edit control
3 ** Defines the font and colour style for a class of text.
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
12 #include "Scintilla.h"
16 using namespace Scintilla
;
19 FontAlias::FontAlias() {
22 FontAlias::~FontAlias() {
24 // ~Font will not release the actual font resource since it is now 0
27 void FontAlias::MakeAlias(Font
&fontOrigin
) {
28 SetID(fontOrigin
.GetID());
31 void FontAlias::ClearFont() {
35 bool FontSpecification::operator==(const FontSpecification
&other
) const {
36 return fontName
== other
.fontName
&&
37 weight
== other
.weight
&&
38 italic
== other
.italic
&&
40 characterSet
== other
.characterSet
&&
41 extraFontFlag
== other
.extraFontFlag
;
44 bool FontSpecification::operator<(const FontSpecification
&other
) const {
45 if (fontName
!= other
.fontName
)
46 return fontName
< other
.fontName
;
47 if (weight
!= other
.weight
)
48 return weight
< other
.weight
;
49 if (italic
!= other
.italic
)
50 return italic
== false;
51 if (size
!= other
.size
)
52 return size
< other
.size
;
53 if (characterSet
!= other
.characterSet
)
54 return characterSet
< other
.characterSet
;
55 if (extraFontFlag
!= other
.extraFontFlag
)
56 return extraFontFlag
< other
.extraFontFlag
;
60 FontMeasurements::FontMeasurements() {
64 void FontMeasurements::Clear() {
72 Style::Style() : FontSpecification() {
73 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
74 Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER
, 0, SC_CHARSET_DEFAULT
,
75 SC_WEIGHT_NORMAL
, false, false, false, caseMixed
, true, true, false);
78 Style::Style(const Style
&source
) : FontSpecification(), FontMeasurements() {
79 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
81 SC_WEIGHT_NORMAL
, false, false, false, caseMixed
, true, true, false);
84 characterSet
= source
.characterSet
;
85 weight
= source
.weight
;
86 italic
= source
.italic
;
88 fontName
= source
.fontName
;
89 eolFilled
= source
.eolFilled
;
90 underline
= source
.underline
;
91 caseForce
= source
.caseForce
;
92 visible
= source
.visible
;
93 changeable
= source
.changeable
;
94 hotspot
= source
.hotspot
;
100 Style
&Style::operator=(const Style
&source
) {
103 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
104 0, 0, SC_CHARSET_DEFAULT
,
105 SC_WEIGHT_NORMAL
, false, false, false, caseMixed
, true, true, false);
108 characterSet
= source
.characterSet
;
109 weight
= source
.weight
;
110 italic
= source
.italic
;
112 fontName
= source
.fontName
;
113 eolFilled
= source
.eolFilled
;
114 underline
= source
.underline
;
115 caseForce
= source
.caseForce
;
116 visible
= source
.visible
;
117 changeable
= source
.changeable
;
121 void Style::Clear(ColourDesired fore_
, ColourDesired back_
, int size_
,
122 const char *fontName_
, int characterSet_
,
123 int weight_
, bool italic_
, bool eolFilled_
,
124 bool underline_
, ecaseForced caseForce_
,
125 bool visible_
, bool changeable_
, bool hotspot_
) {
128 characterSet
= characterSet_
;
132 fontName
= fontName_
;
133 eolFilled
= eolFilled_
;
134 underline
= underline_
;
135 caseForce
= caseForce_
;
137 changeable
= changeable_
;
140 FontMeasurements::Clear();
143 void Style::ClearTo(const Style
&source
) {
160 void Style::Copy(Font
&font_
, const FontMeasurements
&fm_
) {
161 font
.MakeAlias(font_
);
163 font
.SetAscent(fm_
.ascent
);
165 (FontMeasurements
&)(*this) = fm_
;