Is anyone an pretty knowledgable on FreeType library and LVGL fonts

I started mucking around with a on the fly font converter/editor, but thats a lot of new to absorb. If anyone wants to help me out, it would be greatly appreciated.

I’ve created this repo to play with FreeType. It’s not for LittlevGL, just to get started.

Take a look at my code in

So, I THINK i successfully copied the glyphbitmaps…

I am wondering how to set the lv_font_glyph_dsc_t structure from the FreeType data.

SO, I have a few outputs from this that I would like to have.

  1. The font editor (Create fonts from Freetype, create different point sizes, add/remove glyphs from one freetype font into/out of another)
  2. Serializing fonts, so that a GUI from the GUI Creator is independent of implementation of LVGL
  3. Potentially adding optional freetype support back into LVGL

Tka a look at the comments here:

Is it worth to develop a new font converter?
See the existing one:

Ill look at comments.

So, yes I think it is worth it. As this would add a lot of functionality to the GUI editor for completeness, and provide a simple stand alone gui for editing fonts.

Ive got the stuff in the comments. My next task to figure out is:
cmaps and kerning

I think it would be better to extend the existing font converter and re-use components of it.

Cant really do that, as its a javascript program.

Here is the specification of the font format

Note that, you can use your custom format too. You just need to provide a “get_glyph_data” and a “get_bitmap” function.
More info here

Having one tool would be really better.

Nothing really prevents the creation of an FFI, or in the worst case using exec.

Well, I don’t personally like that option, but Ill table this for the moment and get the other features complete.

Here is a question based on serialization of an lv_font

How would I find the size of the array:
const lv_font_fmt_txt_glyph_dsc_t * glyph_dsc;

Good question… I had a look at the comments in the header file.

It looks like ((lv_font_fmt_txt_dsc_t *)0)->cmap_num might do what you want (the weird cast is so you know which structure). The cmap table maps glyphs to Unicode characters so I assume the length of the table equals the number of glyphs. Probably a good idea to check with @kisvegabor on that though.

Ok, maybe this would work…

I can get the length of cmaps. cmaps have a list length, so I suppose I could add those all up and end up with my total number of glyphs

Seems to have worked :slight_smile:

int glyphRange = 0;
		for(int i=0; i<fontDsc.cmap_num; i++)
			glyphRange += ptr->list_length;
			j["FontDsc"]["cmaps"][i] = LVFontCMap::ToJSON(*ptr++);
		for(int i=0; i<glyphRange; i++)
			j["FontDsc"]["GlyphDsc"][i] = 

It’s nice that C++ lets you manipulate JSON so easily. :slightly_smiling_face:

Well the library I am using is nice, nlhomann::json, makes json a first class data structure.

Ok I am pretty happy with this. I think I have serialized a font :slight_smile:

Well at least all of the FontDsc :slight_smile:


What about the lv_font_add_map(&font, "name") topic? Is it still relevant?

That would be for deserialzation, or taking JSON and making a font. As for relevancy, yes eventually I intend on putting the font editor into the GUI editor, but like I said I’ve tabled that for now