From a5a0de142885957a48603688635e0cf6956ff737 Mon Sep 17 00:00:00 2001 From: edgetriggered Date: Sun, 14 Aug 2022 19:58:27 +0000 Subject: [PATCH] UI: Build time font selection --- meson.build | 7 +++++++ openrtx/src/core/graphics.c | 39 ++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index a420d500..9219b7a9 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,13 @@ project('OpenRTX', ['c', 'cpp'], def = {} +## +## UI font configuration, only one uncommented at a time +## + +def += {'FONT_UBUNTU_REGULAR': ''} +# def += {'FONT_FREE_SANS': ''} + ## ## ----------------- Platform-independent source files ------------------------- ## diff --git a/openrtx/src/core/graphics.c b/openrtx/src/core/graphics.c index 88411d1f..d667bfb5 100644 --- a/openrtx/src/core/graphics.c +++ b/openrtx/src/core/graphics.c @@ -42,6 +42,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include // Variable swap macro #define DEG_RAD 0.017453292519943295769236907684886 @@ -51,15 +59,28 @@ /** * Fonts, ordered by the fontSize_t enum. */ -static const GFXfont fonts[] = { TomThumb, // 5pt - FreeSans6pt7b, // 6pt - FreeSans8pt7b, // 8pt - FreeSans9pt7b, // 9pt - FreeSans10pt7b, // 10pt - FreeSans12pt7b, // 12pt - FreeSans16pt7b, // 16pt - FreeSans18pt7b, // 16pt - FreeSans24pt7b // 24pt +static const GFXfont fonts[] = { TomThumb, // 5pt + #if defined FONT_FREE_SANS + FreeSans6pt7b, // 6pt + FreeSans8pt7b, // 8pt + FreeSans9pt7b, // 9pt + FreeSans10pt7b, // 10pt + FreeSans12pt7b, // 12pt + FreeSans16pt7b, // 16pt + FreeSans18pt7b, // 16pt + FreeSans24pt7b // 24pt + #elif defined FONT_UBUNTU_REGULAR + UbuntuRegular6pt7b, // 6pt + UbuntuRegular8pt7b, // 8pt + UbuntuRegular9pt7b, // 9pt + UbuntuRegular10pt7b, // 10pt + UbuntuRegular12pt7b, // 12pt + UbuntuRegular16pt7b, // 16pt + UbuntuRegular18pt7b, // 16pt + UbuntuRegular24pt7b // 24pt + #else + #error Unsupported font family! + #endif }; #ifdef PIX_FMT_RGB565