Xinyuan-LilyGO / LilyGo-EPD47

GNU General Public License v3.0
402 stars 120 forks source link

Tutorial on Fonts and Images #8

Closed kd8bxp closed 3 years ago

kd8bxp commented 3 years ago

I've tried to create a custom font, with no luck. I've used the fontconvert.py tool and continue to get and error "valueError: code point 166 not found in font stack!". I've tried to convert a ttf, and a otf. With no luck. Is there a tutorial somewhere on how to create a font for the T5 4.7"

a tutorial on creating a custom image would also be helpful, thank you.

kd8bxp commented 3 years ago

Update: I was able to get an image to convert and work, but still having issues with custom fonts. thanks

lewisxhe commented 3 years ago

Prerequisite you need to install python3 and install freetype-py using pip The approximate process is like this:

sudo apt install python3-pip
python3 -m pip install freetype-py

The previous is the prerequisite for implementation, and then you need to store the font file you want to convert in the same path as fontconvert.py. This is just for more convenient operation. You can also fill in the font path.

Then just follow the command below to convert the font.

python3 fontconvert.py --compress demo 16 msyh.ttc> font.h

Explanation of specific parameters:

python3 fontconvert.py --compress [generated font name] [font size] [font file path]> [generated font file]

Of course, this only demonstrates the generation of standard ascii codes. If you need other fonts, you only need to fill in the unicode encoding of the font to be generated in the fontconvert.py intervals list.

demo

lewisxhe commented 3 years ago

By the way, please make sure that the unicode encoding in the fontconvert.py intervals list is included in your font file, otherwise please comment other encodings and only keep the 32,126 range!

demo1

kd8bxp commented 3 years ago

Thank you, Changing the intervals is what the problem was. This is good information for anyone else who.

kd8bxp commented 3 years ago

Saw this information was added to a README in the scripts directory, I will close this issue. It's good information. Thanks