Merge tag '2.1.2'
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# Generate a 'HZK' font file for the T5UIC1 DWIN LCD
|
||||
# from multiple bdf font files.
|
||||
# Note: the 16x16 glyphs are not produced
|
||||
# Author: Taylor Talkington
|
||||
# License: GPL
|
||||
|
||||
import bdflib.reader
|
||||
import math
|
||||
|
||||
def glyph_bits(size_x, size_y, font, glyph_ord):
|
||||
asc = font[b'FONT_ASCENT']
|
||||
desc = font[b'FONT_DESCENT']
|
||||
bits = [0 for y in range(size_y)]
|
||||
|
||||
glyph_bytes = math.ceil(size_x / 8)
|
||||
try:
|
||||
glyph = font[glyph_ord]
|
||||
for y, row in enumerate(glyph.data):
|
||||
v = row
|
||||
rpad = size_x - glyph.bbW
|
||||
if rpad < 0: rpad = 0
|
||||
if glyph.bbW > size_x: v = v >> (glyph.bbW - size_x) # some glyphs are actually too wide to fit!
|
||||
v = v << (glyph_bytes * 8) - size_x + rpad
|
||||
v = v >> glyph.bbX
|
||||
bits[y + desc + glyph.bbY] |= v
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
bits.reverse()
|
||||
return bits
|
||||
|
||||
def marlin_font_hzk():
|
||||
fonts = [
|
||||
[6,12,'marlin-6x12-3.bdf'],
|
||||
[8,16,'marlin-8x16.bdf'],
|
||||
[10,20,'marlin-10x20.bdf'],
|
||||
[12,24,'marlin-12x24.bdf'],
|
||||
[14,28,'marlin-14x28.bdf'],
|
||||
[16,32,'marlin-16x32.bdf'],
|
||||
[20,40,'marlin-20x40.bdf'],
|
||||
[24,48,'marlin-24x48.bdf'],
|
||||
[28,56,'marlin-28x56.bdf'],
|
||||
[32,64,'marlin-32x64.bdf']
|
||||
]
|
||||
|
||||
with open('marlin_fixed.hzk','wb') as output:
|
||||
for f in fonts:
|
||||
with open(f[2], 'rb') as file:
|
||||
print(f'{f[0]}x{f[1]}')
|
||||
font = bdflib.reader.read_bdf(file)
|
||||
for glyph in range(128):
|
||||
bits = glyph_bits(f[0], f[1], font, glyph)
|
||||
glyph_bytes = math.ceil(f[0]/8)
|
||||
|
||||
for b in bits:
|
||||
try:
|
||||
z = b.to_bytes(glyph_bytes, 'big')
|
||||
output.write(z)
|
||||
except OverflowError:
|
||||
print('Overflow')
|
||||
print(f'{glyph}')
|
||||
print(font[glyph])
|
||||
for b in bits: print(f'{b:0{f[0]}b}')
|
||||
return
|
||||
@@ -57,12 +57,12 @@ OLDWD=`pwd`
|
||||
#
|
||||
# Compile the 'genpages' command in-place
|
||||
#
|
||||
(cd ${DN_EXEC}; gcc -o genpages genpages.c getline.c)
|
||||
(cd ${DN_EXEC}; cc -o genpages genpages.c getline.c)
|
||||
|
||||
#
|
||||
# By default loop through all languages
|
||||
#
|
||||
LANGS_DEFAULT="an bg ca cz da de el el_gr en es eu fi fr gl hr hu it jp_kana ko_KR nl pl pt pt_br ro ru sk tr uk vi zh_CN zh_TW test"
|
||||
LANGS_DEFAULT="an bg ca cz da de el el_CY en es eu fi fr gl hr hu it jp_kana ko_KR nl pl pt pt_br ro ru sk sv tr uk vi zh_CN zh_TW test"
|
||||
|
||||
#
|
||||
# Generate data for language list MARLIN_LANGS or all if not provided
|
||||
@@ -105,6 +105,9 @@ if [ 1 = 1 ]; then
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -119,7 +122,8 @@ if [ 1 = 1 ]; then
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include <U8glib.h>
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
|
||||
#if defined(__AVR__) && ENABLED(NOT_EXTENDED_ISO10646_1_5X7)
|
||||
// reduced font (only symbols 1 - 127) - saves about 1278 bytes of FLASH
|
||||
|
||||
@@ -66,68 +66,54 @@ wchar_t get_val_utf82uni(uint8_t *pstart) {
|
||||
*/
|
||||
uint8_t* get_utf8_value(uint8_t *pstart, wchar_t *pval) {
|
||||
uint32_t val = 0;
|
||||
uint8_t *p = pstart;
|
||||
const uint8_t *p = pstart;
|
||||
/*size_t maxlen = strlen(pstart);*/
|
||||
|
||||
assert(NULL != pstart);
|
||||
|
||||
#define NEXT_6_BITS() do{ val <<= 6; p++; val |= (*p & 0x3F); }while(0)
|
||||
|
||||
if (0 == (0x80 & *p)) {
|
||||
val = (size_t)*p;
|
||||
p++;
|
||||
}
|
||||
else if (0xC0 == (0xE0 & *p)) {
|
||||
val = *p & 0x1F;
|
||||
val <<= 6;
|
||||
p++;
|
||||
val |= (*p & 0x3F);
|
||||
NEXT_6_BITS();
|
||||
p++;
|
||||
assert((wchar_t)val == get_val_utf82uni(pstart));
|
||||
}
|
||||
else if (0xE0 == (0xF0 & *p)) {
|
||||
val = *p & 0x0F;
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
p++;
|
||||
assert((wchar_t)val == get_val_utf82uni(pstart));
|
||||
}
|
||||
else if (0xF0 == (0xF8 & *p)) {
|
||||
val = *p & 0x07;
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
p++;
|
||||
assert((wchar_t)val == get_val_utf82uni(pstart));
|
||||
}
|
||||
else if (0xF8 == (0xFC & *p)) {
|
||||
val = *p & 0x03;
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
p++;
|
||||
assert((wchar_t)val == get_val_utf82uni(pstart));
|
||||
}
|
||||
else if (0xFC == (0xFE & *p)) {
|
||||
val = *p & 0x01;
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
val <<= 6; p++;
|
||||
val |= (*p & 0x3F);
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
NEXT_6_BITS();
|
||||
p++;
|
||||
assert((wchar_t)val == get_val_utf82uni(pstart));
|
||||
}
|
||||
@@ -156,12 +142,12 @@ uint8_t* get_utf8_value(uint8_t *pstart, wchar_t *pval) {
|
||||
return p;
|
||||
}
|
||||
|
||||
void usage(char* progname) {
|
||||
void usage(char *progname) {
|
||||
fprintf(stderr, "usage: %s\n", progname);
|
||||
fprintf(stderr, " read data from stdin\n");
|
||||
}
|
||||
|
||||
void utf8_parse(const char* msg, unsigned int len) {
|
||||
void utf8_parse(const char *msg, unsigned int len) {
|
||||
uint8_t *pend = NULL;
|
||||
uint8_t *p;
|
||||
uint8_t *pre;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -169,7 +169,7 @@ cat <<EOF >fontutf8-data.h
|
||||
* Contents will be REPLACED by future processing!
|
||||
* Use genallfont.sh to generate font data for updated languages.
|
||||
*/
|
||||
#include <U8glib.h>
|
||||
#include <U8glib-HAL.h>
|
||||
$TMPA
|
||||
#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data }
|
||||
static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {$TMPB};
|
||||
|
||||
Reference in New Issue
Block a user