Rename SafeStringStream -> locked_stringstream. Bump deps for removal of stringstream.
[dcpomatic.git] / src / lib / font.h
1 /*
2     Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #ifndef DCPOMATIC_FONT_H
22 #define DCPOMATIC_FONT_H
23
24 #include "font_files.h"
25 #include <libcxml/cxml.h>
26 #include <boost/optional.hpp>
27 #include <boost/signals2.hpp>
28 #include <boost/filesystem.hpp>
29 #include <string>
30
31 class Font
32 {
33 public:
34         Font (std::string id)
35                 : _id (id) {}
36
37         Font (cxml::NodePtr node);
38
39         void as_xml (xmlpp::Node* node);
40
41         std::string id () const {
42                 return _id;
43         }
44
45         boost::optional<boost::filesystem::path> file (FontFiles::Variant variant) const {
46                 return _files.get (variant);
47         }
48
49         void set_file (FontFiles::Variant variant, boost::filesystem::path file) {
50                 _files.set (variant, file);
51                 Changed ();
52         }
53
54         FontFiles files () const {
55                 return _files;
56         }
57
58         void set_files (FontFiles files) {
59                 _files = files;
60                 Changed ();
61         }
62
63         boost::signals2::signal<void()> Changed;
64
65 private:
66         /** Font ID, used to describe it in the subtitle content */
67         std::string _id;
68         FontFiles _files;
69 };
70
71 bool operator!= (Font const & a, Font const & b);
72 bool operator== (Font const & a, Font const & b);
73
74 #endif