blob: 55e3f33b784b925f143bd224c7482dfc7d3ee3d1 (
plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*
Copyright (C) 2014-2023 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DCPOMATIC_FONT_H
#define DCPOMATIC_FONT_H
#include <dcp/array_data.h>
#include <dcp/warnings.h>
#include <libcxml/cxml.h>
#include <boost/optional.hpp>
LIBDCP_DISABLE_WARNINGS
#include <boost/signals2.hpp>
LIBDCP_ENABLE_WARNINGS
#include <boost/filesystem.hpp>
#include <string>
namespace dcpomatic {
class Font
{
public:
explicit Font(std::string id)
: _id(id) {}
explicit Font(cxml::NodePtr node);
Font(std::string id, boost::filesystem::path file)
: _id(id)
{
_content.file = file;
}
Font(std::string id, dcp::ArrayData data)
: _id(id)
{
_content.data = data;
}
Font(Font const& other);
Font& operator=(Font const& other);
void as_xml(xmlpp::Element* element);
std::string id() const {
return _id;
}
void set_id(std::string id) {
_id = id;
}
boost::optional<boost::filesystem::path> file() const {
return _content.file;
}
void set_file(boost::filesystem::path file) {
_content.file = file;
Changed();
}
/** @return the data set passed to the dcp::ArrayData constructor,
* otherwise the contents of _file, otherwise boost::none.
*/
boost::optional<dcp::ArrayData> data() const;
/** The actual TTF/OTF font data, as either a filename or the raw data itself */
struct Content
{
boost::optional<dcp::ArrayData> data;
boost::optional<boost::filesystem::path> file;
};
Content content() const {
return _content;
}
boost::signals2::signal<void()> Changed;
private:
/** Font ID, used to describe it in the subtitle content; could be either a
* font family name or an ID from some DCP font XML.
*/
std::string _id;
Content _content;
};
bool operator!=(Font const & a, Font const & b);
bool operator==(Font const & a, Font const & b);
}
#endif
|