Add openhasp.ttf

This commit is contained in:
fvanroie 2022-11-26 00:24:13 +01:00
parent d2342377fb
commit 50565fb349
6 changed files with 34 additions and 9 deletions

3
.gitignore vendored
View File

@ -8,11 +8,12 @@ bin/*
data/*
!data/edit.htm
!data/edit.htm.gz
!data/vars.css
!data/openhasp.ttf
!data/style.css
!data/style.css.gz
!data/script.js
!data/script.js.gz
!data/vars.css
!data/cert/
!data/cert/x509_crt_bundle.bin
!data/static/

BIN
data/openhasp.ttf Normal file

Binary file not shown.

View File

@ -6,7 +6,6 @@
/*********************
* INCLUDES
*********************/
#include "lv_freetype.h"
#if LV_USE_FREETYPE
#include "ft2build.h"

View File

@ -23,6 +23,11 @@ typedef struct
#include "hasp_mem.h"
#include "font/hasp_font_loader.h"
extern const uint8_t OPENHASP_TTF_START[] asm("_binary_data_openhasp_ttf_start");
extern const uint8_t OPENHASP_TTF_END[] asm("_binary_data_openhasp_ttf_end");
extern const uint8_t OPENHASPLITE_TTF_START[] asm("_binary_data_openhasplite_ttf_start");
extern const uint8_t OPENHASPLITE_TTF_END[] asm("_binary_data_openhasplite_ttf_end");
static lv_ll_t hasp_fonts_ll;
typedef struct
@ -162,7 +167,7 @@ static lv_font_t* font_add_to_list(const char* payload)
size_t pos = font_split_payload(payload);
if(pos > 0 && pos < 56) {
uint16_t size = atoi(payload + pos);
if(payload[pos - 1] == '_') pos--; // trancate trailing underscore
if(payload[pos - 1] == '_') pos--; // truncate trailing underscore
char fontname[256];
memset(fontname, 0, sizeof(fontname));
@ -182,10 +187,11 @@ static lv_font_t* font_add_to_list(const char* payload)
}
lv_ft_info_t info;
info.name = filename;
info.weight = size;
info.mem = NULL;
info.style = FT_FONT_STYLE_NORMAL;
info.name = filename;
info.weight = size;
info.mem = NULL;
info.mem_size = 0;
info.style = FT_FONT_STYLE_NORMAL;
LOG_VERBOSE(TAG_FONT, F("Loading font %s size %d"), filename, size);
if(lv_ft_font_init(&info)) {
font = info.font;
@ -194,6 +200,24 @@ static lv_font_t* font_add_to_list(const char* payload)
}
}
}
if(!font) {
strcpy(filename, "openhasp");
uint16_t size = atoi(payload);
if(size > 8) {
lv_ft_info_t info;
info.name = filename;
info.weight = size;
info.mem = (const void*) OPENHASP_TTF_START;
info.mem_size = OPENHASP_TTF_END - OPENHASP_TTF_START;
info.style = FT_FONT_STYLE_NORMAL;
LOG_VERBOSE(TAG_FONT, F("Loading font %s size %d"), filename, size);
if(lv_ft_font_init(&info)) {
font = info.font;
font_type = 1;
}
}
}
#endif
if(!font) return NULL;

View File

@ -7,6 +7,8 @@ debug_tool = esp-prog
debug_init_break = tbreak setup
board_build.embed_files =
data/edit.htm.gz
data/openhasp.ttf
data/openhasplite.ttf
data/style.css.gz
data/script.js.gz
data/cert/x509_crt_bundle.bin

View File

@ -10,9 +10,8 @@ board = esp32dev
build_flags =
${env.build_flags}
${esp32.build_flags}
${esp32.ps_ram}
-D HASP_MODEL="FreeTouchDeck"
-DBOARD_HAS_PSRAM ; uses 78kB
;-mfix-esp32-psram-cache-issue ; uses 24kB
;region -- TFT_eSPI build options ------------------------
${esp32.vspi} ; Use VSPI hardware SPI bus