]> git.sesse.net Git - casparcg/commitdiff
* Added font and font size to info() in text_producer
authorHelge Norberg <helge.norberg@svt.se>
Wed, 28 Oct 2015 17:03:57 +0000 (18:03 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Wed, 28 Oct 2015 17:03:57 +0000 (18:03 +0100)
core/producer/text/text_producer.cpp
core/producer/text/utils/texture_font.cpp
core/producer/text/utils/texture_font.h

index 23076a4e5e233eda5e247b9b519f5e02865a855e..ff3f2913e3f70142c6bce7dc60360ace1a7cca91 100644 (file)
@@ -285,6 +285,8 @@ public:
                boost::property_tree::wptree info;
                info.add(L"type", L"text");
                info.add(L"text", text_.value().get());
+               info.add(L"font", font_.get_name());
+               info.add(L"size", font_.get_size());
                return info;
        }
 };
index 9c07f6c0c9a256f258cd7f046b32d9fa53622d4a..879f3bfda3c3137b591d28523b52fca73610135c 100644 (file)
@@ -42,6 +42,7 @@ private:
        double                                                  tracking_;
        bool                                                    normalize_;
        std::map<int, glyph_info>               glyphs_;
+       std::wstring                                    name_;
 
 public:
        impl(texture_atlas& atlas, const text_info& info, bool normalize_coordinates)
@@ -50,6 +51,7 @@ public:
                , size_(info.size)
                , tracking_(info.size*info.tracking/1000.0)
                , normalize_(normalize_coordinates)
+               , name_(info.font)
        {
                if (FT_Set_Char_Size(face_.get(), static_cast<FT_F26Dot6>(size_*64), 0, 72, 72))
                        CASPAR_THROW_EXCEPTION(freetype_exception() << msg_info("Failed to set font size"));
@@ -269,6 +271,16 @@ public:
                result.width = (int)(pos_x+.5f);
                return result;
        }
+
+       std::wstring get_name() const
+       {
+               return name_;
+       }
+
+       double get_size() const
+       {
+               return size_;
+       }
 }; 
 
 texture_font::texture_font(texture_atlas& atlas, const text_info& info, bool normalize_coordinates) : impl_(new impl(atlas, info, normalize_coordinates)) {}
@@ -276,6 +288,8 @@ void texture_font::load_glyphs(unicode_block range, const color<double>& col) {
 void texture_font::set_tracking(int tracking) { impl_->set_tracking(tracking); }
 std::vector<frame_geometry::coord> texture_font::create_vertex_stream(const std::wstring& str, int x, int y, int parent_width, int parent_height, string_metrics* metrics) { return impl_->create_vertex_stream(str, x, y, parent_width, parent_height, metrics); }
 string_metrics texture_font::measure_string(const std::wstring& str) { return impl_->measure_string(str); }
+std::wstring texture_font::get_name() const { return impl_->get_name(); }
+double texture_font::get_size() const { return impl_->get_size(); }
 
 unicode_range get_range(unicode_block block)
 {
index a143eef05aa95151c6614ef22f3295adc3973a73..8adb06c117cf22c88b20e0147f91d54ff437e0dc 100644 (file)
@@ -25,6 +25,8 @@ public:
        void set_tracking(int tracking);
        std::vector<frame_geometry::coord> create_vertex_stream(const std::wstring& str, int x, int y, int parent_width, int parent_height, string_metrics* metrics);
        string_metrics measure_string(const std::wstring& str);
+       std::wstring get_name() const;
+       double get_size() const;
 
 private:
        struct impl;