fonts: update README.md to match new method

This commit is contained in:
Yehoshua Pesach Wallach 2022-04-20 17:15:55 +03:00 committed by JF
parent c006f05c99
commit 1c0d9ef383

View File

@ -6,16 +6,21 @@
## Generate the fonts: ## Generate the fonts:
* Open the [LVGL font converter](https://lvgl.io/tools/fontconverter) * Make sure you have installed lv_font_conv, and it's in the PATH
* Enter the settings for the font that you wish to convert * `npm i lv_font_conv`
* Click on Convert, download the file and place it in `src/DisplayApp/Fonts` * `export PATH="$PATH:$PWD/node_modules/.bin"`
* *OR* globally:
* `npm i -g lv_font_conv`
* `export PATH="$PATH:$HOME/.local/bin"` (if not already in the path)
* or in any other path you choose.
* run the `generate.py` script, while in the folder.
* it has a `-h` flag to show usage, nontheless: `python generate.py fonts.json`
### How to add new symbols: ### How to add new symbols:
* Browse [this cheatsheet](https://fontawesome.com/cheatsheet/free/solid) and pick symbols * Browse [this cheatsheet](https://fontawesome.com/cheatsheet/free/solid) and pick symbols
* For each symbol, add its hex code (0xf641 for the 'Ad' icon, for example) to the *Range* list (Remember to keep this * For each symbol, add its hex code (0xf641 for the 'Ad' icon, for example) to the *Range* list (or the symbol list when its simple enough) in the `fonts.json` file
readme updated with newest range list) * * Convert this hex value into a UTF-8 code
* Convert this hex value into a UTF-8 code
using [this site](http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=f185&mode=hex) using [this site](http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=f185&mode=hex)
* Define the new symbols in `src/displayapp/screens/Symbols.h`: * Define the new symbols in `src/displayapp/screens/Symbols.h`:
@ -23,77 +28,18 @@
static constexpr const char* newSymbol = "\xEF\x86\x85"; static constexpr const char* newSymbol = "\xEF\x86\x85";
``` ```
### Small font ### the config file format:
* Name: jetbrains_mono_bold_20 inside `fonts`, there is a dictionary of fonts,
* Size: 20 and for each font there is:
* Bpp: 1 bit-per-pixel * sources - list of file,range(,symbols) wanted (as a dictionary of those)
* Do not enable font compression or horizontal subpixel rendering * bpp - bits per pixel.
* Load the file `JetBrainsMono-Bold.tff` (use the file in this repo to ensure the version matches) and specify the following range: `0x20-0x7e, 0x410-0x44f` * size - size.
* Add a 2nd font, load the file `FontAwesome5-Solid+Brands+Regular.woff` and specify the following * patches - list of extra "patches" to run, either string to file which should be run, or list of arguments (with first one being the command being run)
range: `0xf293, 0xf294, 0xf244, 0xf240, 0xf242, 0xf243, 0xf241, 0xf54b, 0xf21e, 0xf1e6, 0xf54b, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf069, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf029, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf201, 0xf06e, 0xf015` * features - optional. dictionary of extra file,range fonts to be included when the feature is enabled. (for example: a extra language)
* Fix an error in the font conversion. * compress - optional. default disabled. add `"compress": true` to enable
Replace the following:
/* U+0030 "0" */
0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0x7f,
0xdf, 0xf7, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f,
0x8f, 0xc0,
with
/* U+0030 "0" */
0x3f, 0x1f, 0xef, 0x3f, 0x87, 0xe1, 0xf8, 0x7e,
0xdf, 0xb7, 0xe1, 0xf8, 0x7e, 0x1f, 0xcf, 0x7f,
0x8f, 0xc0,
(there are two changes: 7f -> 7e and f7 -> b7)
### Medium font
* Name: jetbrains_mono_42
* Size: 42
* Bpp: 1 bit-per-pixel
* Do not enable font compression or horizontal subpixel rendering
* Load the file `JetBrainsMono-Regular.tff` (use the file in this repo to ensure the version matches) and specify the following range: `0x25, 0x30-0x3a`
### Large font
* Name: jetbrains_mono_76
* Size: 76
* Bpp: 1 bit-per-pixel
* Do not enable font compression or horizontal subpixel rendering
* Load the file `JetBrainsMono-Regular.tff` (use the file in this repo to ensure the version matches) and specify the following range: `0x25, 0x2D, 0x2F, 0x30-0x3a`
### Digital watchface font
* Name: jetbrains_mono_extrabold_compressed
* Size: 80
* Bpp: 1 bit-per-pixel
* Do not enable font compression or horizontal subpixel rendering
* Load the file `JetBrainsMono-ExtraBold.tff` (use the file in this repo to ensure the version matches) and specify the following range: `0x30-0x3a`
### PineTimeStyle font
* Name: open_sans_light
* Size: 150
* Bpp: 1 bit-per-pixel
* Do not enable font compression or horizontal subpixel rendering
* Load the file `open_sans_light.tff` (use the file in this repo to ensure the version matches) and specify the following symbols: `0123456789`
### Symbols font (Used in QuickSettings for example)
* Name: lv_font_sys_48
* Size: 48
* Bpp: 1 bit-per-pixel
* Do not enable font compression or horizontal subpixel rendering
* Load the file `icons_sys_48.tff` and specify the following range: `0xe902, 0xe904-0xe907, 0xe90b-0xe90c`
### Navigation font ### Navigation font
`navigtion.ttf` is created with the web app [icomoon](https://icomoon.io/app) by importing the svg files from `src/displayapp/icons/navigation/unique` and generating the font. `lv_font_navi_80.json` is a project file for the site, which you can import to add or remove icons. `navigtion.ttf` is created with the web app [icomoon](https://icomoon.io/app) by importing the svg files from `src/displayapp/icons/navigation/unique` and generating the font. `lv_font_navi_80.json` is a project file for the site, which you can import to add or remove icons.
This font must be generated with the `lv_font_conv` tool, which has additional options not available in the online converter.
`lv_font_conv --font navigation.ttf -r '0xe900-0xe929' --size 80 --format lvgl --bpp 2 -o lv_font_navi_80.c`