* [PATCH] lib/fonts: Fix bit position when rotating by 180 degrees
@ 2026-04-28 8:28 Thomas Zimmermann
2026-04-28 12:19 ` Helge Deller
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Zimmermann @ 2026-04-28 8:28 UTC (permalink / raw)
To: deller; +Cc: dri-devel, linux-fbdev, Thomas Zimmermann
Fix the horizontal bit position when rotating a glyph by 180°. The
original code in rotate_ud() rounded the value in width up to a
multiple of 8, aka the bit pitch, and calculated the rotated pixel
from that value. The new code stores the glyph's pitch in bit_pitch,
but fails to update the rotated pixel's output accordingly. Simply
replacing the variable does this.
The bug can be reproduced by setting a font with an unaligned width,
such as sun12x22, like this:
setfont sun12x22
echo 2 > /sys/class/graphics/fbcon/rotate
Without the fix, the font looks distorted.
Fixes: a30e9e6b018f ("lib/fonts: Refactor glyph-rotation helpers")
Closes: https://lore.gitlab.freedesktop.org/drm-ai-reviews/review-patch7-20260407092555.58816-8-tzimmermann@suse.de/
Cc: dri-devel@lists.freedesktop.org
Cc: linux-fbdev@vger.kernel.org
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
lib/fonts/font_rotate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fonts/font_rotate.c b/lib/fonts/font_rotate.c
index 065e0fc0667b..275406008823 100644
--- a/lib/fonts/font_rotate.c
+++ b/lib/fonts/font_rotate.c
@@ -106,7 +106,7 @@ static void __font_glyph_rotate_180(const unsigned char *glyph,
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (font_glyph_test_bit(glyph, x, y, bit_pitch)) {
- font_glyph_set_bit(out, width - (1 + x + shift), height - (1 + y),
+ font_glyph_set_bit(out, bit_pitch - 1 - x - shift, height - 1 - y,
bit_pitch);
}
}
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] lib/fonts: Fix bit position when rotating by 180 degrees
2026-04-28 8:28 [PATCH] lib/fonts: Fix bit position when rotating by 180 degrees Thomas Zimmermann
@ 2026-04-28 12:19 ` Helge Deller
0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2026-04-28 12:19 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, linux-fbdev
On 4/28/26 10:28, Thomas Zimmermann wrote:
> Fix the horizontal bit position when rotating a glyph by 180°. The
> original code in rotate_ud() rounded the value in width up to a
> multiple of 8, aka the bit pitch, and calculated the rotated pixel
> from that value. The new code stores the glyph's pitch in bit_pitch,
> but fails to update the rotated pixel's output accordingly. Simply
> replacing the variable does this.
>
> The bug can be reproduced by setting a font with an unaligned width,
> such as sun12x22, like this:
>
> setfont sun12x22
> echo 2 > /sys/class/graphics/fbcon/rotate
>
> Without the fix, the font looks distorted.
>
> Fixes: a30e9e6b018f ("lib/fonts: Refactor glyph-rotation helpers")
> Closes: https://lore.gitlab.freedesktop.org/drm-ai-reviews/review-patch7-20260407092555.58816-8-tzimmermann@suse.de/
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-fbdev@vger.kernel.org
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> lib/fonts/font_rotate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
applied.
Thanks!
Helge
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-28 12:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-28 8:28 [PATCH] lib/fonts: Fix bit position when rotating by 180 degrees Thomas Zimmermann
2026-04-28 12:19 ` Helge Deller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox