<ClInclude Include="producer\text\utils\string_metrics.h" />\r
<ClInclude Include="producer\text\utils\texture_atlas.h" />\r
<ClInclude Include="producer\text\utils\texture_font.h" />\r
+ <ClInclude Include="producer\text\utils\text_info.h" />\r
<ClInclude Include="producer\variable.h" />\r
<ClInclude Include="video_channel.h" />\r
<ClInclude Include="consumer\output.h" />\r
<ClInclude Include="producer\variable.h">\r
<Filter>source\producer</Filter>\r
</ClInclude>\r
+ <ClInclude Include="producer\text\utils\text_info.h">\r
+ <Filter>source\producer\text\utils</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="producer\transition\transition_producer.cpp">\r
register_producer_factory(&create_text_producer);
}
- std::wstring find_font_file(const std::wstring& font_name)
+ text_info& find_font_file(text_info& info)
{
+ auto& font_name = info.font;
auto it = std::find_if(fonts.begin(), fonts.end(), font_comparer(font_name));
- return (it != fonts.end()) ? (*it).second : L"";
+ info.font_file = (it != fonts.end()) ? (*it).second : L"";
+ return info;
}
}
text::texture_font font_;
public:
- explicit impl(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, const text::text_info& text_info, long parent_width, long parent_height, bool standalone)
+ explicit impl(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, text::text_info& text_info, long parent_width, long parent_height, bool standalone)
: frame_factory_(frame_factory)
, constraints_(parent_width, parent_height)
, x_(x), y_(y), parent_width_(parent_width), parent_height_(parent_height)
, standalone_(standalone)
, atlas_(512,512,4)
- , font_(atlas_, text::find_font_file(text_info.font), text_info.size, !standalone)
+ , font_(atlas_, text::find_font_file(text_info), !standalone)
{
//TODO: examine str to determine which unicode_blocks to load
font_.load_glyphs(text::Basic_Latin, text_info.color);
}
};
-text_producer::text_producer(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, const text::text_info& text_info, long parent_width, long parent_height, bool standalone)
+text_producer::text_producer(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, text::text_info& text_info, long parent_width, long parent_height, bool standalone)
: impl_(new impl(frame_factory, x, y, str, text_info, parent_width, parent_height, standalone))
{}
const binding<int>& text_producer::current_bearing_y() const { return impl_->current_bearing_y(); }
const binding<int>& text_producer::current_protrude_under_y() const { return impl_->current_protrude_under_y(); }
-spl::shared_ptr<text_producer> text_producer::create(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, const text::text_info& text_info, long parent_width, long parent_height, bool standalone)
+spl::shared_ptr<text_producer> text_producer::create(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, text::text_info& text_info, long parent_width, long parent_height, bool standalone)
{
return spl::make_shared<text_producer>(frame_factory, x, y, str, text_info, parent_width, parent_height, standalone);
}
#include "utils/color.h"
#include "utils/string_metrics.h"
+#include "utils/text_info.h"
namespace caspar { namespace core {
namespace text
{
void init();
-
- struct text_info
- {
- std::wstring font;
- float size;
- color<float> color;
- int baseline_shift;
- int tracking;
- };
}
class text_producer : public frame_producer_base
{
public:
- text_producer(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, const text::text_info& text_info, long parent_width, long parent_height, bool standalone);
- static spl::shared_ptr<text_producer> create(const spl::shared_ptr<class frame_factory>& frame_factory, int x, int y, const std::wstring& str, const text::text_info& text_info, long parent_width, long parent_height, bool standalone = false);
+ text_producer(const spl::shared_ptr<frame_factory>& 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<text_producer> create(const spl::shared_ptr<class frame_factory>& 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;
boost::unique_future<std::wstring> call(const std::vector<std::wstring>& param) override;
--- /dev/null
+#pragma once
+
+#include <string>
+#include "color.h"
+
+namespace caspar { namespace core { namespace text {
+
+ struct text_info
+ {
+ std::wstring font;
+ std::wstring font_file;
+
+ float size;
+ color<float> color;
+ int baseline_shift;
+ int tracking;
+ };
+
+}}}
\ No newline at end of file
FT_Face face_;
texture_atlas atlas_;
float size_;
+ float tracking_;
bool normalize_;
std::map<int, glyph_info> glyphs_;
public:
- impl::impl(texture_atlas& atlas, const std::wstring& filename, float size, bool normalize_coordinates) : lib_(nullptr), face_(nullptr), atlas_(atlas), size_(size), normalize_(normalize_coordinates)
+ impl::impl(texture_atlas& atlas, const text_info& info, bool normalize_coordinates) : lib_(nullptr), face_(nullptr), atlas_(atlas), size_(info.size), tracking_(info.size*info.tracking/1000.0f), normalize_(normalize_coordinates)
{
try
{
err = FT_Init_FreeType(&lib_);
if(err) throw freetype_exception("Failed to initialize freetype");
- err = FT_New_Face(lib_, u8(filename).c_str(), 0, &face_);
+ err = FT_New_Face(lib_, u8(info.font_file).c_str(), 0, &face_);
if(err) throw freetype_exception("Failed to load font");
- err = FT_Set_Char_Size(face_, (FT_F26Dot6)(size*64), 0, 72, 72);
+ err = FT_Set_Char_Size(face_, static_cast<FT_F26Dot6>(size_*64), 0, 72, 72);
if(err) throw freetype_exception("Failed to set font size");
}
catch(std::exception& ex)
maxHeight = maxBearingY + maxProtrudeUnderY;
pos_x += face_->glyph->advance.x / 64.0f;
+ pos_x += tracking_;
previous = glyph_index;
}
else
}
};
-texture_font::texture_font(texture_atlas& atlas, const std::wstring& filename, float size, bool normalize_coordinates) : impl_(new impl(atlas, filename, size, normalize_coordinates)) {}
+texture_font::texture_font(texture_atlas& atlas, const text_info& info, bool normalize_coordinates) : impl_(new impl(atlas, info, normalize_coordinates)) {}
void texture_font::load_glyphs(unicode_block range, const color<float>& col) { impl_->load_glyphs(range, col); }
std::vector<float> 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); }
#include <common/memory.h>
#include "string_metrics.h"
+#include "text_info.h"
namespace caspar { namespace core { namespace text {
const texture_font& operator=(const texture_font&);
public:
- texture_font(texture_atlas&, const std::wstring& filename, float size, bool normalize_coordinates);
+ texture_font(texture_atlas&, const text_info&, bool normalize_coordinates);
void load_glyphs(unicode_block block, const color<float>& col);
std::vector<float> 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);
{
if((*it)->is_visible())
{
- if((*it)->is_text())
+ if((*it)->is_text() && (*it)->sheet_color() == 4)
{
std::wstring str = (*it)->text_data().get(L"EngineDict.Editor.Text", L"");