summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <halfline@gmail.com>2024-01-04 21:08:14 +0000
committerRay Strode <halfline@gmail.com>2024-01-04 21:08:14 +0000
commitd6e6366d622962dce02d8c7e4ab814f54a202509 (patch)
treee96c8c3ab53e86c0638630bc95d1c032851df9be
parent2dba038dd7a26691c80a67a13bf95f7fd04ef2f6 (diff)
parent345d28b3cbb898bcadfb430eeb58f3c2896a6648 (diff)
Merge branch 'fix-hidpi-on-freetype' into 'main'24.004.60
label-freetype: Fix rowstride bug with hidpi displays See merge request plymouth/plymouth!297
-rw-r--r--src/plugins/controls/label-freetype/plugin.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/plugins/controls/label-freetype/plugin.c b/src/plugins/controls/label-freetype/plugin.c
index fc4446e0..917b04c0 100644
--- a/src/plugins/controls/label-freetype/plugin.c
+++ b/src/plugins/controls/label-freetype/plugin.c
@@ -429,13 +429,13 @@ finish_measuring_line (ply_label_plugin_control_t *label,
line_height.as_integer = label->face->size->metrics.ascender + -label->face->size->metrics.descender;
- dimensions->x = label->area.x;
+ dimensions->x = label->area.x * label->scale_factor;
dimensions->width = glyph_x->as_pixels_unit.pixels - dimensions->x;
- label->area.width = MAX (label->area.width, dimensions->width);
+ label->area.width = MAX (label->area.width, dimensions->width / label->scale_factor);
dimensions->height = line_height.as_pixels_unit.pixels;
- label->area.height += dimensions->height;
+ label->area.height += dimensions->height / label->scale_factor;
entry = calloc (1, sizeof(ply_rectangle_t));
*entry = *dimensions;
@@ -459,6 +459,7 @@ align_lines (ply_label_plugin_control_t *label)
return;
width = label->width > 0? label->width : label->area.width;
+ width *= label->scale_factor;
dimensions_of_lines = (ply_rectangle_t **) ply_array_get_pointer_elements (label->dimensions_of_lines);
@@ -482,8 +483,8 @@ load_glyphs (ply_label_plugin_control_t *label,
ply_utf8_string_iterator_t utf8_string_iterator;
uint32_t *target = NULL;
ply_rectangle_t target_size;
- ply_freetype_unit_t glyph_x = { .as_pixels_unit = { .pixels = label->area.x } };
- ply_freetype_unit_t glyph_y = { .as_pixels_unit = { .pixels = label->area.y } };
+ ply_freetype_unit_t glyph_x = { .as_pixels_unit = { .pixels = label->area.x * label->scale_factor } };
+ ply_freetype_unit_t glyph_y = { .as_pixels_unit = { .pixels = label->area.y * label->scale_factor } };
FT_Error error;
FT_UInt previous_glyph_index = 0;
bool is_first_character = true;
@@ -510,8 +511,8 @@ load_glyphs (ply_label_plugin_control_t *label,
clear_dimensions_of_lines (label);
line_dimensions = alloca (sizeof(ply_rectangle_t));
- line_dimensions->x = label->area.x;
- line_dimensions->y = label->area.y;
+ line_dimensions->x = label->area.x * label->scale_factor;
+ line_dimensions->y = label->area.y * label->scale_factor;
line_dimensions->width = 0;
line_dimensions->height = 0;
label->area.width = 0;
@@ -535,6 +536,9 @@ load_glyphs (ply_label_plugin_control_t *label,
if (target_size.height == 0)
return;
+
+ target_size.width *= label->scale_factor;
+ target_size.height *= label->scale_factor;
}
/* Go through each line */
@@ -850,15 +854,19 @@ show_control (ply_label_plugin_control_t *label,
long y)
{
ply_rectangle_t dirty_area;
+ bool force_resize = false;
dirty_area = label->area;
label->display = display;
- label->area.x = x;
- label->area.y = y;
+ if (label->area.x != x || label->area.y != y) {
+ label->area.x = x;
+ label->area.y = y;
+ force_resize = true;
+ }
label->is_hidden = false;
- size_control (label, false);
+ size_control (label, force_resize);
if (!label->is_hidden && label->display != NULL)
ply_pixel_display_draw_area (label->display,