/* Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DCP-o-matic. If not, see . */ #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::vector subtitles, int target_height, float fade_factor, std::string font_name); std::vector render_text(std::vector, dcp::Size, dcpomatic::DCPTime, int); std::vector> bounding_box(std::vector 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; int _target_height; };