diff --git a/sources/Adapters/picoTracker/display/chargfx.c b/sources/Adapters/picoTracker/display/chargfx.c index 1086c571f..612b35f08 100644 --- a/sources/Adapters/picoTracker/display/chargfx.c +++ b/sources/Adapters/picoTracker/display/chargfx.c @@ -192,6 +192,8 @@ inline void chargfx_draw_sub_region(uint8_t x, uint8_t y, uint8_t width, ili9341_start_writing(); + const font_t *font = fonts[ui_font_index]; + for (int page = x; page < x + width; page++) { // create one column of screen information uint16_t *buffer_idx = buffer; @@ -204,9 +206,7 @@ inline void chargfx_draw_sub_region(uint8_t x, uint8_t y, uint8_t width, uint16_t fg_color = palette[colors[idx] >> 4]; uint16_t bg_color = palette[colors[idx] & 0xf]; - uint16_t const *pixel_data = (ui_font_index == 0) - ? FONT_HOURGLASS_BITMAP[character] - : FONT_YOU_SQUARED_BITMAP[character]; + const uint16_t *pixel_data = (*font)[character]; // draw the character into the buffer for (int j = CHAR_HEIGHT - 1; j >= 0; j--) { diff --git a/sources/Adapters/picoTracker/display/font.h b/sources/Adapters/picoTracker/display/font.h index 7d537108e..b99309bea 100644 --- a/sources/Adapters/picoTracker/display/font.h +++ b/sources/Adapters/picoTracker/display/font.h @@ -1,3 +1,13 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2024 xiphonics, inc. + * + * This file is part of the picoTracker firmware + */ + +typedef uint16_t font_t[96][10]; + /* * Hourglass font by Damien Guard (https://damieng.com/zx-origins) * Used in accordance with the informal permission in the project's README. @@ -7,12 +17,11 @@ * SPDX-License-Identifier: LicenseRef-DamienGuard-Custom */ -#include - // Hourglass font from https://damieng.com/zx-origins // used with permission the acknowledgement is included in credits // converted to left-to-right pixel format -static const uint16_t FONT_HOURGLASS_BITMAP[96][10] = { + +static const font_t FONT_HOURGLASS_BITMAP = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00}, // ! {0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // " @@ -73,7 +82,7 @@ static const uint16_t FONT_HOURGLASS_BITMAP[96][10] = { {0x00, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x08, 0x00, 0x00}, // Y {0x00, 0x3E, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x00, 0x00}, // Z {0x00, 0x3C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x3C, 0x00, 0x00}, // [ - {0x00, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00}, /* \ */ + {0x00, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00}, /* \*/ {0x00, 0x3C, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3C, 0x00, 0x00}, // ] {0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00}, // ^ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00}, // _ @@ -111,9 +120,19 @@ static const uint16_t FONT_HOURGLASS_BITMAP[96][10] = { {0x00, 0x3C, 0x42, 0x99, 0xA5, 0x85, 0xB9, 0x42, 0x3C, 0x00} // © }; +/* + * You Squared font by Damien Guard (https://damieng.com/zx-origins) + * Used in accordance with the informal permission in the project's README. + * Do not redistribute the font itself; this usage only embeds a converted + * bitmap. + * + * SPDX-License-Identifier: LicenseRef-DamienGuard-Custom + */ + // You Squared font from https://damieng.com/zx-origins // converted to left-to-right pixel format -static const uint16_t FONT_YOU_SQUARED_BITMAP[96][10] = { + +static const font_t FONT_YOU_SQUARED_BITMAP = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00, 0x00}, // ! {0x00, 0x66, 0x66, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // " @@ -211,3 +230,111 @@ static const uint16_t FONT_YOU_SQUARED_BITMAP[96][10] = { {0x00, 0x00, 0x00, 0x6E, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}, // ~ {0x00, 0x3C, 0x42, 0xBD, 0x8D, 0x8D, 0xBD, 0x42, 0x3C, 0x00} // © }; + +/* 8x8 wide font by nILS, given to the public domain */ + +static const uint16_t FONT_WIDE_BITMAP[96][10] = { + {0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000}, // + {0x000, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x000, 0x030, 0x000}, // ! + {0x000, 0x0CC, 0x0CC, 0x0CC, 0x048, 0x000, 0x000, 0x000, 0x000, 0x000}, // " + {0x000, 0x0CC, 0x0CC, 0x1FE, 0x0CC, 0x0CC, 0x1FE, 0x0CC, 0x0CC, 0x000}, // # + {0x000, 0x030, 0x0FC, 0x036, 0x0FC, 0x1B0, 0x1B0, 0x0FC, 0x030, 0x000}, // $ + {0x000, 0x000, 0x186, 0x0C6, 0x060, 0x030, 0x018, 0x18C, 0x186, 0x000}, // % + {0x000, 0x078, 0x0CC, 0x0CC, 0x078, 0x03C, 0x166, 0x0C6, 0x1BC, 0x000}, // & + {0x000, 0x180, 0x0C0, 0x060, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000}, // ' + {0x000, 0x0C0, 0x060, 0x030, 0x030, 0x030, 0x030, 0x060, 0x0C0, 0x000}, // ( + {0x000, 0x00C, 0x018, 0x030, 0x030, 0x030, 0x030, 0x018, 0x00C, 0x000}, // ) + {0x000, 0x000, 0x084, 0x0CC, 0x078, 0x1FE, 0x078, 0x0CC, 0x084, 0x000}, // * + {0x000, 0x000, 0x030, 0x030, 0x030, 0x1FE, 0x030, 0x030, 0x030, 0x000}, // + + {0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x018, 0x018, 0x00C, 0x000}, // , + {0x000, 0x000, 0x000, 0x000, 0x000, 0x1FE, 0x000, 0x000, 0x000, 0x000}, // - + {0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x018, 0x018, 0x000}, // . + {0x000, 0x100, 0x180, 0x0C0, 0x060, 0x030, 0x018, 0x00C, 0x006, 0x000}, // / + {0x000, 0x0FC, 0x186, 0x1C6, 0x1A6, 0x196, 0x18E, 0x186, 0x0FC, 0x000}, // 0 + {0x000, 0x070, 0x060, 0x060, 0x060, 0x060, 0x060, 0x060, 0x060, 0x000}, // 1 + {0x000, 0x0FE, 0x180, 0x180, 0x0FC, 0x006, 0x006, 0x006, 0x1FE, 0x000}, // 2 + {0x000, 0x0FE, 0x180, 0x180, 0x0F8, 0x180, 0x180, 0x180, 0x0FE, 0x000}, // 3 + {0x000, 0x186, 0x186, 0x186, 0x1FE, 0x180, 0x180, 0x180, 0x180, 0x000}, // 4 + {0x000, 0x1FE, 0x006, 0x006, 0x0FE, 0x180, 0x180, 0x186, 0x0FC, 0x000}, // 5 + {0x000, 0x0FC, 0x006, 0x006, 0x0FE, 0x186, 0x186, 0x186, 0x0FC, 0x000}, // 6 + {0x000, 0x1FE, 0x180, 0x180, 0x180, 0x180, 0x180, 0x180, 0x180, 0x000}, // 7 + {0x000, 0x0FC, 0x186, 0x186, 0x0FC, 0x186, 0x186, 0x186, 0x0FC, 0x000}, // 8 + {0x000, 0x0FC, 0x186, 0x186, 0x186, 0x1FC, 0x180, 0x180, 0x0FC, 0x000}, // 9 + {0x000, 0x000, 0x000, 0x018, 0x018, 0x000, 0x018, 0x018, 0x000, 0x000}, // : + {0x000, 0x000, 0x000, 0x018, 0x018, 0x000, 0x018, 0x018, 0x00C, 0x000}, // ; + {0x000, 0x060, 0x030, 0x018, 0x00C, 0x00C, 0x018, 0x030, 0x060, 0x000}, // < + {0x000, 0x000, 0x000, 0x1FC, 0x000, 0x000, 0x1FC, 0x000, 0x000, 0x000}, // = + {0x000, 0x018, 0x030, 0x060, 0x0C0, 0x0C0, 0x060, 0x030, 0x018, 0x000}, // > + {0x000, 0x0FC, 0x186, 0x180, 0x0C0, 0x060, 0x060, 0x000, 0x060, 0x000}, // ? + {0x000, 0x0FC, 0x186, 0x1B6, 0x196, 0x196, 0x1F6, 0x006, 0x0FC, 0x000}, // @ + {0x000, 0x0FC, 0x186, 0x186, 0x186, 0x1FE, 0x186, 0x186, 0x186, 0x000}, // A + {0x000, 0x0FE, 0x186, 0x186, 0x0FE, 0x186, 0x186, 0x186, 0x0FE, 0x000}, // B + {0x000, 0x0FC, 0x186, 0x006, 0x006, 0x006, 0x006, 0x186, 0x0FC, 0x000}, // C + {0x000, 0x0FE, 0x186, 0x186, 0x186, 0x186, 0x186, 0x186, 0x0FE, 0x000}, // D + {0x000, 0x1FE, 0x006, 0x006, 0x07E, 0x006, 0x006, 0x006, 0x1FE, 0x000}, // E + {0x000, 0x1FE, 0x006, 0x006, 0x07E, 0x006, 0x006, 0x006, 0x006, 0x000}, // F + {0x000, 0x0FC, 0x186, 0x006, 0x006, 0x1E6, 0x186, 0x186, 0x0FC, 0x000}, // G + {0x000, 0x186, 0x186, 0x186, 0x1FE, 0x186, 0x186, 0x186, 0x186, 0x000}, // H + {0x000, 0x1FE, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x1FE, 0x000}, // I + {0x000, 0x1E0, 0x0C0, 0x0C0, 0x0C0, 0x0C0, 0x0C0, 0x0E6, 0x07C, 0x000}, // J + {0x000, 0x186, 0x0C6, 0x066, 0x03E, 0x03E, 0x066, 0x0C6, 0x186, 0x000}, // K + {0x000, 0x006, 0x006, 0x006, 0x006, 0x006, 0x006, 0x006, 0x1FE, 0x000}, // L + {0x000, 0x186, 0x1CE, 0x1FE, 0x1B6, 0x186, 0x186, 0x186, 0x186, 0x000}, // M + {0x000, 0x186, 0x18E, 0x19E, 0x1BE, 0x1F6, 0x1E6, 0x1C6, 0x186, 0x000}, // N + {0x000, 0x0FC, 0x186, 0x186, 0x186, 0x186, 0x186, 0x186, 0x0FC, 0x000}, // O + {0x000, 0x0FE, 0x186, 0x186, 0x186, 0x0FE, 0x006, 0x006, 0x006, 0x000}, // P + {0x000, 0x0FC, 0x186, 0x186, 0x186, 0x186, 0x136, 0x066, 0x0DC, 0x000}, // Q + {0x000, 0x0FE, 0x186, 0x186, 0x186, 0x0FE, 0x186, 0x186, 0x186, 0x000}, // R + {0x000, 0x0FC, 0x186, 0x006, 0x0FC, 0x180, 0x180, 0x186, 0x0FC, 0x000}, // S + {0x000, 0x1FE, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x000}, // T + {0x000, 0x186, 0x186, 0x186, 0x186, 0x186, 0x186, 0x186, 0x0FC, 0x000}, // U + {0x000, 0x186, 0x186, 0x186, 0x186, 0x186, 0x0CC, 0x078, 0x030, 0x000}, // V + {0x000, 0x186, 0x186, 0x186, 0x186, 0x1B6, 0x1FE, 0x1CE, 0x186, 0x000}, // W + {0x000, 0x186, 0x186, 0x0CC, 0x078, 0x0CC, 0x186, 0x186, 0x186, 0x000}, // X + {0x000, 0x186, 0x186, 0x186, 0x0CC, 0x078, 0x030, 0x030, 0x030, 0x000}, // Y + {0x000, 0x1FE, 0x180, 0x0C0, 0x070, 0x018, 0x00C, 0x006, 0x1FE, 0x000}, // Z + {0x000, 0x0F0, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x0F0, 0x000}, // [ + {0x000, 0x002, 0x006, 0x00C, 0x018, 0x030, 0x060, 0x0C0, 0x180, + 0x000}, /* \*/ + {0x000, 0x03C, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x03C, 0x000}, // ] + {0x000, 0x030, 0x078, 0x0CC, 0x186, 0x102, 0x000, 0x000, 0x000, 0x000}, // ^ + {0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x1FE, 0x000}, // _ + {0x000, 0x006, 0x00C, 0x018, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000}, // ` + {0x000, 0x000, 0x000, 0x0F8, 0x180, 0x1FC, 0x186, 0x186, 0x1FC, 0x000}, // a + {0x000, 0x006, 0x006, 0x0FE, 0x186, 0x186, 0x186, 0x186, 0x0FE, 0x000}, // b + {0x000, 0x000, 0x000, 0x0FC, 0x186, 0x006, 0x006, 0x186, 0x0FC, 0x000}, // c + {0x000, 0x180, 0x180, 0x1FC, 0x186, 0x186, 0x186, 0x186, 0x1FC, 0x000}, // d + {0x000, 0x000, 0x000, 0x0FC, 0x186, 0x1FE, 0x006, 0x186, 0x0FC, 0x000}, // e + {0x000, 0x0F0, 0x198, 0x018, 0x018, 0x07C, 0x018, 0x018, 0x018, 0x000}, // f + {0x000, 0x000, 0x000, 0x1FC, 0x186, 0x186, 0x186, 0x1FC, 0x180, 0x0FC}, // g + {0x000, 0x006, 0x006, 0x0FE, 0x186, 0x186, 0x186, 0x186, 0x186, 0x000}, // h + {0x000, 0x030, 0x000, 0x03C, 0x030, 0x030, 0x030, 0x030, 0x0FC, 0x000}, // i + {0x000, 0x0C0, 0x000, 0x0F0, 0x0C0, 0x0C0, 0x0C0, 0x0C0, 0x07E, 0x000}, // j + {0x000, 0x006, 0x006, 0x186, 0x0C6, 0x07E, 0x0C6, 0x186, 0x186, 0x000}, // k + {0x000, 0x03C, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x0FC, 0x000}, // l + {0x000, 0x000, 0x000, 0x0FE, 0x1B6, 0x1B6, 0x186, 0x186, 0x186, 0x000}, // m + {0x000, 0x000, 0x000, 0x0FE, 0x186, 0x186, 0x186, 0x186, 0x186, 0x000}, // n + {0x000, 0x000, 0x000, 0x0FC, 0x186, 0x186, 0x186, 0x186, 0x0FC, 0x000}, // o + {0x000, 0x000, 0x000, 0x0FE, 0x186, 0x186, 0x186, 0x0FE, 0x006, 0x006}, // p + {0x000, 0x000, 0x000, 0x1FC, 0x186, 0x186, 0x186, 0x1FC, 0x180, 0x180}, // q + {0x000, 0x000, 0x000, 0x0FE, 0x186, 0x006, 0x006, 0x006, 0x006, 0x000}, // r + {0x000, 0x000, 0x000, 0x0FC, 0x006, 0x0FC, 0x180, 0x180, 0x0FE, 0x000}, // s + {0x000, 0x00C, 0x00C, 0x03E, 0x00C, 0x00C, 0x00C, 0x18C, 0x0F8, 0x000}, // t + {0x000, 0x000, 0x000, 0x186, 0x186, 0x186, 0x186, 0x186, 0x0FC, 0x000}, // u + {0x000, 0x000, 0x000, 0x186, 0x186, 0x186, 0x0CC, 0x078, 0x030, 0x000}, // v + {0x000, 0x000, 0x000, 0x186, 0x186, 0x186, 0x1B6, 0x1B6, 0x0FC, 0x000}, // w + {0x000, 0x000, 0x000, 0x186, 0x0CC, 0x078, 0x078, 0x0CC, 0x186, 0x000}, // x + {0x000, 0x000, 0x000, 0x186, 0x186, 0x186, 0x1FC, 0x180, 0x0FE, 0x000}, // y + {0x000, 0x000, 0x000, 0x1FC, 0x180, 0x0FC, 0x006, 0x006, 0x1FE, 0x000}, // z + {0x000, 0x0C0, 0x060, 0x060, 0x038, 0x038, 0x060, 0x060, 0x0C0, 0x000}, // { + {0x000, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x030, 0x000}, // | + {0x000, 0x00C, 0x018, 0x018, 0x070, 0x070, 0x018, 0x018, 0x00C, 0x000}, // } + {0x000, 0x000, 0x000, 0x018, 0x1BC, 0x0F6, 0x060, 0x000, 0x000, 0x000}, // ~ + {0x000, 0x078, 0x084, 0x132, 0x10A, 0x10A, 0x132, 0x084, 0x078, 0x000}, //  +}; + +static const font_t *fonts[] = { + &FONT_HOURGLASS_BITMAP, + &FONT_YOU_SQUARED_BITMAP, + &FONT_WIDE_BITMAP, +}; diff --git a/sources/Application/Model/Config.cpp b/sources/Application/Model/Config.cpp index 09cb5a3db..76e00e84d 100644 --- a/sources/Application/Model/Config.cpp +++ b/sources/Application/Model/Config.cpp @@ -34,8 +34,6 @@ static const char *midiSendSync[2] = {"Off", "Send"}; static const char *midiClockSyncOptions[2] = {"Internal", "External"}; static const char *remoteUIOnOff[2] = {"Off", "On"}; -static const char *fontOptions[2] = {"Standard", "Bold"}; - // NOTE: these MUST match up to the RecordSource enum in record.h (of all // adapters) also note we *dont* show "All Off" as a UI option for now static const char *recordSourceOptions[4] = {"All Off", "Line In", "Mic", @@ -172,8 +170,8 @@ static const ConfigParam configParams[] = { {"UIFONT", {.intValue = ThemeConstants::DEFAULT_UIFONT}, FourCC::VarUIFont, - fontOptions, - 2, + ThemeConstants::FONT_NAMES, + ThemeConstants::FONT_COUNT, false}, // {"RESERVED1", ThemeConstants::DEFAULT_RESERVED1, diff --git a/sources/Application/Model/ThemeConstants.h b/sources/Application/Model/ThemeConstants.h index ab9611dc1..0f2ecefcc 100644 --- a/sources/Application/Model/ThemeConstants.h +++ b/sources/Application/Model/ThemeConstants.h @@ -32,7 +32,9 @@ const uint32_t DEFAULT_EMPHASIS = 0xFFA500; // Font constants const int DEFAULT_UIFONT = 0x0; -// Default theme name - using inline to avoid multiple definition errors +const int FONT_COUNT = 3; +inline const char *FONT_NAMES[FONT_COUNT] = {"Regular", "Bold", "Wide"}; + inline const char *DEFAULT_THEME_NAME = "Default"; } // namespace ThemeConstants diff --git a/sources/Application/Views/ThemeView.cpp b/sources/Application/Views/ThemeView.cpp index 76957b0e9..db2b4366e 100644 --- a/sources/Application/Views/ThemeView.cpp +++ b/sources/Application/Views/ThemeView.cpp @@ -47,7 +47,9 @@ ThemeView::ThemeView(GUIWindow &w, ViewData *data) : FieldView(w, data) { // Font selection position._y = FONT_FIELD_LINE; v = config->FindVariable(FourCC::VarUIFont); - intVarField_.emplace_back(position, *v, "Font: %s", 0, 1, 1, 1); + intVarField_.emplace_back(position, *v, "Font: %s", 0, + ThemeConstants::FONT_COUNT - 1, 1, + ThemeConstants::FONT_COUNT - 1); fieldList_.insert(fieldList_.end(), &(*intVarField_.rbegin())); (*intVarField_.rbegin()).AddObserver(*this);