The Battle for Wesnoth  1.19.5+dev
font_description.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 - 2024
3  by Chris Beck<render787@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include "config.hpp"
19 #include "lexical_cast.hpp"
21 #include "utils/optional_fwd.hpp"
22 
23 #include <string>
24 #include <utility>
25 #include <vector>
26 
27 namespace font {
28 
29 // structure used to describe a font, and the subset of the Unicode character
30 // set it covers.
31 //
32 // used by font_config interface (not specific to sdl_ttf or pango)
34 {
36  : name()
37  , bold_name()
38  , italic_name()
39  {
40  }
41 
42  explicit subset_descriptor(const config & font)
43  : name(font["name"].str())
44  , bold_name()
45  , italic_name()
46  {
47  if (font.has_attribute("bold_name")) {
48  bold_name = font["bold_name"].str();
49  }
50 
51  if (font.has_attribute("italic_name")) {
52  italic_name = font["italic_name"].str();
53  }
54  }
55 
56  std::string name;
57  utils::optional<std::string> bold_name; //If we are using another font for styled characters in this font, rather than SDL TTF method
58  utils::optional<std::string> italic_name;
59 };
60 
61 } // end namespace font
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
Definitions for the interface to Wesnoth Markup Language (WML).
New lexcical_cast header.
Graphical text output.
utils::optional< std::string > italic_name
utils::optional< std::string > bold_name
subset_descriptor(const config &font)