Match perfectly text layout and drawing parameters #693
o9000 mrovi9000@gmail.com
7 files changed,
22 insertions(+),
7 deletions(-)
M
src/execplugin/execplugin.c
→
src/execplugin/execplugin.c
@@ -349,6 +349,7 @@ execp->backend->text,
strlen(execp->backend->text), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, + execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT, execp->backend->has_markup, panel->scale);
M
src/taskbar/taskbar.c
→
src/taskbar/taskbar.c
@@ -343,6 +343,7 @@ "TAjpg",
5, PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_END, + panel->g_task.centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT, FALSE, panel->scale);
M
src/taskbar/taskbarname.c
→
src/taskbar/taskbarname.c
@@ -144,6 +144,7 @@ taskbar_name->name,
strlen(taskbar_name->name), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, + PANGO_ALIGN_CENTER, FALSE, panel->scale);@@ -171,6 +172,7 @@ taskbar_name->name,
strlen(taskbar_name->name), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, + PANGO_ALIGN_CENTER, FALSE, panel->scale);
M
src/util/area.c
→
src/util/area.c
@@ -947,6 +947,7 @@ line1,
strlen(line1), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, + PANGO_ALIGN_CENTER, FALSE, ((Panel*)area->panel)->scale); else@@ -962,6 +963,7 @@ line2,
strlen(line2), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, + PANGO_ALIGN_CENTER, FALSE, ((Panel*)area->panel)->scale); else
M
src/util/common.c
→
src/util/common.c
@@ -933,6 +933,7 @@ const char *text,
int text_len, PangoWrapMode wrap, PangoEllipsizeMode ellipsis, + PangoAlignment alignment, gboolean markup, double scale) {@@ -951,6 +952,7 @@ pango_cairo_context_set_resolution(context, 96 * scale);
PangoLayout *layout = pango_layout_new(context); pango_layout_set_width(layout, available_width * PANGO_SCALE); pango_layout_set_height(layout, available_height * PANGO_SCALE); + pango_layout_set_alignment(layout, alignment); pango_layout_set_wrap(layout, wrap); pango_layout_set_ellipsize(layout, ellipsis); pango_layout_set_font_description(layout, font);@@ -982,38 +984,41 @@ const char *text,
int text_len, PangoWrapMode wrap, PangoEllipsizeMode ellipsis, + PangoAlignment alignment, gboolean markup, double scale) { - get_text_size(font, height, width, available_height, available_width, text, text_len, wrap, ellipsis, markup, scale); + get_text_size(font, height, width, available_height, available_width, text, text_len, wrap, ellipsis, alignment, markup, scale); // We do multiple passes, because pango sucks int actual_height, actual_width, overflow = 0; while (true) { - get_text_size(font, &actual_height, &actual_width, *height, *width, text, text_len, wrap, ellipsis, markup, scale); + get_text_size(font, &actual_height, &actual_width, *height, *width, text, text_len, wrap, ellipsis, alignment, markup, scale); if (actual_height <= *height) break; - if (*width >= available_width + 50) + if (*width >= available_width) break; overflow = 1; - fprintf(stderr, "tint2: text overflows, recomputing: available %dx%d, computed %dx%d, actual %dx%d\n", + fprintf(stderr, "tint2: text overflows, recomputing: available %dx%d, computed %dx%d, actual %dx%d: %s\n", available_width, available_height, *width, *height, actual_width, - actual_height); + actual_height, + text); (*width)++; } if (overflow) { *height = actual_height; - fprintf(stderr, "tint2: text final size computed as: available %dx%d, computed %dx%d, actual %dx%d\n", + fprintf(stderr, "tint2: text final size computed as: available %dx%d, computed %dx%d, actual %dx%d: %s\n", available_width, available_height, *width, *height, actual_width, - actual_height); + actual_height, + text); } }
M
src/util/common.h
→
src/util/common.h
@@ -122,6 +122,7 @@ const char *text,
int text_len, PangoWrapMode wrap, PangoEllipsizeMode ellipsis, + PangoAlignment alignment, gboolean markup, double scale);