Tactility/Tactility/Source/lvgl/FontSizes.cpp
Ken Van Hoeylandt f8172446fd
App loading improvements and more (#675)
- External apps can opt into automatic cleanup when they exit, including tracked tasks, threads, files, directories, and memory.
- App-relative file paths resolve against the app’s working directory, with `.` and `..` normalized.
- The shell identifies ELF binaries that cannot be executed instead of treating them as scripts.
- Shared icon fonts now offer distinct default and large sizes, with updated icons across the interface.
- ESP32 apps can load additional ELF formats when address mirroring is enabled.
- Terminal colors render clearly on monochrome displays, and toolbar buttons have cleaner styling.
- GPS settings safely refresh their device list when their window is hidden or its widgets are destroyed.
2026-10-06 07:45:58 +02:00

31 lines
950 B
C++

#include <Tactility/lvgl/FontSizes.h>
#include <cmath>
namespace tt::lvgl {
static uint16_t scale(uint16_t size, float factor) {
return static_cast<uint16_t>(std::lround(size * factor));
}
uint16_t getTextFontSize(uint16_t defaultSize, LvglFontSize fontSize) {
switch (fontSize) {
case FONT_SIZE_SMALL: return scale(defaultSize, 0.75f);
case FONT_SIZE_LARGE: return scale(defaultSize, 1.25f);
case FONT_SIZE_DEFAULT:
default: return defaultSize;
}
}
uint16_t getIconFontSize(uint16_t defaultSize, LvglIconFont iconFont) {
switch (iconFont) {
case LVGL_ICON_FONT_LAUNCHER: return scale(defaultSize, 2.6f);
case LVGL_ICON_FONT_SHARED_DEFAULT: return scale(defaultSize, 1.25);
case LVGL_ICON_FONT_SHARED_LARGE: return getIconFontSize(defaultSize, LVGL_ICON_FONT_SHARED) * 2;
case LVGL_ICON_FONT_STATUSBAR:
default: return scale(defaultSize, 1.15f);
}
}
}