Add a comment.
[dcpomatic.git] / src / lib / font.h
index bbf88b34ad0247d1bf9468bb826e11710e4128ab..55c4249cc9b07361b38b5a7b29c03523ceb85aed 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2023 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
+
 #ifndef DCPOMATIC_FONT_H
 #define DCPOMATIC_FONT_H
 
-#include "font_files.h"
+
+#include <dcp/array_data.h>
 #include <libcxml/cxml.h>
 #include <boost/optional.hpp>
 #include <boost/signals2.hpp>
 #include <boost/filesystem.hpp>
 #include <string>
 
+
+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)
+               , _file (file)
+       {}
+
+       Font (std::string id, dcp::ArrayData data)
+               : _id (id)
+               , _data (data)
+       {}
 
        void as_xml (xmlpp::Node* node);
 
@@ -42,33 +58,40 @@ public:
                return _id;
        }
 
-       boost::optional<boost::filesystem::path> file (FontFiles::Variant variant) const {
-               return _files.get (variant);
+       void set_id (std::string id) {
+               _id = id;
        }
 
-       void set_file (FontFiles::Variant variant, boost::filesystem::path file) {
-               _files.set (variant, file);
-               Changed ();
-       }
-
-       FontFiles files () const {
-               return _files;
+       boost::optional<boost::filesystem::path> file () const {
+               return _file;
        }
 
-       void set_files (FontFiles files) {
-               _files = files;
+       void set_file (boost::filesystem::path file) {
+               _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;
+
        boost::signals2::signal<void()> 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;
-       FontFiles _files;
+       boost::optional<dcp::ArrayData> _data;
+       boost::optional<boost::filesystem::path> _file;
 };
 
+
 bool operator!= (Font const & a, Font const & b);
 bool operator== (Font const & a, Font const & b);
 
+
+}
+
 #endif