From 943bc900c8388da817050d37fcb5d2ff0ee5aaf4 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 24 Oct 2024 11:51:10 +0100 Subject: [PATCH] Unicorn(s): Remove some Hershey fonts. Since Hershey fonts make virtually no sense on these low-resolution displays, remove all but Serif/Sans to make up for the additional flash usage of MicroPython 1.24.0 / Pico SDK 2.0.0. --- libraries/hershey_fonts/hershey_fonts.cpp | 5 +++++ micropython/modules/hershey_fonts/micropython.cmake | 8 +++++++- micropython/modules/micropython-cosmic_unicorn.cmake | 3 +++ micropython/modules/micropython-galactic_unicorn.cmake | 3 +++ micropython/modules/micropython-stellar_unicorn.cmake | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libraries/hershey_fonts/hershey_fonts.cpp b/libraries/hershey_fonts/hershey_fonts.cpp index 9962f3288..5069d249c 100644 --- a/libraries/hershey_fonts/hershey_fonts.cpp +++ b/libraries/hershey_fonts/hershey_fonts.cpp @@ -28,12 +28,17 @@ namespace hershey { } const font_t* font(std::string_view font) { +#ifdef PG_HERSHEY_LITE + if(font == "serif") return ×r; + return &futural; +#else if(font == "sans") return &futural; else if(font == "gothic") return &gothgbt; else if(font == "cursive") return &scripts; else if(font == "serif_italic") return ×i; else if(font == "serif") return ×r; return &futural; +#endif } inline float deg2rad(float degrees) { diff --git a/micropython/modules/hershey_fonts/micropython.cmake b/micropython/modules/hershey_fonts/micropython.cmake index 14ae6c61a..8a8091e4c 100644 --- a/micropython/modules/hershey_fonts/micropython.cmake +++ b/micropython/modules/hershey_fonts/micropython.cmake @@ -12,4 +12,10 @@ target_include_directories(usermod_${MOD_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR}/../../../libraries/hershey_fonts ) -target_link_libraries(usermod INTERFACE usermod_${MOD_NAME}) \ No newline at end of file +target_link_libraries(usermod INTERFACE usermod_${MOD_NAME}) + +function(hershey_lite) + target_compile_definitions(usermod_${MOD_NAME} INTERFACE + PG_HERSHEY_LITE=1 + ) +endfunction() \ No newline at end of file diff --git a/micropython/modules/micropython-cosmic_unicorn.cmake b/micropython/modules/micropython-cosmic_unicorn.cmake index c14af9dd1..1923c8421 100644 --- a/micropython/modules/micropython-cosmic_unicorn.cmake +++ b/micropython/modules/micropython-cosmic_unicorn.cmake @@ -13,6 +13,9 @@ include(pimoroni_bus/micropython) # Pico Graphics Essential include(hershey_fonts/micropython) +# We need to save ~3k somewhere, +# and Hershey fonts don't make sense on these boards +hershey_lite() include(bitmap_fonts/micropython) include(picographics/micropython) diff --git a/micropython/modules/micropython-galactic_unicorn.cmake b/micropython/modules/micropython-galactic_unicorn.cmake index 15bbfcfad..6f15556a7 100644 --- a/micropython/modules/micropython-galactic_unicorn.cmake +++ b/micropython/modules/micropython-galactic_unicorn.cmake @@ -13,6 +13,9 @@ include(pimoroni_bus/micropython) # Pico Graphics Essential include(hershey_fonts/micropython) +# We need to save ~3k somewhere, +# and Hershey fonts don't make sense on these boards +hershey_lite() include(bitmap_fonts/micropython) include(picographics/micropython) diff --git a/micropython/modules/micropython-stellar_unicorn.cmake b/micropython/modules/micropython-stellar_unicorn.cmake index d44fb45de..fbb13dfe7 100644 --- a/micropython/modules/micropython-stellar_unicorn.cmake +++ b/micropython/modules/micropython-stellar_unicorn.cmake @@ -13,6 +13,9 @@ include(pimoroni_bus/micropython) # Pico Graphics Essential include(hershey_fonts/micropython) +# We need to save ~3k somewhere, +# and Hershey fonts don't make sense on these boards +hershey_lite() include(bitmap_fonts/micropython) include(picographics/micropython)