X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffont.h;h=12a14aba4e74086dee82c93d3a6464dd6159dee7;hb=b55b41c4de6eebc26dd8126fdc5914055b778d89;hp=0dd63448e7557edd089b70ed9889e8a3a8977064;hpb=acd023e023cfd0c4ccde3d658d038083e2071661;p=dcpomatic.git diff --git a/src/lib/font.h b/src/lib/font.h index 0dd63448e..12a14aba4 100644 --- a/src/lib/font.h +++ b/src/lib/font.h @@ -1,38 +1,61 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2023 Carl Hetherington - This program is free software; you can redistribute it and/or modify + 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. - This program is distributed in the hope that it will be useful, + 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ + #ifndef DCPOMATIC_FONT_H #define DCPOMATIC_FONT_H + +#include #include #include #include #include #include + +namespace dcpomatic { + + class Font { public: - Font (std::string id) + explicit Font (std::string id) : _id (id) {} - Font (cxml::NodePtr node); + 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::Node* node); @@ -40,24 +63,50 @@ public: 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 */ +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; - boost::optional _file; + Content _content; }; -bool -operator!= (Font const & a, Font const & b); + +bool operator!= (Font const & a, Font const & b); +bool operator== (Font const & a, Font const & b); + + +} #endif