Merge branch 'show-label-dimensions' into 'main'

label: Put dimensions of text in log

See merge request plymouth/plymouth!287
This commit is contained in:
Ray Strode 2023-12-29 01:21:50 +00:00
commit 41cf8643d6
2 changed files with 18 additions and 1 deletions

View file

@ -660,9 +660,23 @@ load_glyphs (ply_label_plugin_control_t *label,
} while (true);
if (action == PLY_LOAD_GLYPH_ACTION_MEASURE) {
if (!is_first_character)
if (!is_first_character) {
char *text = NULL;
finish_measuring_line (label, &glyph_x, &glyph_y, line_dimensions);
if (ply_is_tracing ()) {
if (label->rich_text != NULL)
text = ply_rich_text_get_string (label->rich_text, &label->span);
ply_trace ("Text '%s' has dimensions %ldx%ld", text?: label->text,
line_dimensions->width,
line_dimensions->height);
free (text);
}
}
align_lines (label);
}
}

View file

@ -42,6 +42,7 @@
#include <cairo.h>
#include <pango/pangocairo.h>
#include "ply-logger.h"
#include "ply-terminal.h"
#include "ply-pixel-buffer.h"
#include "ply-pixel-display.h"
@ -338,6 +339,8 @@ size_control (ply_label_plugin_control_t *label,
pango_layout_get_pixel_size (pango_layout, &text_width, &text_height);
}
ply_trace ("Text '%s' has dimensions %dx%d", label->text, text_width, text_height);
label->area.width = text_width;
label->area.height = text_height;