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(const FontAlias &other) : Font() {
26
FontAlias::~FontAlias() {
28
// ~Font will not release the actual font resource since it is now 0
31
void FontAlias::MakeAlias(Font &fontOrigin) {
32
SetID(fontOrigin.GetID());
35
void FontAlias::ClearFont() {
39
bool FontSpecification::operator==(const FontSpecification &other) const {
40
return fontName == other.fontName &&
41
weight == other.weight &&
42
italic == other.italic &&
44
characterSet == other.characterSet &&
45
extraFontFlag == other.extraFontFlag;
48
bool FontSpecification::operator<(const FontSpecification &other) const {
49
if (fontName != other.fontName)
50
return fontName < other.fontName;
51
if (weight != other.weight)
52
return weight < other.weight;
53
if (italic != other.italic)
54
return italic == false;
55
if (size != other.size)
56
return size < other.size;
57
if (characterSet != other.characterSet)
58
return characterSet < other.characterSet;
59
if (extraFontFlag != other.extraFontFlag)
60
return extraFontFlag < other.extraFontFlag;
64
FontMeasurements::FontMeasurements() {
68
void FontMeasurements::Clear() {
76
Style::Style() : FontSpecification() {
77
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
78
Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
79
SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
82
Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
83
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
85
SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
88
characterSet = source.characterSet;
89
weight = source.weight;
90
italic = source.italic;
92
fontName = source.fontName;
93
eolFilled = source.eolFilled;
94
underline = source.underline;
95
caseForce = source.caseForce;
96
visible = source.visible;
97
changeable = source.changeable;
98
hotspot = source.hotspot;
104
Style &Style::operator=(const Style &source) {
107
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
108
0, 0, SC_CHARSET_DEFAULT,
109
SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
112
characterSet = source.characterSet;
113
weight = source.weight;
114
italic = source.italic;
116
fontName = source.fontName;
117
eolFilled = source.eolFilled;
118
underline = source.underline;
119
caseForce = source.caseForce;
120
visible = source.visible;
121
changeable = source.changeable;
125
void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
126
const char *fontName_, int characterSet_,
127
int weight_, bool italic_, bool eolFilled_,
128
bool underline_, ecaseForced caseForce_,
129
bool visible_, bool changeable_, bool hotspot_) {
132
characterSet = characterSet_;
136
fontName = fontName_;
137
eolFilled = eolFilled_;
138
underline = underline_;
139
caseForce = caseForce_;
141
changeable = changeable_;
144
FontMeasurements::Clear();
147
void Style::ClearTo(const Style &source) {
164
void Style::Copy(Font &font_, const FontMeasurements &fm_) {
165
font.MakeAlias(font_);
167
font.SetAscent(fm_.ascent);
169
(FontMeasurements &)(*this) = fm_;