• Stars
    star
    175
  • Rank 218,059 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Converts TTF/WOFF fonts to compact bitmap format

lv_font_conv - font convertor to compact bitmap format

CI NPM version

Converts TTF/WOFF/OTF fonts to compact format, suitable for small embedded systems. Main features are:

  • Allows bitonal and anti-aliased glyphs (1-4 bits per pixel).
  • Preserves kerning info.
  • Compression.
  • Users can select required glyphs only (subsetting).
  • Multiple font sources can be merged.
  • Simple CLI interface, easy to integrate into external build systems.

Install the script

node.js v14+ required.

Global install of the last version, execute as "lv_font_conv"

# install release from npm registry
npm i lv_font_conv -g
# install from github's repo, master branch
npm i lvgl/lv_font_conv -g

run via npx without install

# run from npm registry
npx lv_font_conv -h
# run from github master
npx github:lvgl/lv_font_conv -h

Note, runing via npx may take some time until modules installed, be patient.

CLI params

Common:

  • --bpp - bits per pixel (antialiasing).
  • --size - output font size (pixels).
  • -o, --output - output path (file or directory, depends on format).
  • --format - output format.
    • --format dump - dump glyph images and font info, useful for debug.
    • --format bin - dump font in binary form (as described in spec).
    • --format lvgl - dump font in LittlevGL format.
  • --force-fast-kern-format - always use more fast kering storage format, at cost of some size. If size difference appears, it will be displayed.
  • --lcd - generate bitmaps with 3x horizontal resolution, for subpixel smoothing.
  • --lcd-v - generate bitmaps with 3x vertical resolution, for subpixel smoothing.
  • --use-color-info - try to use glyph color info from font to create grayscale icons. Since gray tones are emulated via transparency, result will be good on contrast background only.
  • --lv-include - only with --format lvgl, set alternate path for lvgl.h.

Per font:

  • --font - path to font file (ttf/woff/woff2/otf). May be used multiple time for merge.
  • -r, --range - single glyph or range + optional mapping, belongs to previously declared --font. Can be used multiple times. Examples:
    • -r 0x1F450 - single value, dec or hex format.
    • -r 0x1F450-0x1F470 - range.
    • -r '0x1F450=>0xF005' - single glyph with mapping.
    • -r '0x1F450-0x1F470=>0xF005' - range with mapping.
    • -r 0x1F450 -r 0x1F451-0x1F470 - 2 ranges.
    • -r 0x1F450,0x1F451-0x1F470 - the same as above, but defined with single -r.
  • --symbols - list of characters to copy (instead of numeric format in -r).
    • --symbols 0123456789., - extract chars to display numbers.
  • --autohint-off - do not force autohinting ("light" is on by default).
  • --autohint-strong - use more strong autohinting (will break kerning).

Additional debug options:

  • --no-compress - disable built-in RLE compression.
  • --no-prefilter - disable bitmap lines filter (XOR), used to improve compression ratio.
  • --no-kerning - drop kerning info to reduce size (not recommended).
  • --full-info - don't shorten 'font_info.json' (include pixels data).

Examples

Merge english from Roboto Regular and icons from Font Awesome, and show debug info:

env DEBUG=* lv_font_conv --font Roboto-Regular.ttf -r 0x20-0x7F --font FontAwesome.ttf -r 0xFE00=>0x81 --size 16 --format bin --bpp 3 --no-compress -o output.font

Merge english & russian from Roboto Regular, and show debug info:

env DEBUG=* lv_font_conv --font Roboto-Regular.ttf -r 0x20-0x7F -r 0x401,0x410-0x44F,0x451 --size 16 --format bin --bpp 3 --no-compress -o output.font

Dump all Roboto glyphs to inspect icons and font details:

lv_font_conv --font Roboto-Regular.ttf -r 0x20-0x7F --size 16 --format dump --bpp 3 -o ./dump

Note. Option --no-compress exists temporary, to avoid confusion until LVGL adds compression support.

Technical notes

Supported output formats

  1. bin - universal binary format, as described in https://github.com/lvgl/lv_font_conv/tree/master/doc.
  2. lvgl - format for LittlevGL, C file. Has minor limitations and a bit bigger size, because C does not allow to effectively define relative offsets in data blocks.
  3. dump - create folder with each glyph in separate image, and other font data as json. Useful for debug.

Merged font metrics

When multiple fonts merged into one, sources can have different metrics. Result will follow principles below:

  1. No scaling. Glyphs will have exactly the same size, as intended by font authors.
  2. The same baseline.
  3. OS/2 metrics (sTypoAscender, sTypoDescender, sTypoLineGap) will be used from the first font in list.
  4. hhea metrics (ascender, descender), defined as max/min point of all font glyphs, are recalculated, according to new glyphs set.

Development

Current package includes WebAssembly build of FreeType with some helper functions. Everything is wrapped into Docker and requires zero knowledge about additional tools install. See package.json for additional commands. You may need those if decide to upgrade FreeType or update helpers.

This builds image with emscripten & freetype, usually should be done only once:

npm run build:dockerimage

This compiles helpers and creates WebAssembly files:

npm run build:freetype

More Repositories

1

lvgl

Embedded graphics library to create beautiful UIs for any MCU, MPU and display type.
C
16,168
star
2

lv_port_esp32

LVGL ported to ESP32 including various display and touchpad drivers
C
1,011
star
3

lv_binding_rust

LVGL bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
Rust
676
star
4

