1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-18 13:55:11 -05:00

fix(cairo): Use font metrics as vertical baseline

Refs #372
This commit is contained in:
Michael Carlberg 2017-01-25 04:40:58 +01:00
parent 1a25be374f
commit d2eeac9b22

View file

@ -186,7 +186,7 @@ namespace cairo {
cairo_text_extents_t extents; cairo_text_extents_t extents;
f->textwidth(subset, &extents); f->textwidth(subset, &extents);
save(true); save();
{ {
*this << t.bg; *this << t.bg;
cairo_set_operator(m_c, static_cast<cairo_operator_t>(t.bg_operator)); cairo_set_operator(m_c, static_cast<cairo_operator_t>(t.bg_operator));
@ -194,11 +194,11 @@ namespace cairo {
t.bg_rect.w + extents.x_advance, t.bg_rect.h); t.bg_rect.w + extents.x_advance, t.bg_rect.h);
cairo_fill(m_c); cairo_fill(m_c);
} }
restore(true); restore();
// Render subset // Render subset
auto fontextents = f->extents(); auto fontextents = f->extents();
f->render(subset, x, y - (extents.height / 2.0 + extents.y_bearing + fontextents.descent) + f->offset()); f->render(subset, x, y - (fontextents.descent / 2 - fontextents.height / 4) + f->offset());
// Get updated position // Get updated position
position(&x, nullptr); position(&x, nullptr);