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