diff --git a/include/cairo/context.hpp b/include/cairo/context.hpp index 591b4895..c80e8e5f 100644 --- a/include/cairo/context.hpp +++ b/include/cairo/context.hpp @@ -151,9 +151,9 @@ namespace cairo { // Sort the fontlist so that the // preferred font gets prioritized - auto& fns = m_fonts; - std::sort(fns.begin(), fns.end(), [&](const unique_ptr& a, const unique_ptr&) { - if (t.fontindex > 0 && std::distance(fns.begin(), std::find(fns.begin(), fns.end(), a)) == t.fontindex - 1) { + vector> fns(m_fonts.begin(), m_fonts.end()); + std::sort(fns.begin(), fns.end(), [&](const shared_ptr& a, const shared_ptr&) { + if (t.font > 0 && std::distance(fns.begin(), std::find(fns.begin(), fns.end(), a)) == t.font - 1) { return -1; } else { return 0; @@ -232,7 +232,7 @@ namespace cairo { return *this; } - context& operator<<(unique_ptr&& f) { + context& operator<<(shared_ptr&& f) { m_fonts.emplace_back(forward(f)); return *this; } @@ -315,7 +315,7 @@ namespace cairo { protected: cairo_t* m_c; const logger& m_log; - vector> m_fonts; + vector> m_fonts; std::deque> m_points; }; } diff --git a/include/cairo/font.hpp b/include/cairo/font.hpp index 499eafe7..5c1e0755 100644 --- a/include/cairo/font.hpp +++ b/include/cairo/font.hpp @@ -263,7 +263,7 @@ namespace cairo { FcPatternPrint(match); #endif - return make_unique(cairo, match, offset); + return make_shared(cairo, match, offset); } } diff --git a/include/cairo/types.hpp b/include/cairo/types.hpp index 39d92381..dda2e563 100644 --- a/include/cairo/types.hpp +++ b/include/cairo/types.hpp @@ -58,7 +58,7 @@ namespace cairo { struct textblock { alignment align; string contents; - int fontindex; + int font; unsigned int bg; int bg_operator; rect bg_rect; diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp index 0752fbdb..620a99f8 100644 --- a/src/components/renderer.cpp +++ b/src/components/renderer.cpp @@ -489,7 +489,7 @@ void renderer::draw_text(const string& contents) { cairo::textblock block{}; block.align = m_align; block.contents = contents; - block.fontindex = m_font; + block.font = m_font; block.bg = 0; block.bg_rect = cairo::rect{0.0, 0.0, 0.0, 0.0}; block.bg_operator = 0;