Add small 5x3 font

This commit is contained in:
David 2023-08-20 12:54:21 +02:00
parent bf452e922a
commit 70972ab6fd
3 changed files with 242 additions and 7 deletions

View File

@ -5847,13 +5847,14 @@ uint16_t mode_2Dscrollingtext(void) {
int letterWidth;
int letterHeight;
switch (map(SEGMENT.custom2, 0, 255, 1, 5)) {
switch (map(SEGMENT.custom2, 0, 255, 1, 6)) {
default:
case 1: letterWidth = 4; letterHeight = 6; break;
case 2: letterWidth = 5; letterHeight = 8; break;
case 3: letterWidth = 6; letterHeight = 8; break;
case 4: letterWidth = 7; letterHeight = 9; break;
case 5: letterWidth = 5; letterHeight = 12; break;
case 1: letterWidth = 3; letterHeight = 5; break;
case 2: letterWidth = 4; letterHeight = 6; break;
case 3: letterWidth = 5; letterHeight = 8; break;
case 4: letterWidth = 6; letterHeight = 8; break;
case 5: letterWidth = 7; letterHeight = 9; break;
case 6: letterWidth = 5; letterHeight = 12; break;
}
const bool zero = SEGMENT.check3;
const int yoffset = map(SEGMENT.intensity, 0, 255, -rows/2, rows/2) + (rows-letterHeight)/2;

View File

@ -557,6 +557,7 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint3
}
}
#include "src/font/clear_3x5.h"
#include "src/font/console_font_4x6.h"
#include "src/font/console_font_5x8.h"
#include "src/font/console_font_5x12.h"
@ -564,7 +565,7 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint3
#include "src/font/console_font_7x9.h"
// draws a raster font character on canvas
// only supports: 4x6=24, 5x8=40, 5x12=60, 6x8=48 and 7x9=63 fonts ATM
// only supports: 3x5=15, 4x6=24, 5x8=40, 5x12=60, 6x8=48 and 7x9=63 fonts ATM
void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2) {
if (!isActive()) return; // not active
if (chr < 32 || chr > 126) return; // only ASCII 32-126 supported
@ -583,6 +584,7 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
if (y0 >= rows) break; // drawing off-screen
uint8_t bits = 0;
switch (font) {
case 15: bits = pgm_read_byte_near(&clear_3x5[(chr * h) + i]); break; // 3x5 font
case 24: bits = pgm_read_byte_near(&console_font_4x6[(chr * h) + i]); break; // 5x8 font
case 40: bits = pgm_read_byte_near(&console_font_5x8[(chr * h) + i]); break; // 5x8 font
case 48: bits = pgm_read_byte_near(&console_font_6x8[(chr * h) + i]); break; // 6x8 font

232
wled00/src/font/clear_3x5.h Normal file
View File

@ -0,0 +1,232 @@
/**
** The original 3x5 font is licensed under the 3-clause BSD license:
**
** Copyright 1999 Brian J. Swetland
** Copyright 1999 Vassilii Khachaturov
** Portions (of vt100.c/vt100.h) copyright Dan Marks
**
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions, and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions, and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the authors may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
** Modifications to Tom Thumb for improved readability are from Robey Pointer,
** see:
** http://robey.lag.net/2010/01/23/tiny-monospace-font.html
**
** The original author does not have any objection to relicensing of Robey
** Pointer's modifications (in this file) in a more permissive license. See
** the discussion at the above blog, and also here:
** http://opengameart.org/forumtopic/how-to-submit-art-using-the-3-clause-bsd-license
**
** Feb 21, 2016: Conversion from Linux BDF --> Adafruit GFX font,
** with the help of this Python script:
** https://gist.github.com/skelliam/322d421f028545f16f6d
** William Skellenger (williamj@skellenger.net)
** Twitter: @skelliam
**
*/
static const unsigned char clear_3x5[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 space */
0x80, 0x80, 0x80, 0x00, 0x80, /* 0x21 exclam */
0xA0, 0xA0, 0x00, 0x00, 0x00, /* 0x22 quotedbl */
0xA0, 0xE0, 0xA0, 0xE0, 0xA0, /* 0x23 numbersign */
0x60, 0xC0, 0x60, 0xC0, 0x40, /* 0x24 dollar */
0x80, 0x20, 0x40, 0x80, 0x20, /* 0x25 percent */
0xC0, 0xC0, 0xE0, 0xA0, 0x60, /* 0x26 ampersand */
0x80, 0x80, 0x00, 0x00, 0x00, /* 0x27 quotesingle */
0x40, 0x80, 0x80, 0x80, 0x40, /* 0x28 parenleft */
0x80, 0x40, 0x40, 0x40, 0x80, /* 0x29 parenright */
0xA0, 0x40, 0xA0, 0x00, 0x00, /* 0x2A asterisk */
0x40, 0xE0, 0x40, 0x00, 0x00, /* 0x2B plus */
0x40, 0x80, 0x00, 0x00, 0x00, /* 0x2C comma */
0xE0, 0x00, 0x00, 0x00, 0x00, /* 0x2D hyphen */
0x80, 0x00, 0x00, 0x00, 0x00, /* 0x2E period */
0x20, 0x20, 0x40, 0x80, 0x80, /* 0x2F slash */
0xE0, 0xA0, 0xA0, 0xA0, 0xE0, /* 0x30 zero */
0x40, 0xC0, 0x40, 0x40, 0xE0, /* 0x31 one */
0xE0, 0x20, 0xE0, 0x80, 0xE0, /* 0x32 two */
0xE0, 0x20, 0xE0, 0x20, 0xE0, /* 0x33 three */
0xA0, 0xA0, 0xE0, 0x20, 0x20, /* 0x34 four */
0xE0, 0x80, 0xE0, 0x20, 0xE0, /* 0x35 five */
0xE0, 0x80, 0xE0, 0xA0, 0xE0, /* 0x36 six */
0xE0, 0x20, 0x20, 0x20, 0x20, /* 0x37 seven */
0xE0, 0xA0, 0xE0, 0xA0, 0xE0, /* 0x38 eight */
0xE0, 0xA0, 0xE0, 0x20, 0xE0, /* 0x39 nine */
0x00, 0x40, 0x00, 0x40, 0x00, /* 0x3A colon */
0x40, 0x00, 0x40, 0x80, 0x00, /* 0x3B semicolon */
0x20, 0x40, 0x80, 0x40, 0x20, /* 0x3C less */
0xE0, 0x00, 0xE0, 0x00, 0x00, /* 0x3D equal */
0x80, 0x40, 0x20, 0x40, 0x80, /* 0x3E greater */
0xE0, 0x20, 0x40, 0x00, 0x40, /* 0x3F question */
0x40, 0xA0, 0xE0, 0x80, 0x60, /* 0x40 at */
0x40, 0xA0, 0xE0, 0xA0, 0xA0, /* 0x41 A */
0xC0, 0xA0, 0xC0, 0xA0, 0xC0, /* 0x42 B */
0x60, 0x80, 0x80, 0x80, 0x60, /* 0x43 C */
0xC0, 0xA0, 0xA0, 0xA0, 0xC0, /* 0x44 D */
0xE0, 0x80, 0xE0, 0x80, 0xE0, /* 0x45 E */
0xE0, 0x80, 0xE0, 0x80, 0x80, /* 0x46 F */
0x60, 0x80, 0xE0, 0xA0, 0x60, /* 0x47 G */
0xA0, 0xA0, 0xE0, 0xA0, 0xA0, /* 0x48 H */
0xE0, 0x40, 0x40, 0x40, 0xE0, /* 0x49 I */
0x20, 0x20, 0x20, 0xA0, 0x40, /* 0x4A J */
0xA0, 0xA0, 0xC0, 0xA0, 0xA0, /* 0x4B K */
0x80, 0x80, 0x80, 0x80, 0xE0, /* 0x4C L */
0xA0, 0xE0, 0xE0, 0xA0, 0xA0, /* 0x4D M */
0xA0, 0xE0, 0xE0, 0xE0, 0xA0, /* 0x4E N */
0x40, 0xA0, 0xA0, 0xA0, 0x40, /* 0x4F O */
0xC0, 0xA0, 0xC0, 0x80, 0x80, /* 0x50 P */
0x40, 0xA0, 0xA0, 0xE0, 0x60, /* 0x51 Q */
0xC0, 0xA0, 0xE0, 0xC0, 0xA0, /* 0x52 R */
0x60, 0x80, 0x40, 0x20, 0xC0, /* 0x53 S */
0xE0, 0x40, 0x40, 0x40, 0x40, /* 0x54 T */
0xA0, 0xA0, 0xA0, 0xA0, 0x60, /* 0x55 U */
0xA0, 0xA0, 0xA0, 0x40, 0x40, /* 0x56 V */
0xA0, 0xA0, 0xE0, 0xE0, 0xA0, /* 0x57 W */
0xA0, 0xA0, 0x40, 0xA0, 0xA0, /* 0x58 X */
0xA0, 0xA0, 0x40, 0x40, 0x40, /* 0x59 Y */
0xE0, 0x20, 0x40, 0x80, 0xE0, /* 0x5A Z */
0xE0, 0x80, 0x80, 0x80, 0xE0, /* 0x5B bracketleft */
0x80, 0x40, 0x20, 0x00, 0x00, /* 0x5C backslash */
0xE0, 0x20, 0x20, 0x20, 0xE0, /* 0x5D bracketright */
0x40, 0xA0, 0x00, 0x00, 0x00, /* 0x5E asciicircum */
0xE0, 0x00, 0x00, 0x00, 0x00, /* 0x5F underscore */
0x80, 0x40, 0x00, 0x00, 0x00, /* 0x60 grave */
0xC0, 0x60, 0xA0, 0xE0, 0x00, /* 0x61 a */
0x80, 0xC0, 0xA0, 0xA0, 0xC0, /* 0x62 b */
0x60, 0x80, 0x80, 0x60, 0x00, /* 0x63 c */
0x20, 0x60, 0xA0, 0xA0, 0x60, /* 0x64 d */
0x60, 0xA0, 0xC0, 0x60, 0x00, /* 0x65 e */
0x20, 0x40, 0xE0, 0x40, 0x40, /* 0x66 f */
0x60, 0xA0, 0xE0, 0x20, 0x40, /* 0x67 g */
0x80, 0xC0, 0xA0, 0xA0, 0xA0, /* 0x68 h */
0x80, 0x00, 0x80, 0x80, 0x80, /* 0x69 i */
0x20, 0x00, 0x20, 0xA0, 0x40, /* 0x6A j */
0x80, 0xA0, 0xC0, 0xC0, 0xA0, /* 0x6B k */
0xC0, 0x40, 0x40, 0x40, 0xE0, /* 0x6C l */
0xE0, 0xE0, 0xE0, 0xA0, 0x00, /* 0x6D m */
0xC0, 0xA0, 0xA0, 0xA0, 0x00, /* 0x6E n */
0x40, 0xA0, 0xA0, 0x40, 0x00, /* 0x6F o */
0xC0, 0xA0, 0xA0, 0xC0, 0x80, /* 0x70 p */
0x60, 0xA0, 0xA0, 0x60, 0x20, /* 0x71 q */
0x40, 0x80, 0x80, 0x80, 0x00, /* 0x72 r */
0x60, 0xC0, 0x60, 0xC0, 0x00, /* 0x73 s */
0x40, 0xE0, 0x40, 0x40, 0x60, /* 0x74 t */
0xA0, 0xA0, 0xA0, 0x60, 0x00, /* 0x75 u */
0xA0, 0xA0, 0xE0, 0x40, 0x00, /* 0x76 v */
0xA0, 0xE0, 0xE0, 0xE0, 0x00, /* 0x77 w */
0xA0, 0x40, 0x40, 0xA0, 0x00, /* 0x78 x */
0xA0, 0xA0, 0x60, 0x20, 0x40, /* 0x79 y */
0xE0, 0x60, 0xC0, 0xE0, 0x00, /* 0x7A z */
0x60, 0x40, 0x80, 0x40, 0x60, /* 0x7B braceleft */
0x80, 0x80, 0x00, 0x80, 0x80, /* 0x7C bar */
0xC0, 0x40, 0x20, 0x40, 0xC0, /* 0x7D braceright */
0x60, 0xC0, 0x00, 0x00, 0x00, /* 0x7E asciitilde */
0x80, 0x00, 0x80, 0x80, 0x80, /* 0xA1 exclamdown */
0x40, 0xE0, 0x80, 0xE0, 0x40, /* 0xA2 cent */
0x60, 0x40, 0xE0, 0x40, 0xE0, /* 0xA3 sterling */
0xA0, 0x40, 0xE0, 0x40, 0xA0, /* 0xA4 currency */
0xA0, 0xA0, 0x40, 0xE0, 0x40, /* 0xA5 yen */
0x80, 0x80, 0x00, 0x80, 0x80, /* 0xA6 brokenbar */
0x60, 0x40, 0xA0, 0x40, 0xC0, /* 0xA7 section */
0xA0, 0x00, 0x00, 0x00, 0x00, /* 0xA8 dieresis */
0x60, 0x80, 0x60, 0x00, 0x00, /* 0xA9 copyright */
0x60, 0xA0, 0xE0, 0x00, 0xE0, /* 0xAA ordfeminine */
0x40, 0x80, 0x40, 0x00, 0x00, /* 0xAB guillemotleft */
0xE0, 0x20, 0x00, 0x00, 0x00, /* 0xAC logicalnot */
0xC0, 0x00, 0x00, 0x00, 0x00, /* 0xAD softhyphen */
0xC0, 0xC0, 0xA0, 0x00, 0x00, /* 0xAE registered */
0xE0, 0x00, 0x00, 0x00, 0x00, /* 0xAF macron */
0x40, 0xA0, 0x40, 0x00, 0x00, /* 0xB0 degree */
0x40, 0xE0, 0x40, 0x00, 0xE0, /* 0xB1 plusminus */
0xC0, 0x40, 0x60, 0x00, 0x00, /* 0xB2 twosuperior */
0xE0, 0x60, 0xE0, 0x00, 0x00, /* 0xB3 threesuperior */
0x40, 0x80, 0x00, 0x00, 0x00, /* 0xB4 acute */
0xA0, 0xA0, 0xA0, 0xC0, 0x80, /* 0xB5 mu */
0x60, 0xA0, 0x60, 0x60, 0x60, /* 0xB6 paragraph */
0xE0, 0xE0, 0xE0, 0x00, 0x00, /* 0xB7 periodcentered */
0x40, 0x20, 0xC0, 0x00, 0x00, /* 0xB8 cedilla */
0x80, 0x80, 0x80, 0x00, 0x00, /* 0xB9 onesuperior */
0x40, 0xA0, 0x40, 0x00, 0xE0, /* 0xBA ordmasculine */
0x80, 0x40, 0x80, 0x00, 0x00, /* 0xBB guillemotright */
0x80, 0x80, 0x00, 0x60, 0x20, /* 0xBC onequarter */
0x80, 0x80, 0x00, 0xC0, 0x60, /* 0xBD onehalf */
0xC0, 0xC0, 0x00, 0x60, 0x20, /* 0xBE threequarters */
0x40, 0x00, 0x40, 0x80, 0xE0, /* 0xBF questiondown */
0x40, 0x20, 0x40, 0xE0, 0xA0, /* 0xC0 Agrave */
0x40, 0x80, 0x40, 0xE0, 0xA0, /* 0xC1 Aacute */
0xE0, 0x00, 0x40, 0xE0, 0xA0, /* 0xC2 Acircumflex */
0x60, 0xC0, 0x40, 0xE0, 0xA0, /* 0xC3 Atilde */
0xA0, 0x40, 0xA0, 0xE0, 0xA0, /* 0xC4 Adieresis */
0xC0, 0xC0, 0xA0, 0xE0, 0xA0, /* 0xC5 Aring */
0x60, 0xC0, 0xE0, 0xC0, 0xE0, /* 0xC6 AE */
0x60, 0x80, 0x60, 0x20, 0x40, /* 0xC7 Ccedilla */
0x40, 0x20, 0xE0, 0xC0, 0xE0, /* 0xC8 Egrave */
0x40, 0x80, 0xE0, 0xC0, 0xE0, /* 0xC9 Eacute */
0xE0, 0x00, 0xE0, 0xC0, 0xE0, /* 0xCA Ecircumflex */
0xA0, 0x00, 0xE0, 0xC0, 0xE0, /* 0xCB Edieresis */
0x40, 0x20, 0xE0, 0x40, 0xE0, /* 0xCC Igrave */
0x40, 0x80, 0xE0, 0x40, 0xE0, /* 0xCD Iacute */
0xE0, 0x00, 0xE0, 0x40, 0xE0, /* 0xCE Icircumflex */
0xA0, 0x00, 0xE0, 0x40, 0xE0, /* 0xCF Idieresis */
0xC0, 0xA0, 0xE0, 0xA0, 0xC0, /* 0xD0 Eth */
0xC0, 0x60, 0xA0, 0xE0, 0xA0, /* 0xD1 Ntilde */
0x40, 0x20, 0xE0, 0xA0, 0xE0, /* 0xD2 Ograve */
0x40, 0x80, 0xE0, 0xA0, 0xE0, /* 0xD3 Oacute */
0xE0, 0x00, 0xE0, 0xA0, 0xE0, /* 0xD4 Ocircumflex */
0xC0, 0x60, 0xE0, 0xA0, 0xE0, /* 0xD5 Otilde */
0xA0, 0x00, 0xE0, 0xA0, 0xE0, /* 0xD6 Odieresis */
0xA0, 0x40, 0xA0, 0x00, 0x00, /* 0xD7 multiply */
0x60, 0xA0, 0xE0, 0xA0, 0xC0, /* 0xD8 Oslash */
0x80, 0x40, 0xA0, 0xA0, 0xE0, /* 0xD9 Ugrave */
0x20, 0x40, 0xA0, 0xA0, 0xE0, /* 0xDA Uacute */
0xE0, 0x00, 0xA0, 0xA0, 0xE0, /* 0xDB Ucircumflex */
0xA0, 0x00, 0xA0, 0xA0, 0xE0, /* 0xDC Udieresis */
0x20, 0x40, 0xA0, 0xE0, 0x40, /* 0xDD Yacute */
0x80, 0xE0, 0xA0, 0xE0, 0x80, /* 0xDE Thorn */
0x60, 0xA0, 0xC0, 0xC0, 0x80, /* 0xDF germandbls */
0x40, 0x20, 0x60, 0xA0, 0xE0, /* 0xE0 agrave */
0x40, 0x80, 0x60, 0xA0, 0xE0, /* 0xE1 aacute */
0xE0, 0x00, 0x60, 0xA0, 0xE0, /* 0xE2 acircumflex */
0x60, 0xC0, 0x60, 0xA0, 0xE0, /* 0xE3 atilde */
0xA0, 0x00, 0x60, 0xA0, 0xE0, /* 0xE4 adieresis */
0x60, 0x60, 0x60, 0xA0, 0xE0, /* 0xE5 aring */
0x60, 0xE0, 0xE0, 0xC0, 0x00, /* 0xE6 ae */
0x60, 0x80, 0x60, 0x20, 0x40, /* 0xE7 ccedilla */
0x40, 0x20, 0x60, 0xE0, 0x60, /* 0xE8 egrave */
0x40, 0x80, 0x60, 0xE0, 0x60, /* 0xE9 eacute */
0xE0, 0x00, 0x60, 0xE0, 0x60, /* 0xEA ecircumflex */
0xA0, 0x00, 0x60, 0xE0, 0x60, /* 0xEB edieresis */
0x80, 0x40, 0x80, 0x80, 0x80, /* 0xEC igrave */
0x40, 0x80, 0x40, 0x40, 0x40, /* 0xED iacute */
0xE0, 0x00, 0x40, 0x40, 0x40, /* 0xEE icircumflex */
0xA0, 0x00, 0x40, 0x40, 0x40, /* 0xEF idieresis */
0x60, 0xC0, 0x60, 0xA0, 0x60, /* 0xF0 eth */
0xC0, 0x60, 0xC0, 0xA0, 0xA0, /* 0xF1 ntilde */
0x40, 0x20, 0x40, 0xA0, 0x40, /* 0xF2 ograve */
0x40, 0x80, 0x40, 0xA0, 0x40, /* 0xF3 oacute */
0xE0, 0x00, 0x40, 0xA0, 0x40, /* 0xF4 ocircumflex */
0xC0, 0x60, 0x40, 0xA0, 0x40, /* 0xF5 otilde */
0xA0, 0x00, 0x40, 0xA0, 0x40, /* 0xF6 odieresis */
0x40, 0x00, 0xE0, 0x00, 0x40, /* 0xF7 divide */
};