lvgl / lv_font_conv

Converts TTF/WOFF fonts to compact bitmap format
https://lvgl.io/tools/fontconverter
MIT License
187 stars 79 forks source link

Allow setting the font name as command line argument #82

Closed Viatorus closed 2 years ago

Viatorus commented 2 years ago

Currently, the font name is the derivated from the output file path:

https://github.com/lvgl/lv_font_conv/blob/4677fed860332139df94a7f7f566ce3854cc563d/lib/writers/lvgl/lv_font.js#L18-L19

Would be nice to set the font name via command line (e.g. like lv_image_conv does).

puzrin commented 2 years ago

I see no reasons and tend to decline changes.

Viatorus commented 2 years ago

It wouldn't be a breaking change.

It would be an additional, optional option. If the name is not provided per cmd, it fallsback to the default behavior.

Should I submit a PR?

puzrin commented 2 years ago

I do not like to accept changes "just for fun". Please, explain the reasons first, why this is not opinion-based and could be useful for all. As far as I remember - it's possible to define a custom output name now.

embeddedt commented 2 years ago

As far as I remember - it's possible to define a custom output name now.

Based on the code, it does not appear that it is currently possible to define a custom output name without changing the output file name as well. This means you would need a wrapper script to then rename the file if you didn't want the names to be matching.

Personally, I don't see any issue with adding this feature.

puzrin commented 2 years ago

https://github.com/puzrin/dispenser/blob/master/support/build_fonts.js#L28

Output is not related to input, custom names are ok.

Viatorus commented 2 years ago

@embeddedt Thank you for your help here.

@puzrin

Output is not related to input, custom names are ok.

That is not the problem I was talking about. Your output file my_font_roboto_14.c has the same name as the output variable my_font_roboto_14 and this cannot be changed via CMD in lv_font_conv. So you would have to rename files manual. In lv_img_conv I don't need to do this manual, since it is part of the tool itself:

https://github.com/lvgl/lv_img_conv/blob/master/lib/cli.ts#L21-L25

What we (in our project) have, is folder structure like: <project>/resources/fonts/ and <project>/resources/images/

I want to instrument lv_font_conv to output the font my_font.ttf to <project>/resources/font/my_font_18.c but also name the font variable <project>_resources_fonts_my_font_18 instead of just my_font_18. We do the same with images (and all other resources) because we don't want to pollute the global naming scope in C with short, unrelated names.

puzrin commented 2 years ago

Ah, ok. Now understand. May be reasonable.

But note, that's lvgl-writer specific. Binary output has no such need. Could you suggest an argument name, "lvgl-specific"?