X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Frender_text.h;h=762d794466e9747984dbf3be5d6e11ea153c9b15;hp=f235fb45971d69241c1abea7212b31feb095475d;hb=323b8cbb0b95297fbd027ffdc4ea5003b59ef25f;hpb=c4403784febdbdd42e9c32e67fadb147f11fe566 diff --git a/src/lib/render_text.h b/src/lib/render_text.h index f235fb459..762d79446 100644 --- a/src/lib/render_text.h +++ b/src/lib/render_text.h @@ -18,14 +18,55 @@ */ + #include "position_image.h" #include "dcpomatic_time.h" #include "string_text.h" #include +#include + + +namespace dcpomatic { + class Font; +} + + +std::string marked_up (std::list subtitles, int target_height, float fade_factor, std::string font_name); +std::list render_text (std::list, dcp::Size, dcpomatic::DCPTime, int); + + +class FontMetrics +{ +public: + FontMetrics(int target_height) + : _target_height(target_height) + {} + + float baseline_to_bottom(StringText const& subtitle); + float height(StringText const& subtitle); + +private: + /** Class to collect the properties of a subtitle which affect the metrics we care about + * i.e. baseline position and height. + */ + class Identifier + { + public: + Identifier(StringText const& subtitle); + + std::shared_ptr font; + int size; + float aspect_adjust; + + bool operator<(Identifier const& other) const; + }; + + using Cache = std::map>; + + Cache::iterator get(StringText const& subtitle); + + Cache _cache; -class Font; + int _target_height; +}; -std::string marked_up (std::list subtitles, int target_height, float fade_factor); -std::list render_text ( - std::list, std::list > fonts, dcp::Size, dcpomatic::DCPTime, int - );