Prevent writing outside of key without ellipsize

This commit is contained in:
Willow Barraco
2023-08-31 22:03:51 +02:00
parent 8f7142b171
commit 4444c6e664
2 changed files with 12 additions and 2 deletions

10
drw.c
View File

@ -47,9 +47,15 @@ drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
// if a word is too long, cairo let it, and ignore our width
if (width < (w - (b*2))) {
cairo_rel_move_to(d->cairo, - width / 2, - height / 2);
cairo_rel_move_to(d->cairo, - width / 2, 0);
} else {
cairo_rel_move_to(d->cairo, - w / 2 + b, - height / 2);
cairo_rel_move_to(d->cairo, - w / 2 + b, 0);
}
if (height < (h - (b*2))) {
cairo_rel_move_to(d->cairo, 0, - height / 2);
} else {
cairo_rel_move_to(d->cairo, 0, - h / 2);
}
pango_cairo_show_layout(d->cairo, d->layout);