lvgl / lv_utils

Convert images or system fonts to C arrays. Written for LVGL embedded GUI library
https://littlevgl.com
54 stars 38 forks source link

font converter and monospace fonts #4

Closed sdalu closed 6 years ago

sdalu commented 6 years ago

Font converter is using ttf fonts, and when trying to convert the unscii fonts, the monospace characteristic of the font is lost. Can you add a converter that will retain the fixed width, perhaps decoding the .hex file format of the font.

kisvegabor commented 6 years ago

Yes, it is now losing the monospace characteristic and it's a good feature to add! I can't promise that I will have time for it in the next days.

Would somebody like to contribute in it?

sdalu commented 6 years ago

Got a small ruby program, generating 1-bpp font from .hex Need some testing, will post it

kisvegabor commented 6 years ago

It's great! We can use it until this feature isn't implemented in the "original" font converter.

sdalu commented 6 years ago

For people browsing the issues, code is available here: https://github.com/littlevgl/lv_utils/blob/master/hex2lvfont.rb

ruslanproject commented 6 years ago

what is .hex format for font? try ttf and bdf, invalid format for hex2lvfont.rb I dont know ruby, cannt understand it syntax.

monospace font realy actual

sdalu commented 6 years ago

The hex2lvfont.rb converter only deal with font in hex format [1]. The two fonts I know that are defined this way are:

[1] https://en.wikipedia.org/wiki/GNU_Unifont#The_.hex_font_format

kisvegabor commented 6 years ago

I updated the font converter with monospace feature. If you tested it and have any remarks please open a new issue for it.

kisvegabor commented 6 years ago

Based on the suggestion here: https://github.com/littlevgl/lvgl/issues/229 I modified the monospace support to leave letters "slim" (not extra columns to not occupy extra space) and updated drawing algorithm of the library align letters during rendering. The updates are in lvgl/dev-5.2 branch.