| cfa72955 | 07-Apr-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Implement font rotation
Move the core of fbcon's font-rotation code to the font library as the new helper font_data_rotate(). The code can rotate in steps of 90°. For completeness, it als
lib/fonts: Implement font rotation
Move the core of fbcon's font-rotation code to the font library as the new helper font_data_rotate(). The code can rotate in steps of 90°. For completeness, it also copies the glyph data for multiples of 360°.
Bring back the memset optimization. A memset to 0 again clears the whole glyph output buffer. Then use the internal rotation helpers on the cleared output. Fbcon's original implementation worked like this, but lost it during refactoring.
Replace fbcon's font-rotation code with the new implementations. All that's left to do for fbcon is to maintain its internal fbcon state.
v2: - fix typos
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| a30e9e6b | 07-Apr-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Refactor glyph-rotation helpers
Change the signatures of the glyph-rotation helpers to match their public interfaces. Drop the inline qualifier.
Rename several variables to better match
lib/fonts: Refactor glyph-rotation helpers
Change the signatures of the glyph-rotation helpers to match their public interfaces. Drop the inline qualifier.
Rename several variables to better match their meaning. Especially rename variables to bit_pitch (or a variant thereof) if they store a pitch value in bits per scanline. The original code is fairly confusing about this. Move the calculation of the bit pitch into the new helper font_glyph_bit_pitch().
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| 6ad4ed84 | 07-Apr-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Refactor glyph-pattern helpers
Change the signatures of the pattern helpers to align them with other font-glyph helpers: use the font_glyph_ prefix and pass the glyph buffer first.
Calcu
lib/fonts: Refactor glyph-pattern helpers
Change the signatures of the pattern helpers to align them with other font-glyph helpers: use the font_glyph_ prefix and pass the glyph buffer first.
Calculating the position of the involved bit is somewhat obfuscated in the original implementation. Move it into the new helper __font_glyph_pos() and use the result as array index and bit position.
Note that these bit helpers use a bit pitch, while other code uses a byte pitch. This is intentional and required here.
v2: - fix typos in commit message
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| bdfd9432 | 07-Apr-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Implement glyph rotation
Move the glyph rotation helpers from fbcon to the font library. Wrap them behind clean interfaces. Also clear the output memory to zero. Previously, the implement
lib/fonts: Implement glyph rotation
Move the glyph rotation helpers from fbcon to the font library. Wrap them behind clean interfaces. Also clear the output memory to zero. Previously, the implementation relied on the caller to do that.
Go through the fbcon code and callers of the glyph-rotation helpers. In addition to the font rotation, there's also the cursor code, which uses the rotation helpers.
The font-rotation relied on a single memset to zero for the whole font. This is now multiple memsets on each glyph. This will be sorted out when the font library also implements font rotation.
Building glyph rotation in the font library still depends on CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y. If we get more users of the code, we can still add a dedicated Kconfig symbol to the font library.
No changes have been made to the actual implementation of the rotate_*() and pattern_*() functions. These will be refactored as separate changes.
v2: - fix typos
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| de0b375b | 07-Apr-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Clean up Makefile
Simplify the Makefile. Drop font-obj-y and sort the fonts by dictionary order. Done in preparation for supporting optional font rotation.
v2: - sort Makefile font entri
lib/fonts: Clean up Makefile
Simplify the Makefile. Drop font-obj-y and sort the fonts by dictionary order. Done in preparation for supporting optional font rotation.
v2: - sort Makefile font entries by Family/Size in ascending order (Geert, Jiri)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| db65872b | 09-Mar-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Remove internal symbols and macros from public header file
Define access macros for font_data_t in fonts.c. Define struct font_data and declare most of the font symbols in the internal he
lib/fonts: Remove internal symbols and macros from public header file
Define access macros for font_data_t in fonts.c. Define struct font_data and declare most of the font symbols in the internal header font.h, where they can only be seen by the font code.
Also move font indices into internal font.h. They appear to be unused though. There is m86k assembly code that operates on the idx field, so leave them in place for now.
List all built-in fonts in a separate section in the public header file.
v2: - do not add config guards around font symbols (Helge) - keep declaration of built-in fonts in public header
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| c37bd7c8 | 09-Mar-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Store font data for user space with font_data_export()
Add font_data_export() and update consoles to use it.
The helper font_data_export() is based on code in fbcon_get_font(). It extend
lib/fonts: Store font data for user space with font_data_export()
Add font_data_export() and update consoles to use it.
The helper font_data_export() is based on code in fbcon_get_font(). It extends the size of a single glyph to match the requested vpitch, which us usually 32 bytes for fonts from user space. Internal fonts have a pitch according to the glyph's height.
The implementation of font_data_export() differs in several ways from the original code. The original implementation distinguished between different pitches of the font data. This is not necessary as the pitch is a parameter in the copying.
There was also special handling for a font pitch of 3 bytes, which got expanded to 4 bytes (with trailing bits on each scanline). The logic originated from long before git history exists even in the historical tree. So it is not clear why this was implemented. It is not what user space expects. The setfont utitlity loads font with 3-bytes pitches and expects to read such fonts with a 3-byte pitch. For any font width, the font pitch is always the width extended to the next multiple of 8. See [1] for the user-space font-reading code.
With the changes to handling the font pitches, font_data_export() replaces the original code's various special cases with a single copying logic.
v3: - fix typos (Helge)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://github.com/legionus/kbd/blob/v2.9.0/src/libkfont/kdfontop.c#L73 # [1] Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| 514d0de7 | 09-Mar-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Create font_data_t from struct console_font with font_data_import()
Add font_data_import() and update consoles to use it.
The implementation of font_data_import() is based on code from f
lib/fonts: Create font_data_t from struct console_font with font_data_import()
Add font_data_import() and update consoles to use it.
The implementation of font_data_import() is based on code from fbcon, which supports overflow checks and crc32 checksums. Fbcon uses the crc32 checksum.
Newport_con now implements the same overflow checks as fbcon. As before, this console does not support checksums, which are optional. Newport_con can now also handle input font data with a vertical pitch other than 32 bytes. (The vertical pitch is the offset between two glyphs in the font data.)
As an internal change, remove the const qualifier from the data field if struct font_data. This allows font_data_import() to write the data without type casting. For all users of the font data via font_data_t, the stored data is still read only.
v3: - fix typos
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| 1e3c49aa | 09-Mar-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Compare font data for equality with font_data_is_equal()
Add font_data_is_equal() and update consoles to use it.
Font data is equal if it has the same size and contains the same values o
lib/fonts: Compare font data for equality with font_data_is_equal()
Add font_data_is_equal() and update consoles to use it.
Font data is equal if it has the same size and contains the same values on all bytes. Only fbcon uses a crc32 checksum. If set in both operands the checksums have to be equal.
The new helper also guarantees to not compare internal fonts against fonts from user space. Internal fonts cannot be ref-counted, so making them equal to user-space fonts with the same byte sequence results in undefined behavior.
The test only compares data buffers. Their interpretation is up each console. Therefore remove a width test in fbcon_set_font().
v3: - rebase onto font_data_{get,put}()
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|
| 1de371b1 | 09-Mar-2026 |
Thomas Zimmermann <tzimmermann@suse.de> |
lib/fonts: Manage font-data lifetime with font_data_get/_put()
Add font_data_get() and font_data_put(). Update consoles to use them over REFCOUNT() and plain kfree().
Newly allocated font data star
lib/fonts: Manage font-data lifetime with font_data_get/_put()
Add font_data_get() and font_data_put(). Update consoles to use them over REFCOUNT() and plain kfree().
Newly allocated font data starts with a reference count of 1. Loading the font puts the previously loaded font. If the reference count reaches zero, font_data_put() frees the font data.
The kernel stores a refcount of zero for internal font data. Invoking font_data_get() and font_data_put() tests this internally and returns success without further operation. From the caller's perspective, getting and putting works the same for all font data.
Fbcon used the userfont flag distinguish between internal fonts and fonts loaded by user space. Only the latter where refcounted. With the new helper's automatic handling of internal font data, remove the userfont flag from fbcon.
Newport_con uses a default font, FONT_DATA, until user space loads custom font data. Remove all special cases for FONT_DATA, as the get and put calls' read-only handling also covers this case.
v3: - fix module linker error wrt font symbols (Nathan, Arnd) - fix typos
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
show more ...
|