]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
console: Correct truetype spacing error
authorSimon Glass <sjg@chromium.org>
Thu, 1 Jun 2023 16:22:36 +0000 (10:22 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 14 Jul 2023 16:54:51 +0000 (12:54 -0400)
The putc_xy() method is supposed to return the amount of space used. The
existing implementation erroneously adds the previous sub-pixel position
to the returned value. This spaces out the characters very slightly more
than it should. It is seldom noticeable but it does make accurate
measurement of the text impossible.

Fix this minor but long-standing bug.

Fixes: a29b012037c ("video: Add a console driver that uses TrueType fonts")
Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/video/console_truetype.c
test/dm/video.c

index 63d7557c71a085f4fbf294c7b861699442d9cb2d..6f3fc82f9b05682909b0ccba71df5e828f4e645c 100644 (file)
@@ -256,7 +256,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
         */
        x_shift = xpos - (double)tt_floor(xpos);
        xpos += advance * met->scale;
-       width_frac = (int)VID_TO_POS(xpos);
+       width_frac = (int)VID_TO_POS(advance * met->scale);
        if (x + width_frac >= vc_priv->xsize_frac)
                return -EAGAIN;
 
index 30778157d9406aff63125018c98395473c2ea561..6d9c55c1403535bab9028ecde2c3f03c110a3d3c 100644 (file)
@@ -556,7 +556,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts)
        ut_assertok(video_get_nologo(uts, &dev));
        ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
        vidconsole_put_string(con, test_string);
-       ut_asserteq(12237, compress_frame_buffer(uts, dev));
+       ut_asserteq(12187, compress_frame_buffer(uts, dev));
 
        return 0;
 }
@@ -577,7 +577,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
        ut_assertok(video_get_nologo(uts, &dev));
        ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
        vidconsole_put_string(con, test_string);
-       ut_asserteq(35030, compress_frame_buffer(uts, dev));
+       ut_asserteq(34481, compress_frame_buffer(uts, dev));
 
        return 0;
 }
@@ -598,7 +598,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
        ut_assertok(video_get_nologo(uts, &dev));
        ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
        vidconsole_put_string(con, test_string);
-       ut_asserteq(29018, compress_frame_buffer(uts, dev));
+       ut_asserteq(29579, compress_frame_buffer(uts, dev));
 
        return 0;
 }