mirror of https://github.com/polybar/polybar.git
refactor(cairo): Use shared_ptr for font list
This commit is contained in:
parent
e857a34f52
commit
1a5246e940
|
@ -151,9 +151,9 @@ namespace cairo {
|
||||||
|
|
||||||
// Sort the fontlist so that the
|
// Sort the fontlist so that the
|
||||||
// preferred font gets prioritized
|
// preferred font gets prioritized
|
||||||
auto& fns = m_fonts;
|
vector<shared_ptr<font>> fns(m_fonts.begin(), m_fonts.end());
|
||||||
std::sort(fns.begin(), fns.end(), [&](const unique_ptr<font>& a, const unique_ptr<font>&) {
|
std::sort(fns.begin(), fns.end(), [&](const shared_ptr<font>& a, const shared_ptr<font>&) {
|
||||||
if (t.fontindex > 0 && std::distance(fns.begin(), std::find(fns.begin(), fns.end(), a)) == t.fontindex - 1) {
|
if (t.font > 0 && std::distance(fns.begin(), std::find(fns.begin(), fns.end(), a)) == t.font - 1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -232,7 +232,7 @@ namespace cairo {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
context& operator<<(unique_ptr<font>&& f) {
|
context& operator<<(shared_ptr<font>&& f) {
|
||||||
m_fonts.emplace_back(forward<decltype(f)>(f));
|
m_fonts.emplace_back(forward<decltype(f)>(f));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ namespace cairo {
|
||||||
protected:
|
protected:
|
||||||
cairo_t* m_c;
|
cairo_t* m_c;
|
||||||
const logger& m_log;
|
const logger& m_log;
|
||||||
vector<unique_ptr<font>> m_fonts;
|
vector<shared_ptr<font>> m_fonts;
|
||||||
std::deque<pair<double, double>> m_points;
|
std::deque<pair<double, double>> m_points;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,7 @@ namespace cairo {
|
||||||
FcPatternPrint(match);
|
FcPatternPrint(match);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return make_unique<font_fc>(cairo, match, offset);
|
return make_shared<font_fc>(cairo, match, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace cairo {
|
||||||
struct textblock {
|
struct textblock {
|
||||||
alignment align;
|
alignment align;
|
||||||
string contents;
|
string contents;
|
||||||
int fontindex;
|
int font;
|
||||||
unsigned int bg;
|
unsigned int bg;
|
||||||
int bg_operator;
|
int bg_operator;
|
||||||
rect bg_rect;
|
rect bg_rect;
|
||||||
|
|
|
@ -489,7 +489,7 @@ void renderer::draw_text(const string& contents) {
|
||||||
cairo::textblock block{};
|
cairo::textblock block{};
|
||||||
block.align = m_align;
|
block.align = m_align;
|
||||||
block.contents = contents;
|
block.contents = contents;
|
||||||
block.fontindex = m_font;
|
block.font = m_font;
|
||||||
block.bg = 0;
|
block.bg = 0;
|
||||||
block.bg_rect = cairo::rect{0.0, 0.0, 0.0, 0.0};
|
block.bg_rect = cairo::rect{0.0, 0.0, 0.0, 0.0};
|
||||||
block.bg_operator = 0;
|
block.bg_operator = 0;
|
||||||
|
|
Loading…
Reference in New Issue