M5Stack Core2, How to load Custom Font?
-
I was reading: https://community.m5stack.com/topic/388/cahnge-font-size-in-python/ on how to load custom font on my Core2 Board and tried to do it myself.
Given font file in
.ttf
format, I've generated 2 files: in.c
and.bin
format using the following online tool: https://lvgl.io/tools/font_conv_v5_3Then, I moved them to my Core2 Board and tried to use the new font like this (I'm working with MicroPython):
from m5stack import * from m5stack_ui import * from uiflow import * from valera import * screen = M5Screen() screen.clean_screen() screen.set_screen_bg_color(0xFFFFFF) label0 = M5Label('Hi', x=149, y=86, color=0x000, parent=None) lcd.compileFont("./valera.c") lcd.font("./valera.c")
But, every time I run the above code the program crashes and causes a restart to the device.
Any suggestions on what could be the problem here? -
What crash is it, what the error message?
-
I'm not seeing any error message, the device just restarts.
I've tried to use the following code instead (without callinglcd.font
):lcd.compileFont("./valera.c") label0 = M5Label('Hi', x=149, y=86, color=0x000, font=valera.fon, parent=None)
While it doesn't cause restart the font isn't working (I've tried to search the generated files and
compileFont
doesn't seem to produce any.fon
file, which shouldn't be the case)Side Note: my input
.c
file is less than 100 KB in size, as larger files caused crashes according to the comments in previous posts.