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.
7
8#include <stdexcept>
9#include <string_view>
10#include <vector>
11#include <optional>
12#include <memory>
13
14#include "ScintillaTypes.h"
15
16#include "Debugging.h"
17#include "Geometry.h"
18#include "Platform.h"
19
20#include "Style.h"
21
22using namespace Scintilla;
23using namespace Scintilla::Internal;
24
25bool 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;
33}
34
35bool 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;
51}
52
53namespace {
54
55// noexcept Platform::DefaultFontSize
56int DefaultFontSize() noexcept {
57 try {
58 return Platform::DefaultFontSize();
59 } catch (...) {
60 return 10;
61 }
62}
63
64}
65
66Style::Style(const char *fontName_) noexcept :
67 FontSpecification(fontName_, DefaultFontSize() * FontSizeMultiplier),
68 fore(0xa9, 0xa9, 0xa9),
69 back(0x5a, 0x5a, 0x5a),
70 eolFilled(false),
71 underline(false),
72 caseForce(CaseForce::mixed),
73 visible(true),
74 changeable(true),
75 hotspot(false) {
76}
77
78void Style::Copy(std::shared_ptr<Font> font_, const FontMeasurements &fm_) noexcept {
79 font = std::move(font_);
80 (FontMeasurements &)(*this) = fm_;
81}
82