Ken Van Hoeylandt 86010186d8
Improve Terminal, App List, app starting, and more (#658)
app-module:

- Implement `AppStartContext` to reduce amount of `app_start_` and `app_exec` functions: replace them with `app_start_with_context()`
- Add support for environment variables when starting apps
- Implement support for environment variables for apps

graphics-module:

- Add this new module
- Move font-module code into this module
- Implement pixel_buffer

apps:

- Terminal app: reduce memory usage by only buffering a single row of characters, and try to buffer in IRAM when possible. Implement new pixel_buffer.
- App List: Mark apps as favourite to pin them on top. Use touch or press "x" key.
- App List: Add toolbar button that shows alert dialog with info about using favourites
2026-09-24 00:44:28 +02:00

34 lines
1.1 KiB
C++

// SPDX-License-Identifier: Apache-2.0
#include <font/render.h>
#include <font/font.h>
#include <graphics/pixel_buffer.h>
extern "C" {
void font_render_char_pixel_buffer_rgb565(
PixelBuffer* buffer,
int x,
int y,
const FixedWidthFont* font,
char character,
uint16_t fg,
uint16_t bg,
PixelBufferConversion conversion
) {
const auto raw = static_cast<unsigned char>(character);
const unsigned char glyphChar = (raw >= font->first_codepoint && raw <= font->last_codepoint) ? raw : ' ';
const uint8_t* glyph = &font->glyph_bitmap[(glyphChar - font->first_codepoint) * font->glyph_height * font->glyph_bytes_per_row];
for (int row = 0; row < font->glyph_height; row++) {
const uint8_t* bits = &glyph[row * font->glyph_bytes_per_row];
for (int col = 0; col < font->glyph_width; col++) {
// The font stores the leftmost pixel of each row byte in the most significant bit.
const bool covered = (bits[col / 8] & (0x80U >> (col % 8))) != 0;
pixel_buffer_set_pixel_rgb565(buffer, x + col, y + row, covered ? fg : bg, conversion);
}
}
}
}