Update Russian translation (#3918)
[geany-mirror.git] / scintilla / src / Style.cxx
bloba45072292e8cc386f5487222f248ffb53aafc73c
1 // Scintilla source code edit control
2 /** @file Style.cxx
3 ** Defines the font and colour style for a class of text.
4 **/
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.
8 #include <stdexcept>
9 #include <string_view>
10 #include <vector>
11 #include <optional>
12 #include <memory>
14 #include "ScintillaTypes.h"
16 #include "Debugging.h"
17 #include "Geometry.h"
18 #include "Platform.h"
20 #include "Style.h"
22 using namespace Scintilla;
23 using namespace Scintilla::Internal;
25 bool FontSpecification::operator==(const FontSpecification &other) const noexcept {
26 return fontName == other.fontName &&
27 weight == other.weight &&
28 italic == other.italic &&
29 size == other.size &&
30 characterSet == other.characterSet &&
31 extraFontFlag == other.extraFontFlag &&
32 checkMonospaced == other.checkMonospaced;
35 bool FontSpecification::operator<(const FontSpecification &other) const noexcept {
36 if (fontName != other.fontName)
37 return fontName < other.fontName;
38 if (weight != other.weight)
39 return weight < other.weight;
40 if (italic != other.italic)
41 return !italic;
42 if (size != other.size)
43 return size < other.size;
44 if (characterSet != other.characterSet)
45 return characterSet < other.characterSet;
46 if (extraFontFlag != other.extraFontFlag)
47 return extraFontFlag < other.extraFontFlag;
48 if (checkMonospaced != other.checkMonospaced)
49 return checkMonospaced < other.checkMonospaced;
50 return false;
53 namespace {
55 // noexcept Platform::DefaultFontSize
56 int DefaultFontSize() noexcept {
57 try {
58 return Platform::DefaultFontSize();
59 } catch (...) {
60 return 10;
66 Style::Style(const char *fontName_) noexcept :
67 FontSpecification(fontName_, DefaultFontSize() * FontSizeMultiplier),
68 fore(0,0,0),
69 back(0xff, 0xff, 0xff),
70 eolFilled(false),
71 underline(false),
72 caseForce(CaseForce::mixed),
73 visible(true),
74 changeable(true),
75 hotspot(false),
76 invisibleRepresentation{} {
79 void Style::Copy(std::shared_ptr<Font> font_, const FontMeasurements &fm_) noexcept {
80 font = std::move(font_);
81 (FontMeasurements &)(*this) = fm_;