X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffont.cc;h=c817d361018ce9c9bfc51068a4846e4ce06c284e;hb=refs%2Fheads%2Ffaster-subtitle-moving;hp=019c9ab076fe8f83e362c8030f2542b4beceb1df;hpb=f41818f14369f170475b7f2bde1a2dd856517b14;p=dcpomatic.git diff --git a/src/lib/font.cc b/src/lib/font.cc index 019c9ab07..c817d3610 100644 --- a/src/lib/font.cc +++ b/src/lib/font.cc @@ -20,10 +20,15 @@ #include "font.h" #include "dcpomatic_assert.h" +#include "dcpomatic_socket.h" +#include +#include #include #include using std::string; +using boost::shared_ptr; +using dcp::raw_convert; using namespace dcpomatic; Font::Font (cxml::NodePtr node) @@ -38,7 +43,7 @@ Font::Font (cxml::NodePtr node) } void -Font::as_xml (xmlpp::Node* node) +Font::as_xml (xmlpp::Node* node) const { node->add_child("Id")->add_child_text (_id); if (_file) { @@ -46,6 +51,27 @@ Font::as_xml (xmlpp::Node* node) } } +/** Add things to an XML node to describe this font for transfer across + * a network to another machine. The companion method send_binary() will be called + * to send binary parts. + */ +void +Font::transfer_xml (xmlpp::Node* node) const +{ + node->add_child("Id")->add_child_text (_id); + if (_file) { + node->add_child("FileLength")->add_child_text(raw_convert(boost::filesystem::file_size(*_file))); + } +} + +void +Font::transfer_binary (shared_ptr socket) const +{ + if (_file) { + dcp::Data data (*_file); + socket->write (data.data().get(), data.size()); + } +} bool dcpomatic::operator== (Font const & a, Font const & b)