X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Frender_text.h;h=6d20912a278771981dd2f9299b26c4ee354fd096;hb=e7d8a70a16f972de2861bb1464dec6df3d26c579;hp=f235fb45971d69241c1abea7212b31feb095475d;hpb=c4403784febdbdd42e9c32e67fadb147f11fe566;p=dcpomatic.git diff --git a/src/lib/render_text.h b/src/lib/render_text.h index f235fb459..6d20912a2 100644 --- a/src/lib/render_text.h +++ b/src/lib/render_text.h @@ -18,14 +18,57 @@ */ -#include "position_image.h" + #include "dcpomatic_time.h" +#include "position_image.h" +#include "rect.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); +std::list> bounding_box(std::list subtitles, dcp::Size target, boost::optional override_standard = boost::none); + + +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 - );