libdcp
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Friends | List of all members
dcp::TextAsset Class Referenceabstract

A parent for classes representing a file containing subtitles or captions. More...

#include <text_asset.h>

Inheritance diagram for dcp::TextAsset:
dcp::Asset dcp::Object dcp::InteropTextAsset dcp::SMPTETextAsset

Classes

class  Font
 
struct  ParseState
 

Public Member Functions

 TextAsset (boost::filesystem::path file)
 
bool equals (std::shared_ptr< const Asset >, EqualityOptions const &, NoteHandler note) const override
 
std::vector< std::shared_ptr< const Text > > texts_during (Time from, Time to, bool starting) const
 
std::vector< std::shared_ptr< const Text > > texts () const
 
virtual void add (std::shared_ptr< Text >)
 
virtual void add_font (std::string id, dcp::ArrayData data)=0
 
void ensure_font (std::string id, dcp::ArrayData data)
 
std::map< std::string, ArrayDatafont_data () const
 
std::map< std::string, boost::filesystem::path > font_filenames () const
 
virtual void write (boost::filesystem::path) const =0
 
virtual std::string xml_as_string () const =0
 
Time latest_text_out () const
 
void fix_empty_font_ids ()
 
virtual std::vector< std::shared_ptr< LoadFontNode > > load_font_nodes () const =0
 
virtual int time_code_rate () const =0
 
virtual boost::optional< std::string > raw_xml () const
 
virtual SubtitleStandard subtitle_standard () const =0
 
- Public Member Functions inherited from dcp::Asset
 Asset ()
 
 Asset (boost::filesystem::path file)
 
 Asset (std::string id, boost::filesystem::path file)
 
virtual void add_to_assetmap (AssetMap &asset_map, boost::filesystem::path root) const
 
virtual void add_to_pkl (std::shared_ptr< PKL > pkl, boost::filesystem::path root) const
 
boost::optional< boost::filesystem::path > file () const
 
void set_file (boost::filesystem::path file) const
 
void set_file_preserving_hash (boost::filesystem::path file) const
 
void rename_file (boost::filesystem::path file)
 
std::string hash (boost::function< void(int64_t, int64_t)> progress={}) const
 
void set_hash (std::string hash)
 
void unset_hash ()
 
- Public Member Functions inherited from dcp::Object
 Object ()
 
 Object (std::string id)
 
 Object (Object const &other)
 
Objectoperator= (Object const &other)
 
std::string id () const
 

Static Public Member Functions

static std::string format_xml (xmlpp::Document const &document, boost::optional< std::pair< std::string, std::string >> xml_namespace)
 

Protected Member Functions

void parse_texts (xmlpp::Element const *node, std::vector< ParseState > &state, boost::optional< int > tcr, Standard standard)
 
ParseState font_node_state (xmlpp::Element const *node, Standard standard) const
 
ParseState text_node_state (xmlpp::Element const *node) const
 
ParseState image_node_state (xmlpp::Element const *node) const
 
ParseState subtitle_node_state (xmlpp::Element const *node, boost::optional< int > tcr) const
 
Time fade_time (xmlpp::Element const *node, std::string name, boost::optional< int > tcr) const
 
void position_align (ParseState &ps, xmlpp::Element const *node) const
 
void texts_as_xml (xmlpp::Element *root, int time_code_rate, Standard standard) const
 

Protected Attributes

std::vector< std::shared_ptr< Text > > _texts
 
std::vector< Font_fonts
 
boost::optional< std::string > _raw_xml
 
- Protected Attributes inherited from dcp::Asset
boost::optional< boost::filesystem::path > _file
 
- Protected Attributes inherited from dcp::Object
std::string _id
 

Private Member Functions

void maybe_add_text (std::string text, std::vector< ParseState > const &parse_state, float space_before, Standard standard, std::vector< Ruby > const &rubies)
 

Static Private Member Functions

static void pull_fonts (std::shared_ptr< order::Part > part)
 

Friends

struct ::interop_dcp_font_test
 
struct ::smpte_dcp_font_test
 
struct ::pull_fonts_test1
 
struct ::pull_fonts_test2
 
struct ::pull_fonts_test3
 

Additional Inherited Members

- Static Protected Member Functions inherited from dcp::Asset
static void add_file_to_assetmap (AssetMap &asset_map, boost::filesystem::path root, boost::filesystem::path file, std::string id)
 

Detailed Description

A parent for classes representing a file containing subtitles or captions.

This class holds a list of Text objects which it can extract from the appropriate part of either an Interop or SMPTE XML file. Its subclasses InteropTextAsset and SMPTETextAsset handle the differences between the two types.

Definition at line 96 of file text_asset.h.

Member Function Documentation

◆ fix_empty_font_ids()

void TextAsset::fix_empty_font_ids ( )

Replace empty IDs in any <LoadFontId> and <Font> tags with a dummy string. Some systems give errors with empty font IDs (see DCP-o-matic bug #1689).

Definition at line 854 of file text_asset.cc.

◆ format_xml()

string TextAsset::format_xml ( xmlpp::Document const &  document,
boost::optional< std::pair< std::string, std::string >>  xml_namespace 
)
static

Format XML much as write_to_string_formatted() would do, except without adding any white space to <Text> nodes. This is an attempt to avoid changing what is actually displayed while also formatting the XML in such a way as to avoid DoM bug 2205.

xml_namespace is an optional namespace for the root node; it would be nicer to set this up with set_namespace_declaration in the caller and then to extract it here but I couldn't find a way to get all namespaces with the libxml++ API.

Definition at line 967 of file text_asset.cc.

◆ raw_xml()

virtual boost::optional<std::string> dcp::TextAsset::raw_xml ( ) const
inlinevirtual
Returns
Raw XML loaded from, or written to, an on-disk asset, or boost::none if
  • this object was not created from an existing on-disk asset and has not been written to one, or
  • this asset is encrypted and no key is available.

Definition at line 132 of file text_asset.h.

◆ texts_as_xml()

void TextAsset::texts_as_xml ( xmlpp::Element *  xml_root,
int  time_code_rate,
Standard  standard 
) const
protected
Parameters
standardStandard (INTEROP or SMPTE); this is used rather than putting things in the child class because the differences between the two are fairly subtle.

Definition at line 727 of file text_asset.cc.

Member Data Documentation

◆ _fonts

std::vector<Font> dcp::TextAsset::_fonts
protected

TTF font data that we need

Definition at line 209 of file text_asset.h.

◆ _raw_xml

boost::optional<std::string> dcp::TextAsset::_raw_xml
mutableprotected

The raw XML data that we read from or wrote to our asset; useful for validation

Definition at line 212 of file text_asset.h.

◆ _texts

std::vector<std::shared_ptr<Text> > dcp::TextAsset::_texts
protected

All our texts, in no particular order

Definition at line 183 of file text_asset.h.


The documentation for this class was generated from the following files: