X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Ffont.h;h=0afd873e1ded8fdd2a02d5a0c69c5534a682531c;hb=8b52763e14ae99c0b04d381afdea0aa915c1c56d;hp=5876bf8a46052cbbbd75ad2adb941a581b2c7029;hpb=f41818f14369f170475b7f2bde1a2dd856517b14;p=dcpomatic.git diff --git a/src/lib/font.h b/src/lib/font.h index 5876bf8a4..0afd873e1 100644 --- a/src/lib/font.h +++ b/src/lib/font.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2023 Carl Hetherington This file is part of DCP-o-matic. @@ -18,17 +18,22 @@ */ + #ifndef DCPOMATIC_FONT_H #define DCPOMATIC_FONT_H + +#include #include #include #include #include #include + namespace dcpomatic { + class Font { public: @@ -37,32 +42,68 @@ public: 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; + } + void as_xml (xmlpp::Node* node); std::string id () const { return _id; } + void set_id (std::string id) { + _id = id; + } + boost::optional file () const { - return _file; + return _content.file; } void set_file (boost::filesystem::path file) { - _file = 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 data() const; + + /** The actual TTF/OTF font data, as either a filename or the raw data itself */ + struct Content + { + boost::optional data; + boost::optional file; + }; + + Content content() const { + return _content; + } + boost::signals2::signal Changed; private: - /** Font ID, used to describe it in the subtitle content */ + /** 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; - boost::optional _file; + Content _content; }; + bool operator!= (Font const & a, Font const & b); bool operator== (Font const & a, Font const & b); + } #endif