Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion wled00/FX_2Dfcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,15 @@ 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"
#include "src/font/console_font_6x8.h"
#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
Expand All @@ -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
Expand Down
141 changes: 141 additions & 0 deletions wled00/src/font/clear_3x5.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
** 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 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you deleted a few too much now...
WLED expects the array to have all chars from 0x20 thru 0x7E

if (chr < 32 || chr > 126) return; // only ASCII 32-126 supported

So your table needs to have everything up to 126 = 0x7E.
Please re-add the missing 4 chars. We want to avoid crashing due to array-out-of-bounds read.

};