From b2ff46b516037c3734464ab1e7dcf9224e12fc82 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 1 Apr 2022 13:13:44 +0100 Subject: [PATCH] Bitmap Fonts: Simplify and add support for 16bit fonts. --- libraries/badger2040/badger2040.cpp | 3 + libraries/badger2040/badger2040.hpp | 1 + libraries/bitmap_fonts/bitmap_fonts.cpp | 64 +++++--- libraries/bitmap_fonts/bitmap_fonts.hpp | 3 - .../bitmap_fonts/font14_outline_data.hpp | 138 ++++++++++++++++++ libraries/bitmap_fonts/font6_data.hpp | 36 ++--- libraries/bitmap_fonts/font8_data.hpp | 24 +-- 7 files changed, 216 insertions(+), 53 deletions(-) create mode 100644 libraries/bitmap_fonts/font14_outline_data.hpp diff --git a/libraries/badger2040/badger2040.cpp b/libraries/badger2040/badger2040.cpp index ba51a2d9..ee5c489d 100644 --- a/libraries/badger2040/badger2040.cpp +++ b/libraries/badger2040/badger2040.cpp @@ -376,6 +376,9 @@ namespace pimoroni { } else if (name == "bitmap8") { _bitmap_font = &font8; _font = nullptr; + } else if (name == "bitmap14_outline") { + _bitmap_font = &font14_outline; + _font = nullptr; } else { // check that font exists and assign it if(hershey::fonts.find(name) != hershey::fonts.end()) { diff --git a/libraries/badger2040/badger2040.hpp b/libraries/badger2040/badger2040.hpp index 0ee75d19..8ea3375a 100644 --- a/libraries/badger2040/badger2040.hpp +++ b/libraries/badger2040/badger2040.hpp @@ -8,6 +8,7 @@ #include "libraries/bitmap_fonts/bitmap_fonts.hpp" #include "libraries/bitmap_fonts/font6_data.hpp" #include "libraries/bitmap_fonts/font8_data.hpp" +#include "libraries/bitmap_fonts/font14_outline_data.hpp" namespace pimoroni { diff --git a/libraries/bitmap_fonts/bitmap_fonts.cpp b/libraries/bitmap_fonts/bitmap_fonts.cpp index 11acaa5d..fcfbe3c1 100644 --- a/libraries/bitmap_fonts/bitmap_fonts.cpp +++ b/libraries/bitmap_fonts/bitmap_fonts.cpp @@ -34,45 +34,69 @@ namespace bitmap { uint8_t char_index = c; unicode_sorta::accents char_accent = unicode_sorta::ACCENT_NONE; + // Remap any chars that fall outside of the 7-bit ASCII range + // using our unicode fudge lookup table. if(char_index > 127) { char_index = unicode_sorta::char_base[c - 128]; char_accent = unicode_sorta::char_accent[c - 128]; } - bool upper = char_index < 97; // Only valid for A-Z and a-z + // We don't map font data for the first 32 non-printable ASCII chars char_index -= 32; - const uint8_t *d = &font->data[char_index * font->max_width]; - const uint8_t *a = &font->data[101 * font->max_width + char_accent * font->max_width]; + // If our font is taller than 8 pixels it must be two bytes per column + bool two_bytes_per_column = font->height > 8; - // Vertical offset of our char within the 32 pixel column canvas - // At 16 pixels this gives us 8 pixels above and below the char for accents and spacing. - uint8_t offset = (32 - font->height) / 2; + // Figure out how many bytes we need to skip per char to find our data in the array + uint8_t bytes_per_char = two_bytes_per_column ? font->max_width * 2 : font->max_width; + // Get a pointer to the start of the data for this character + const uint8_t *d = &font->data[char_index * bytes_per_char]; + + // Accents can be up to 8 pixels tall on both 8bit and 16bit fonts + // Each accent's data is font->max_width bytes + 2 offset bytes long + const uint8_t *a = &font->data[101 * bytes_per_char + char_accent * (font->max_width + 2)]; + + // Effectively shift off the first two bytes of accent data- + // these are the lower and uppercase accent offsets + const uint8_t offset_lower = *a++; + const uint8_t offset_upper = *a++; + + // Pick which offset we should use based on the case of the char + // This is only valid for A-Z a-z. + // Note this magic number is relative to the start of printable ASCII chars. + uint8_t accent_offset = char_index < 65 ? offset_upper : offset_lower; + + // Offset our y position to account for our column canvas being 32 pixels + int y_offset = y - (8 * scale); + + // Iterate through each horizontal column of font (and accent) data for(uint8_t cx = 0; cx < font->widths[char_index]; cx++) { // Our maximum bitmap font height will be 16 pixels // give ourselves a 32 pixel high canvas in which to plot the char and accent. - uint32_t data = *d << offset; - if(char_accent != unicode_sorta::ACCENT_NONE) { - uint32_t accent = *a; - accent <<= offset; // Shift the char to the middle of the canvas - if(char_accent == unicode_sorta::ACCENT_CEDILLA) { - // Special case handling for the Cedilla- that little upside-down question mark that goes beneath characters - accent <<= font->accent_offset_below; - } else { - accent >>= upper ? font->accent_offset_upper : font->accent_offset_lower; // Shift the accent above the char - } - data |= accent; // Merge the accent data into the canvas + // We shift the char down 8 pixels to make room for an accent above. + uint32_t data = *d << 8; + + // For fonts that are taller than 8 pixels (up to 16) they need two bytes + if(two_bytes_per_column) { + d++; + data <<= 8; // Move down the first byte + data |= *d << 8; // Add the second byte } - // Offset our y position to account for our column canvas being 32 pixels - int y_offset = y - (offset * scale); - // Dra the 32 pixel high column + + // If the char has an accent, merge it into the column data at its offset + if(char_accent != unicode_sorta::ACCENT_NONE) { + data |= *a << accent_offset; + } + + // Draw the 32 pixel column for(uint8_t cy = 0; cy < 32; cy++) { if((1U << cy) & data) { rectangle(x + (cx * scale), y_offset + (cy * scale), scale, scale); } } + // Move to the next columns of char and accent data d++; a++; } diff --git a/libraries/bitmap_fonts/bitmap_fonts.hpp b/libraries/bitmap_fonts/bitmap_fonts.hpp index 953e3fb5..2dc596a0 100644 --- a/libraries/bitmap_fonts/bitmap_fonts.hpp +++ b/libraries/bitmap_fonts/bitmap_fonts.hpp @@ -8,9 +8,6 @@ namespace bitmap { struct font_t { const uint8_t height; const uint8_t max_width; - const uint8_t accent_offset_upper; // Number of pixels to shift accents UP above uppercase letters - const uint8_t accent_offset_lower; // Number of pixels to shift accents UP above lowercase letters - const uint8_t accent_offset_below; // Number of pixels to shift accents DOWN below lowercase letters (height of the cedilla accent) const uint8_t widths[96 + 5]; // 96 printable ASCII chars plus 5 exta we can't easily remap and decorate with accents const uint8_t data[]; }; diff --git a/libraries/bitmap_fonts/font14_outline_data.hpp b/libraries/bitmap_fonts/font14_outline_data.hpp new file mode 100644 index 00000000..14df4089 --- /dev/null +++ b/libraries/bitmap_fonts/font14_outline_data.hpp @@ -0,0 +1,138 @@ +#pragma once + +#include "bitmap_fonts.hpp" + +const bitmap::font_t font14_outline { + .height = 14, + .max_width = 10, + .widths = { + 5, 3, 5,10, 7,10,10, 3, 5, 5, 6, 7, 4, 7, 3, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 4, 5, 8, 5, 7, + 8, 7, 6, 6, 6, 6, 6, 7, 7, 7, 7, 6, 6,10, 7, 8, + 6, 9, 6, 6, 7, 7, 7, 9, 7, 7, 7, 5, 7, 5, 7, 8, + 5, 8, 6, 5, 6, 6, 5, 7, 6, 3, 5, 6, 5, 9, 6, 7, + 6, 7, 5, 5, 6, 6, 7, 9, 7, 7, 7, 5, 3, 5, 8, 5, + 9, 6, 6, 10, 6 // Extra + }, + .data = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x0f, 0xfc, 0x0a, 0x04, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ! + 0x00, 0x7c, 0x00, 0x44, 0x00, 0x7c, 0x00, 0x44, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " + 0x03, 0xf0, 0x02, 0xd0, 0x0e, 0xdc, 0x08, 0x04, 0x0e, 0xdc, 0x0e, 0xdc, 0x08, 0x04, 0x0e, 0xdc, 0x02, 0xd0, 0x03, 0xf0, // // + 0x0e, 0xf8, 0x0b, 0x8c, 0x1b, 0x76, 0x10, 0x02, 0x1b, 0x76, 0x0c, 0xd4, 0x07, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // $ + 0x00, 0x38, 0x00, 0x6c, 0x0f, 0x54, 0x09, 0xec, 0x0e, 0x78, 0x07, 0x9c, 0x0d, 0xe4, 0x0a, 0xbc, 0x0d, 0x80, 0x07, 0x00, // % + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // & + 0x00, 0x7c, 0x00, 0x44, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' + 0x03, 0xf0, 0x0e, 0x1c, 0x19, 0xe6, 0x17, 0x3a, 0x1c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ( + 0x1c, 0x0e, 0x17, 0x3a, 0x19, 0xe6, 0x0e, 0x1c, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ) + 0x00, 0xfc, 0x00, 0xb4, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xb4, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // * + 0x01, 0xc0, 0x01, 0x40, 0x07, 0x70, 0x04, 0x10, 0x07, 0x70, 0x01, 0x40, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + + 0x1c, 0x00, 0x17, 0x00, 0x19, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // , + 0x01, 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - + 0x0e, 0x00, 0x0a, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // . + 0x1e, 0x00, 0x13, 0x80, 0x1c, 0xe0, 0x07, 0x38, 0x01, 0xce, 0x00, 0x72, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // / + + 0x07, 0xf8, 0x0c, 0x0c, 0x0b, 0xf4, 0x0a, 0x14, 0x0b, 0xf4, 0x0c, 0x0c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0 + 0x0e, 0x70, 0x0a, 0x58, 0x0b, 0xec, 0x08, 0x04, 0x0b, 0xfc, 0x0a, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1 + 0x0e, 0x38, 0x0b, 0x2c, 0x09, 0xb4, 0x0a, 0xd4, 0x0b, 0x74, 0x0b, 0x8c, 0x0e, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 2 + 0x07, 0x38, 0x0d, 0x2c, 0x0b, 0x34, 0x0b, 0xf4, 0x0b, 0x34, 0x0c, 0xcc, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 3 + 0x03, 0xc0, 0x02, 0x70, 0x02, 0x98, 0x0e, 0xec, 0x08, 0x04, 0x0e, 0xfc, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 4 + 0x0e, 0xfc, 0x0a, 0x84, 0x0a, 0xb4, 0x0a, 0xb4, 0x0b, 0xb4, 0x0c, 0x74, 0x07, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 5 + 0x07, 0xf8, 0x0c, 0x0c, 0x0b, 0xb4, 0x0a, 0xb4, 0x0b, 0xb4, 0x0c, 0x74, 0x07, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 6 + 0x00, 0x1c, 0x00, 0x14, 0x0f, 0x94, 0x08, 0xf4, 0x0f, 0x34, 0x01, 0xc4, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 7 + 0x07, 0xf8, 0x0c, 0x4c, 0x0b, 0xb4, 0x0a, 0xb4, 0x0b, 0xb4, 0x0c, 0x4c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8 + 0x0e, 0xf8, 0x0b, 0x8c, 0x0b, 0x74, 0x0b, 0x54, 0x0b, 0x74, 0x0c, 0x0c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9 + 0x0e, 0x1c, 0x0a, 0x14, 0x0e, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // : + 0x1c, 0x00, 0x17, 0x1c, 0x19, 0x14, 0x0f, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ; + 0x03, 0x80, 0x06, 0xc0, 0x0d, 0x60, 0x0b, 0xa0, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // < + 0x0e, 0xe0, 0x0a, 0xa0, 0x0a, 0xa0, 0x0a, 0xa0, 0x0a, 0xa0, 0x0a, 0xa0, 0x0a, 0xa0, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, // = + 0x0e, 0xe0, 0x0b, 0xa0, 0x0d, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // > + 0x00, 0x00, 0x00, 0x1c, 0x0f, 0xd4, 0x0a, 0x74, 0x0f, 0xb4, 0x00, 0xcc, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ? + + 0x0f, 0xf0, 0x18, 0x18, 0x37, 0xec, 0x2c, 0x74, 0x2b, 0xb4, 0x2b, 0xb4, 0x3c, 0x0c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, // @ + 0x0f, 0x80, 0x08, 0xf0, 0x0f, 0x1c, 0x01, 0x64, 0x0f, 0x1c, 0x08, 0xf0, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // A + 0x0f, 0xfc, 0x08, 0x04, 0x0b, 0xb4, 0x0b, 0xb4, 0x0c, 0x4c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // B + 0x07, 0xf8, 0x0c, 0x0c, 0x0b, 0xf4, 0x0a, 0x14, 0x0a, 0x14, 0x0e, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // C + 0x0f, 0xfc, 0x08, 0x04, 0x0b, 0xf4, 0x0b, 0xf4, 0x0c, 0x0c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // D + 0x0f, 0xfc, 0x08, 0x04, 0x0b, 0xb4, 0x0a, 0xb4, 0x0a, 0xb4, 0x0e, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // E + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0xb4, 0x00, 0xb4, 0x00, 0xf4, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // F + 0x07, 0xf8, 0x0c, 0x0c, 0x0b, 0xf4, 0x0b, 0xd4, 0x0b, 0x54, 0x0c, 0x5c, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // G + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0xbc, 0x00, 0xa0, 0x0f, 0xbc, 0x08, 0x04, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // H + 0x0e, 0x1c, 0x0a, 0x14, 0x0b, 0xf4, 0x08, 0x04, 0x0b, 0xf4, 0x0a, 0x14, 0x0e, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // I + 0x0e, 0x1c, 0x0a, 0x14, 0x0b, 0xf4, 0x0c, 0x04, 0x07, 0xf4, 0x00, 0x14, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // J + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0xbc, 0x0e, 0x5c, 0x09, 0xe4, 0x0f, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // K + 0x0f, 0xfc, 0x08, 0x04, 0x0b, 0xfc, 0x0a, 0x00, 0x0a, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // L + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0xec, 0x00, 0xd8, 0x00, 0xb0, 0x00, 0xb0, 0x00, 0xd8, 0x0f, 0xec, 0x08, 0x04, 0x0f, 0xfc, // M + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0xcc, 0x07, 0x38, 0x0c, 0xfc, 0x08, 0x04, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // N + 0x07, 0xf8, 0x0c, 0x0c, 0x0b, 0xf4, 0x0a, 0x14, 0x0a, 0x14, 0x0b, 0xf4, 0x0c, 0x0c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, // O + + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0x74, 0x01, 0x74, 0x01, 0x8c, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // P + 0x07, 0xf8, 0x0c, 0x0c, 0x0b, 0xf4, 0x0a, 0x14, 0x0a, 0x14, 0x1b, 0xf4, 0x14, 0x0c, 0x17, 0xf8, 0x1c, 0x00, 0x00, 0x00, // Q + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0x74, 0x0e, 0x74, 0x09, 0x8c, 0x0f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // R + 0x0e, 0xf8, 0x0b, 0x8c, 0x0b, 0x74, 0x0b, 0x54, 0x0c, 0xd4, 0x07, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // S + 0x00, 0x1c, 0x00, 0x14, 0x0f, 0xf4, 0x08, 0x04, 0x0f, 0xf4, 0x00, 0x14, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // T + 0x07, 0xfc, 0x0c, 0x04, 0x0b, 0xfc, 0x0a, 0x00, 0x0b, 0xfc, 0x0c, 0x04, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U + 0x01, 0xfc, 0x07, 0x04, 0x0c, 0xfc, 0x0b, 0x80, 0x0c, 0xfc, 0x07, 0x04, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // V + 0x01, 0xfc, 0x07, 0x04, 0x0c, 0xfc, 0x0b, 0xc0, 0x0c, 0x40, 0x0b, 0xc0, 0x0c, 0xfc, 0x07, 0x04, 0x01, 0xfc, 0x00, 0x00, // W + 0x0f, 0x3c, 0x09, 0xe4, 0x0e, 0xdc, 0x03, 0x30, 0x0e, 0xdc, 0x09, 0xe4, 0x0f, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // X + 0x00, 0x3c, 0x00, 0xe4, 0x0f, 0x9c, 0x08, 0x70, 0x0f, 0x9c, 0x00, 0xe4, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Y + 0x0f, 0x1c, 0x09, 0x94, 0x0a, 0xf4, 0x0b, 0x34, 0x0b, 0xd4, 0x0a, 0x64, 0x0e, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Z + 0x0f, 0xfc, 0x08, 0x04, 0x0b, 0xf4, 0x0a, 0x14, 0x0e, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x1e, 0x00, 0x72, 0x01, 0xce, 0x07, 0x38, 0x1c, 0xe0, 0x13, 0x80, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // "\" + 0x0e, 0x1c, 0x0a, 0x14, 0x0b, 0xf4, 0x08, 0x04, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x70, 0x00, 0x58, 0x00, 0x6c, 0x00, 0x34, 0x00, 0x6c, 0x00, 0x58, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ + 0x1c, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x14, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, // _ + + 0x00, 0x0e, 0x00, 0x1a, 0x00, 0x36, 0x00, 0x2c, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ` + 0x07, 0xc0, 0x0c, 0x60, 0x0b, 0xa0, 0x0a, 0xa0, 0x0b, 0xa0, 0x0c, 0x60, 0x0b, 0xc0, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, // a + 0x0f, 0xfc, 0x08, 0x04, 0x0b, 0xbc, 0x0b, 0xa0, 0x0c, 0x60, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // b + 0x07, 0xc0, 0x0c, 0x60, 0x0b, 0xa0, 0x0a, 0xa0, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // c + 0x07, 0xc0, 0x0c, 0x60, 0x0b, 0xa0, 0x0b, 0xbc, 0x08, 0x04, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // d + 0x07, 0xc0, 0x0c, 0x60, 0x0a, 0xa0, 0x0a, 0xa0, 0x0b, 0x60, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // e + 0x0f, 0xf8, 0x08, 0x0c, 0x0f, 0xb4, 0x00, 0xf4, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // f + 0x1f, 0xc0, 0x36, 0x60, 0x2d, 0xa0, 0x2d, 0xa0, 0x2d, 0xa0, 0x30, 0x60, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // g + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0xbc, 0x0f, 0xa0, 0x08, 0x60, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // h + 0x0f, 0xf8, 0x08, 0x28, 0x0f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // i + 0x1c, 0x00, 0x14, 0x00, 0x17, 0xf8, 0x18, 0x28, 0x0f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // j + 0x0f, 0xfc, 0x08, 0x04, 0x0e, 0xfc, 0x0d, 0x60, 0x0b, 0xa0, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // k + 0x07, 0xfc, 0x0c, 0x04, 0x0b, 0xfc, 0x0a, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // l + 0x0f, 0xc0, 0x08, 0x60, 0x0f, 0xa0, 0x07, 0xa0, 0x04, 0x60, 0x07, 0xa0, 0x0f, 0xa0, 0x08, 0x60, 0x0f, 0xc0, 0x00, 0x00, // m + 0x0f, 0xc0, 0x08, 0x60, 0x0f, 0xa0, 0x0f, 0xa0, 0x08, 0x60, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // n + 0x07, 0xc0, 0x0c, 0x60, 0x0b, 0xa0, 0x0a, 0xa0, 0x0b, 0xa0, 0x0c, 0x60, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // o + + 0x3f, 0xe0, 0x20, 0x20, 0x3d, 0xa0, 0x05, 0xa0, 0x06, 0x60, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // p + 0x03, 0xc0, 0x06, 0x60, 0x05, 0xa0, 0x3d, 0xa0, 0x20, 0x20, 0x37, 0xe0, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // q + 0x0f, 0xc0, 0x08, 0x60, 0x0f, 0xa0, 0x00, 0xa0, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // r + 0x0f, 0xc0, 0x0b, 0x60, 0x0a, 0xa0, 0x0d, 0xa0, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // s + 0x01, 0xc0, 0x07, 0x70, 0x0c, 0x10, 0x0b, 0x70, 0x0b, 0xc0, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // t + 0x07, 0xe0, 0x0c, 0x20, 0x0b, 0xe0, 0x0b, 0xe0, 0x0c, 0x20, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // u + 0x01, 0xe0, 0x07, 0x20, 0x0c, 0xe0, 0x0b, 0x80, 0x0c, 0xe0, 0x07, 0x20, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // v + 0x01, 0xe0, 0x07, 0x20, 0x0c, 0xe0, 0x0b, 0x80, 0x0c, 0x80, 0x0b, 0x80, 0x0c, 0xe0, 0x07, 0x20, 0x01, 0xe0, 0x00, 0x00, // w + 0x0e, 0xe0, 0x0b, 0xa0, 0x0d, 0x60, 0x06, 0xc0, 0x0d, 0x60, 0x0b, 0xa0, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // x + 0x1d, 0xe0, 0x17, 0x20, 0x1a, 0xe0, 0x0d, 0x80, 0x06, 0xe0, 0x03, 0x20, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // y + 0x0e, 0xe0, 0x0b, 0xa0, 0x09, 0xa0, 0x0a, 0xa0, 0x0b, 0x20, 0x0b, 0xa0, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // z + 0x01, 0xe0, 0x0f, 0x3c, 0x18, 0xc6, 0x17, 0xfa, 0x1c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x1f, 0xfe, 0x10, 0x02, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // | + 0x1c, 0x0e, 0x17, 0xfa, 0x18, 0xc6, 0x0f, 0x3c, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x03, 0x80, 0x02, 0xc0, 0x03, 0x40, 0x03, 0x40, 0x02, 0xc0, 0x02, 0xc0, 0x03, 0x40, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, // ~ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + // Extra + 0x0f, 0x80, 0x08, 0xf0, 0x0f, 0x1c, 0x01, 0x64, 0x08, 0x04, 0x0b, 0xb4, 0x0a, 0xb4, 0x0a, 0xb4, 0x0e, 0xfc, 0x00, 0x00, // Æ + 0x3f, 0xe0, 0x20, 0x20, 0x3d, 0xa0, 0x05, 0xa0, 0x06, 0x60, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Þ + 0x0f, 0xfc, 0x08, 0x04, 0x0f, 0xb4, 0x0b, 0xb4, 0x0c, 0x4c, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ß + 0x07, 0xc0, 0x0c, 0x60, 0x0b, 0xa0, 0x0a, 0xa0, 0x0b, 0xa0, 0x0c, 0x60, 0x0a, 0xa0, 0x0a, 0xa0, 0x0b, 0x60, 0x0f, 0xc0, // æ + 0x3f, 0xe0, 0x20, 0x20, 0x3d, 0xa0, 0x05, 0xa0, 0x06, 0x60, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // þ + // Accents + Offsets + // All chars are shifted 8px down into a 32 pixel canvas for combining with accents. + // Accent shift values (the first two numbers in each line below) move the accent down to meet them. + // These are the shift values for lower and UPPER case letters respectively. + 9,6, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Grave + 9,6, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Acute + 9,6, 0x00, 0x02, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Circumflex + 9,6, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // Tilde + 10,7, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Diaresis + 9,6, 0x00, 0x02, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Ring Above + 12,10, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, // Stroke + 16,16, 0x00, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Cedilla + } +}; \ No newline at end of file diff --git a/libraries/bitmap_fonts/font6_data.hpp b/libraries/bitmap_fonts/font6_data.hpp index 4f95992c..020486b5 100644 --- a/libraries/bitmap_fonts/font6_data.hpp +++ b/libraries/bitmap_fonts/font6_data.hpp @@ -5,9 +5,6 @@ const bitmap::font_t font6 { .height = 6, .max_width = 6, - .accent_offset_upper = 2, - .accent_offset_lower = 2, - .accent_offset_below = 2, .widths = { 3, 2, 4, 6, 6, 6, 7, 2, 3, 3, 4, 4, 2, 4, 2, 4, 6, 3, 5, 5, 6, 5, 6, 6, 6, 6, 2, 2, 4, 4, 4, 5, @@ -15,7 +12,7 @@ const bitmap::font_t font6 { 6, 6, 6, 5, 6, 6, 6, 6, 5, 5, 5, 3, 4, 3, 4, 4, 3, 6, 6, 5, 6, 5, 5, 6, 5, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 5, 5, 5, 4, 2, 4, 4, 2, - 6, 6, 6, 6, 6 // Extra + 6, 5, 5, 6, 5 // Extra }, .data = { 0x00,0x00,0x00,0x00,0x00,0x00, // @@ -115,19 +112,22 @@ const bitmap::font_t font6 { 0x04,0x02,0x02,0x00,0x00,0x00, // ~ 0x00,0x00,0x00,0x00,0x00,0x00, // Extra - 0x00,0x00,0x00,0x00,0x00,0x00, // Æ - 0x00,0x00,0x00,0x00,0x00,0x00, // Þ - 0x00,0x00,0x00,0x00,0x00,0x00, // ß - 0x00,0x00,0x00,0x00,0x00,0x00, // æ - 0x00,0x00,0x00,0x00,0x00,0x00, // þ - // Accents - 0x00,0x00,0x01,0x02,0x00,0x00, // Grave - 0x00,0x00,0x02,0x01,0x00,0x00, // Acute - 0x00,0x02,0x01,0x02,0x00,0x00, // Circumflex - 0x00,0x01,0x02,0x01,0x02,0x00, // Tilde - 0x00,0x01,0x00,0x01,0x00,0x00, // Diaresis - 0x00,0x02,0x05,0x02,0x00,0x00, // Ring Above - 0x00,0x40,0x20,0x10,0x00,0x00, // Stroke - 0x00,0x00,0x28,0x10,0x00,0x00 // Cedilla + 0x3c,0x12,0x3c,0x2a,0x2a,0x00, // Æ + 0x3f,0x12,0x12,0x12,0x0e,0x00, // Þ + 0x3e,0x0a,0x2a,0x34,0x00,0x00, // ß + 0x3c,0x12,0x3c,0x2a,0x2a,0x00, // æ + 0x3f,0x12,0x12,0x12,0x0e,0x00, // þ + // Accents + Offsets + // All chars are shifted 8px down into a 32 pixel canvas for combining with accents. + // Accent shift values (the first two numbers in each line below) move the accent down to meet them. + // These are the shift values for lower and UPPER case letters respectively. + 6,6, 0x00,0x00,0x01,0x02,0x00,0x00, // Grave + 6,6, 0x00,0x00,0x02,0x01,0x00,0x00, // Acute + 6,6, 0x00,0x02,0x01,0x02,0x00,0x00, // Circumflex + 6,6, 0x00,0x01,0x02,0x01,0x02,0x00, // Tilde + 6,6, 0x00,0x01,0x00,0x01,0x00,0x00, // Diaresis + 6,6, 0x00,0x02,0x05,0x02,0x00,0x00, // Ring Above + 6,6, 0x00,0x40,0x20,0x10,0x00,0x00, // Stroke + 10,10, 0x00,0x00,0x28,0x10,0x00,0x00 // Cedilla } }; \ No newline at end of file diff --git a/libraries/bitmap_fonts/font8_data.hpp b/libraries/bitmap_fonts/font8_data.hpp index b4585df4..f5732640 100644 --- a/libraries/bitmap_fonts/font8_data.hpp +++ b/libraries/bitmap_fonts/font8_data.hpp @@ -5,9 +5,6 @@ const bitmap::font_t font8 { .height = 8, .max_width = 6, - .accent_offset_upper = 2, - .accent_offset_lower = 1, - .accent_offset_below = 1, .widths = { 2, 2, 4, 6, 5, 5, 5, 2, 4, 4, 4, 4, 3, 4, 3, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 2, 3, 4, 4, 4, 5, @@ -120,14 +117,17 @@ const bitmap::font_t font8 { 0x7e,0x09,0x49,0x36,0x00,0x00, // ß 0x20,0x54,0x78,0x54,0x58,0x00, // æ 0x7f,0x24,0x24,0x18,0x00,0x00, // þ - // Accents - 0x00,0x00,0x01,0x02,0x00,0x00, // Grave - 0x00,0x00,0x02,0x01,0x00,0x00, // Acute - 0x00,0x02,0x01,0x02,0x00,0x00, // Circumflex - 0x00,0x01,0x02,0x01,0x02,0x00, // Tilde - 0x00,0x01,0x00,0x01,0x00,0x00, // Diaresis - 0x00,0x02,0x05,0x02,0x00,0x00, // Ring Above - 0x00,0x40,0x20,0x00,0x00,0x00, // Stroke - 0x00,0x00,0xa0,0x40,0x00,0x00 // Cedilla + // Accents + Offsets + // All chars are shifted 8px down into a 32 pixel canvas for combining with accents. + // Accent shift values (the first two numbers in each line below) move the accent down to meet them. + // These are the shift values for lower and UPPER case letters respectively. + 6,4, 0x00,0x00,0x01,0x02,0x00,0x00, // Grave + 6,4, 0x00,0x00,0x02,0x01,0x00,0x00, // Acute + 6,4, 0x00,0x02,0x01,0x02,0x00,0x00, // Circumflex + 6,4, 0x00,0x01,0x02,0x01,0x02,0x00, // Tilde + 6,4, 0x00,0x01,0x00,0x01,0x00,0x00, // Diaresis + 6,4, 0x00,0x02,0x05,0x02,0x00,0x00, // Ring Above + 6,4, 0x00,0x80,0x40,0x00,0x00,0x00, // Stroke + 9,9, 0x00,0x00,0xa0,0x40,0x00,0x00 // Cedilla } }; \ No newline at end of file