lv_port_pc_visual_studio

Visual Studio projects for LVGL embedded graphics library. Recommended on Windows. Linux support with Wayland is work in progress.
C
572
star
5

lv_demos

Examples, tutorials and applications for the LVGL embedded GUI library
C
480
star
6

lvgl_esp32_drivers

Drivers for ESP32 to be used with LVGL
C
321
star
7

lv_drivers

TFT and touch pad drivers for LVGL embedded GUI library
C
295
star
8

lv_binding_micropython

LVGL binding for MicroPython
C
250
star
9

lv_port_pc_vscode

C
244
star
10

lv_platformio

PlatformIO project example for LVGL
C
241
star
11

lv_port_linux

LVGL configured to work with a standard Linux framebuffer
C
237
star
12

lv_port_pc_eclipse

PC simulator project for LVGL embedded GUI Library. Recommended on Linux and Mac.
C
235
star
13

lv_arduino

LVGL as Arduino Library + example sketch
C
147
star
14

lv_port_win_codeblocks

Windows PC simulator project for LVGL embedded GUI Library
C
145
star
15

lv_binding_js

React bindings for LVGL ⚛️
C++
141
star
16

lv_port_windows

LVGL ported to Windows
C
83
star
17

lv_img_conv

Image converter for LVGL, written in JS
TypeScript
72
star
18

lv_port_stm32f429_disco

LVGL ported to STM32F429I-DISC1 using SW4STM32 (Ac6) IDE
C
71
star
19

lv_lib_png

PNG decoder for LVGL
C
60
star
20

lv_i18n

Internationalization (i18n) for LVGL
JavaScript
58
star
21

lv_web_emscripten

LVGL ported to Emscripten to be converted to JavaScript
C
55
star
22

lv_port_stm32f746_disco

LVGL ported to STM32F746G-DISCO using STM32CubeIDE
C
50
star
23

lv_lib_qrcode

QR code generation with LVGL
C
50
star
24

lv_utils

Convert images or system fonts to C arrays. Written for LVGL embedded GUI library
PHP
49
star
25

lv_lib_freetype

Interface to FreeType to generate font bitmaps run time
C
47
star
26

lv_binding_cpp

[WIP] C++ binding for LVGL
C++
45
star
27

docs_old

DEPRECATED: Documentation for LVGL is now located in the main repository: https://github.com/lvgl/lvgl
HTML
42
star
28

lv_fs_if

LVGL interfaces to various file systems (PC, FatFS)
C
40
star
29

lv_lib_split_jpg

JPG decoder for LVGL
C
32
star
30

lv_lib_gif

GIF library for LVGL
C
32
star
31

lv_lib_rlottie

Lottie animation support for LVGL
C
29
star
32

lv_port_stm32f769_disco

LVGL ported to STM32F769 Discovery using CubeIDE
C
26
star
33

lv_gui_builder

[WIP] Drag end drop GUI designer for LVGL
24
star
34

lv_lib_tinygl

EXPERIMENTAL - 3D extension for lvgl using TinyGL
C
21
star
35

lv_port_raspberry_pi_pico_mdk

An MDK template for Raspberry Pi Pico + LVGL
C
19
star
36

blog

Post, News and Tutorials about LVGL embedded GUI library
C
19
star
37

lv_port_stm32f469_disco

LVGL ported to STM32F469 Discovery using SWSTM32 (Ac6) IDE
C
14
star
38

lv_lib_bmp

BMP decoder library for LVGL
C
12
star
39

lv_binding_pikascript

C
11
star
40

lv_port_stm32h7b3i_disco

This repository contains the Light and Versatile Graphics Library (LVGL) port for the STM32H7B3I-DK development board.
C
11
star
41

lv_port_stm32h745i_disco

LVGL ported to STM32H745I DISCO
C
11
star
42

lv_apps

Ready to use UIs and high level components for applications
C
10
star
43

lv_port_maixduino

Maixduino GUI project with LVGL
C
10
star
44

docs

Meta repository for compiled documentation. Do not send PRs here - they will be closed. The Markdown files are now located in the main repository: https://github.com/lvgl/lvgl
HTML
10
star
45

lvgl-project-creator

Create LVGL projects quickly and easily
Python
9
star
46

sim

Meta repository for online LVGL simulators
JavaScript
8
star
47

lv_port_xilinx_zedboard_vitis

This repository contains a template AMP project for the Zedboard using VGA, FreeRTOS, LVGL and USB peripherals
C
8
star
48

lv_port_aurix

LVGL ported to Aurix TFT board
C
7
star
49

lv_port_an547_cm55_sim

A LVGL porting for Cortex-M55 running on an Arm official FPGA prototyping development board called MPS3 (AN547), see Figure 1. It is also possible to run the project template on an emulator called Corstone-300-FVP, which is free. Topics Resources
C
7
star
50

lv_port_stm_nucleo_g071rb

LVGL ported to ST's NUCLEO G071RB board
C
3
star
51

lv_binding_berry

Binding to Berry language
C
3
star
52

lv_port_stm32f746_disco_atollic

DEPRECATED: LittlevGL ported to STM32F746G-DISCO using Atollic IDE
C
2
star
53

template

Template repo with README and CI settings
2
star
54

markup_temporary

Temporary repository to evaluate the markup language support
1
star
55

pic32mx_r61581_no_os

LittlevGL ported to PIC32MX with R61581 display controller
C
1
star