public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Jocelyn Falempe <jfalempe@redhat.com>,
	javierm@redhat.com, deller@gmx.de,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	airlied@gmail.com, simona@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 1/4] lib/fonts: Look up glyph data with font_data_glyph_buf()
Date: Tue, 2 Jun 2026 10:08:38 +0200	[thread overview]
Message-ID: <e45c05f9-be0e-4845-898e-5dc003387bdd@suse.de> (raw)
In-Reply-To: <db9abca9-0174-46fc-8952-aaa23a4e4574@redhat.com>

Hi

Am 01.06.26 um 13:18 schrieb Jocelyn Falempe:
> On 29/05/2026 16:01, Thomas Zimmermann wrote:
>> Add font_data_glyph_buf() to retrieve a character's glyph data or NULL
>> otherwise. Console fonts can currently contain 256 or 512 glyphs. The
>> kernel-internal characters are of type char, unsigned short or unsigned
>> int. Catch all of them by accepting unsigned int. Callers possibly have
>> to cast from signed to unsigned types to reach all glyphs in a font.
>
> Thanks, yes I missed to check font_data_num_glyphs(), and using signed 
> index is also problematic.
>
> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>

Thanks for reviewing. I'll merge the series in a few days if no other 
comments come in.

Best regards
Thomas

>
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>   include/linux/font.h |  3 +++
>>   lib/fonts/fonts.c    | 31 +++++++++++++++++++++++++++++++
>>   2 files changed, 34 insertions(+)
>>
>> diff --git a/include/linux/font.h b/include/linux/font.h
>> index 6845f02d739a..ea23b727388b 100644
>> --- a/include/linux/font.h
>> +++ b/include/linux/font.h
>> @@ -101,6 +101,9 @@ font_data_t *font_data_import(const struct 
>> console_font *font, unsigned int vpit
>>   void font_data_get(font_data_t *fd);
>>   bool font_data_put(font_data_t *fd);
>>   unsigned int font_data_size(font_data_t *fd);
>> +const unsigned char *font_data_glyph_buf(font_data_t *fd,
>> +                     unsigned int width, unsigned int vpitch,
>> +                     unsigned int c);
>>   bool font_data_is_equal(font_data_t *lhs, font_data_t *rhs);
>>   int font_data_export(font_data_t *fd, struct console_font *font, 
>> unsigned int vpitch);
>>   diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c
>> index f5d5333450a0..4fc66722d00d 100644
>> --- a/lib/fonts/fonts.c
>> +++ b/lib/fonts/fonts.c
>> @@ -178,6 +178,37 @@ unsigned int font_data_size(font_data_t *fd)
>>   }
>>   EXPORT_SYMBOL_GPL(font_data_size);
>>   +static unsigned int font_data_num_glyphs(font_data_t *fd, unsigned 
>> int width, unsigned int height)
>> +{
>> +    return font_data_size(fd) / font_glyph_size(width, height);
>> +}
>> +
>> +/**
>> + * font_data_glyph_buf() - Returns the glyph for a specific 
>> character as raw bytes
>> + * @fd: The font data
>> + * @width: The glyph width in bits per scanline
>> + * @vpitch: The number of scanlines per glyph
>> + * @c: The character
>> + *
>> + * Glyphs start at fixed intervals within the font data. 
>> font_data_glyph_buf()
>> + * returns the glyph shape of the specified character. If no such glyph
>> + * exists in the font, it returns NULL.
>> + *
>> + * Returns:
>> + * The character's raw glyph shape, or NULL if no glyph exists for 
>> the character. The
>> + * provided buffer is read-only.
>> + */
>> +const unsigned char *font_data_glyph_buf(font_data_t *fd,
>> +                     unsigned int width, unsigned int vpitch,
>> +                     unsigned int c)
>> +{
>> +    if (c >= font_data_num_glyphs(fd, width, vpitch))
>> +        return NULL;
>> +
>> +    return font_data_buf(fd) + font_glyph_size(width, vpitch) * c;
>> +}
>> +EXPORT_SYMBOL_GPL(font_data_glyph_buf);
>> +
>>   /**
>>    * font_data_is_equal - Compares font data for equality
>>    * @lhs: Left-hand side font data
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-06-02  8:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 14:01 [PATCH 0/4] drm: Safe font-data access in log/panic drawing Thomas Zimmermann
2026-05-29 14:01 ` [PATCH 1/4] lib/fonts: Look up glyph data with font_data_glyph_buf() Thomas Zimmermann
2026-06-01 11:18   ` Jocelyn Falempe
2026-06-02  8:08     ` Thomas Zimmermann [this message]
2026-06-04  6:27   ` Claude review: " Claude Code Review Bot
2026-05-29 14:01 ` [PATCH 2/4] drm/client: log: Look up glyph shape with font helper Thomas Zimmermann
2026-06-01 11:19   ` Jocelyn Falempe
2026-06-04  6:27   ` Claude review: " Claude Code Review Bot
2026-05-29 14:01 ` [PATCH 3/4] drm/panic: " Thomas Zimmermann
2026-06-01 11:19   ` Jocelyn Falempe
2026-06-04  6:27   ` Claude review: " Claude Code Review Bot
2026-05-29 14:01 ` [PATCH 4/4] drm/draw: Remove unused helper drm_draw_get_char_bitmap() Thomas Zimmermann
2026-06-01 11:19   ` Jocelyn Falempe
2026-06-04  6:27   ` Claude review: " Claude Code Review Bot
2026-06-04  6:27 ` Claude review: drm: Safe font-data access in log/panic drawing Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e45c05f9-be0e-4845-898e-5dc003387bdd@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jfalempe@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox