From aa6b89700131a0fd5245f0165a5c630d7c7a69f8 Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Tue, 4 Apr 2017 14:53:26 +0200 Subject: [PATCH] [text_producer] Removed unused member function measure_string() --- core/producer/text/text_producer.cpp | 6 --- core/producer/text/text_producer.h | 8 ++-- core/producer/text/utils/texture_font.cpp | 52 ----------------------- core/producer/text/utils/texture_font.h | 1 - modules/psd/psd_scene_producer.cpp | 1 - 5 files changed, 3 insertions(+), 65 deletions(-) diff --git a/core/producer/text/text_producer.cpp b/core/producer/text/text_producer.cpp index 3bf3a097b..dc7e0e077 100644 --- a/core/producer/text/text_producer.cpp +++ b/core/producer/text/text_producer.cpp @@ -210,11 +210,6 @@ public: frame_ = core::draw_frame(std::move(frame)); } - text::string_metrics measure_string(const std::wstring& str) - { - return font_.measure_string(str); - } - // frame_producer draw_frame receive_impl() @@ -310,7 +305,6 @@ draw_frame text_producer::receive_impl() { return impl_->receive_impl(); } std::future text_producer::call(const std::vector& param) { return impl_->call(param); } variable& text_producer::get_variable(const std::wstring& name) { return impl_->get_variable(name); } const std::vector& text_producer::get_variables() const { return impl_->get_variables(); } -text::string_metrics text_producer::measure_string(const std::wstring& str) { return impl_->measure_string(str); } constraints& text_producer::pixel_constraints() { return impl_->pixel_constraints(); } std::wstring text_producer::print() const { return impl_->print(); } diff --git a/core/producer/text/text_producer.h b/core/producer/text/text_producer.h index 05069cec5..85eeb8769 100644 --- a/core/producer/text/text_producer.h +++ b/core/producer/text/text_producer.h @@ -36,7 +36,7 @@ #include "utils/text_info.h" namespace caspar { namespace core { - namespace text + namespace text { void init(module_dependencies dependencies); std::vector> list_fonts(); @@ -45,17 +45,15 @@ namespace caspar { namespace core { class text_producer : public frame_producer_base { public: - text_producer(const spl::shared_ptr& frame_factory, int x, int y, const std::wstring& str, + text_producer(const spl::shared_ptr& frame_factory, int x, int y, const std::wstring& str, text::text_info& text_info, long parent_width, long parent_height, bool standalone); static spl::shared_ptr create(const spl::shared_ptr& frame_factory, int x, int y, const std::wstring& str, text::text_info& text_info, long parent_width, long parent_height, bool standalone = false); - + draw_frame receive_impl() override; std::future call(const std::vector& param) override; variable& get_variable(const std::wstring& name) override; const std::vector& get_variables() const override; - text::string_metrics measure_string(const std::wstring& str); - constraints& pixel_constraints() override; std::wstring print() const override; std::wstring name() const override; diff --git a/core/producer/text/utils/texture_font.cpp b/core/producer/text/utils/texture_font.cpp index 5a0421701..615865efe 100644 --- a/core/producer/text/utils/texture_font.cpp +++ b/core/producer/text/utils/texture_font.cpp @@ -221,57 +221,6 @@ public: return result; } - string_metrics measure_string(const std::wstring& str) - { - string_metrics result; - - bool use_kerning = (face_->face_flags & FT_FACE_FLAG_KERNING) == FT_FACE_FLAG_KERNING; - int index = 0; - FT_UInt previous = 0; - double pos_x = 0; -// float pos_y = 0; - - auto end = str.end(); - for(auto it = str.begin(); it != end; ++it, ++index) - { - auto glyph_it = glyphs_.find(*it); - if(glyph_it != glyphs_.end()) - { - const glyph_info& coords = glyph_it->second; - - FT_UInt glyph_index = FT_Get_Char_Index(face_.get(), (*it)); - - if(use_kerning && previous && glyph_index) - { - FT_Vector delta; - FT_Get_Kerning(face_.get(), previous, glyph_index, FT_KERNING_DEFAULT, &delta); - - pos_x += delta.x / 64.0; - } - - FT_Load_Glyph(face_.get(), glyph_index, FT_LOAD_NO_BITMAP | FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_NORMAL); - - int bearingY = face_->glyph->metrics.horiBearingY >> 6; - if(bearingY > result.bearingY) - result.bearingY = bearingY; - - int protrudeUnderY = coords.height - bearingY; - - if (protrudeUnderY > result.protrudeUnderY) - result.protrudeUnderY = protrudeUnderY; - - if (result.bearingY + result.protrudeUnderY > result.height) - result.height = result.bearingY + result.protrudeUnderY; - - pos_x += face_->glyph->advance.x / 64.0; - previous = glyph_index; - } - } - - result.width = (int)(pos_x+.5f); - return result; - } - std::wstring get_name() const { return name_; @@ -287,7 +236,6 @@ texture_font::texture_font(texture_atlas& atlas, const text_info& info, bool nor void texture_font::load_glyphs(unicode_block range, const color& col) { impl_->load_glyphs(range, col); } void texture_font::set_tracking(double tracking) { impl_->set_tracking(tracking); } std::vector texture_font::create_vertex_stream(const std::wstring& str, int x, int y, int parent_width, int parent_height, string_metrics* metrics, double shear) { return impl_->create_vertex_stream(str, x, y, parent_width, parent_height, metrics, shear); } -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(); } diff --git a/core/producer/text/utils/texture_font.h b/core/producer/text/utils/texture_font.h index 11855adfa..95f2bdf6e 100644 --- a/core/producer/text/utils/texture_font.h +++ b/core/producer/text/utils/texture_font.h @@ -24,7 +24,6 @@ public: void load_glyphs(unicode_block block, const color& col); void set_tracking(double tracking); std::vector create_vertex_stream(const std::wstring& str, int x, int y, int parent_width, int parent_height, string_metrics* metrics, double shear = 0.0); - string_metrics measure_string(const std::wstring& str); std::wstring get_name() const; double get_size() const; diff --git a/modules/psd/psd_scene_producer.cpp b/modules/psd/psd_scene_producer.cpp index fb075ff9e..c9f8325f7 100644 --- a/modules/psd/psd_scene_producer.cpp +++ b/modules/psd/psd_scene_producer.cpp @@ -451,7 +451,6 @@ spl::shared_ptr create_psd_scene_producer(const core::fram auto text_producer = core::text_producer::create(dependencies.frame_factory, 0, 0, str, text_info, doc.width(), doc.height()); //text_producer->pixel_constraints().width.set(psd_layer->size().width); //text_producer->pixel_constraints().height.set(psd_layer->size().height); - core::text::string_metrics metrics = text_producer->measure_string(str); layer_producer = text_producer; scene_layer = ¤t.scene()->create_layer(spl::make_shared_ptr(layer_producer), static_cast(psd_layer->text_pos().x), static_cast(psd_layer->text_pos().y), layer_name); -- 2.39.2