]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
plugins: label-freetype: Fix font alignment
authorAlfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com>
Thu, 20 Oct 2022 10:37:14 +0000 (11:37 +0100)
committerAlfonso Sánchez-Beato <alfonso.sanchez-beato@canonical.com>
Thu, 20 Oct 2022 10:37:14 +0000 (11:37 +0100)
label->width is used to calculate wrapping of lines and it is by
default -1. We need to use label->area.width instead when aligning a
line, as label->width might not have been set.

src/plugins/controls/label-freetype/plugin.c

index bb29fc4cbdce884ba6d96bd81e8038a0d7eba23b..ee66f46a399cd279fee265aa0ebe2507b6f1dd3f 100644 (file)
@@ -314,9 +314,9 @@ draw_control (ply_label_plugin_control_t *label,
 
                 /* Start at start position (alignment) */
                 if (label->alignment == PLY_LABEL_ALIGN_CENTER)
-                        pen.x += (label->width - width_of_line (label, cur_c)) << 5;
+                        pen.x += (label->area.width - width_of_line (label, cur_c)) << 5;
                 else if (label->alignment == PLY_LABEL_ALIGN_RIGHT)
-                        pen.x += (label->width - width_of_line (label, cur_c)) << 6;
+                        pen.x += (label->area.width - width_of_line (label, cur_c)) << 6;
 
                 while (*cur_c && *cur_c != '\n') {
                         /* TODO: Unicode support. */