File: font.cpp

package info (click to toggle)
ares 134%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 34,680 kB
  • sloc: cpp: 338,717; ansic: 89,036; sh: 52; makefile: 27
file content (74 lines) | stat: -rw-r--r-- 1,464 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#if defined(Hiro_Font)

const string Font::Sans  = "{sans}";
const string Font::Serif = "{serif}";
const string Font::Mono  = "{mono}";

Font::Font(const string& family, f32 size) {
  setFamily(family);
  setSize(size);
  state.bold = false;
  state.italic = false;
}

Font::operator bool() const {
  return state.family || state.size || state.bold || state.italic;
}

auto Font::operator==(const Font& source) const -> bool {
  return family() == source.family() && size() == source.size() && bold() == source.bold() && italic() == source.italic();
}

auto Font::operator!=(const Font& source) const -> bool {
  return !operator==(source);
}

auto Font::bold() const -> bool {
  return state.bold;
}

auto Font::family() const -> string {
  return state.family;
}

auto Font::italic() const -> bool {
  return state.italic;
}

auto Font::reset() -> type& {
  state.family = "";
  state.size = 0;
  state.bold = false;
  state.italic = false;
  return *this;
}

auto Font::setBold(bool bold) -> type& {
  state.bold = bold;
  return *this;
}

auto Font::setFamily(const string& family) -> type& {
  state.family = family;
  return *this;
}

auto Font::setItalic(bool italic) -> type& {
  state.italic = italic;
  return *this;
}

auto Font::setSize(f32 size) -> type& {
  state.size = size;
  return *this;
}

auto Font::size() const -> f32 {
  return state.size;
}

auto Font::size(const string& text) const -> Size {
  return pFont::size(*this, text);
}

#endif