lib/fonts/font_rotate.c
Source file repositories/reference/linux-study-clean/lib/fonts/font_rotate.c
File Facts
- System
- Linux kernel
- Corpus path
lib/fonts/font_rotate.c- Extension
.c- Size
- 8526 bytes
- Lines
- 276
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
Dependency Surface
linux/errno.hlinux/export.hlinux/math.hlinux/overflow.hlinux/slab.hlinux/string.hfont.h
Detected Declarations
function Copyrightfunction __font_glyph_posfunction font_glyph_test_bitfunction font_glyph_set_bitfunction __font_glyph_rotate_90function font_glyph_rotate_90function __font_glyph_rotate_180function font_glyph_rotate_180function __font_glyph_rotate_270function font_glyph_rotate_270function font_data_bufexport font_glyph_rotate_90export font_glyph_rotate_180export font_glyph_rotate_270export font_data_rotate
Annotated Snippet
if (font_glyph_test_bit(glyph, x, y, bit_pitch)) {
font_glyph_set_bit(out, out_bit_pitch - 1 - y - shift, x,
out_bit_pitch);
}
}
}
}
/**
* font_glyph_rotate_90 - Rotate a glyph pattern by 90° in clockwise direction
* @glyph: The glyph to rotate
* @width: The glyph width in bits per scanline
* @height: The number of scanlines in the glyph
* @out: The rotated glyph bitmap
*
* The parameters @width and @height refer to the input glyph given in @glyph.
* The caller has to provide the output buffer @out of sufficient size to hold
* the rotated glyph. Rotating by 90° flips the width and height for the output
* glyph. Depending on the glyph pitch, the size of the output glyph can be
* different than the size of the input. Callers have to take this into account
* when allocating the output memory.
*/
void font_glyph_rotate_90(const unsigned char *glyph, unsigned int width, unsigned int height,
unsigned char *out)
{
memset(out, 0, font_glyph_size(height, width)); /* flip width/height */
__font_glyph_rotate_90(glyph, width, height, out);
}
EXPORT_SYMBOL_GPL(font_glyph_rotate_90);
static void __font_glyph_rotate_180(const unsigned char *glyph,
unsigned int width, unsigned int height,
unsigned char *out)
{
unsigned int x, y;
unsigned int shift = (8 - (width % 8)) & 7;
unsigned int bit_pitch = font_glyph_bit_pitch(width);
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, bit_pitch - 1 - x - shift, height - 1 - y,
bit_pitch);
}
}
}
}
/**
* font_glyph_rotate_180 - Rotate a glyph pattern by 180°
* @glyph: The glyph to rotate
* @width: The glyph width in bits per scanline
* @height: The number of scanlines in the glyph
* @out: The rotated glyph bitmap
*
* The parameters @width and @height refer to the input glyph given in @glyph.
* The caller has to provide the output buffer @out of sufficient size to hold
* the rotated glyph.
*/
void font_glyph_rotate_180(const unsigned char *glyph, unsigned int width, unsigned int height,
unsigned char *out)
{
memset(out, 0, font_glyph_size(width, height));
__font_glyph_rotate_180(glyph, width, height, out);
}
EXPORT_SYMBOL_GPL(font_glyph_rotate_180);
static void __font_glyph_rotate_270(const unsigned char *glyph,
unsigned int width, unsigned int height,
unsigned char *out)
{
unsigned int x, y;
unsigned int shift = (8 - (width % 8)) & 7;
unsigned int bit_pitch = font_glyph_bit_pitch(width);
unsigned int out_bit_pitch = font_glyph_bit_pitch(height);
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, y, bit_pitch - 1 - x - shift,
out_bit_pitch);
}
}
}
/**
* font_glyph_rotate_270 - Rotate a glyph pattern by 270° in clockwise direction
* @glyph: The glyph to rotate
Annotation
- Immediate include surface: `linux/errno.h`, `linux/export.h`, `linux/math.h`, `linux/overflow.h`, `linux/slab.h`, `linux/string.h`, `font.h`.
- Detected declarations: `function Copyright`, `function __font_glyph_pos`, `function font_glyph_test_bit`, `function font_glyph_set_bit`, `function __font_glyph_rotate_90`, `function font_glyph_rotate_90`, `function __font_glyph_rotate_180`, `function font_glyph_rotate_180`, `function __font_glyph_rotate_270`, `function font_glyph_rotate_270`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.