lv_font_conv icon indicating copy to clipboard operation
lv_font_conv copied to clipboard

Allow setting the font name as command line argument

Open Viatorus opened this issue 1 year ago • 4 comments

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).

Viatorus avatar Aug 12 '22 07:08 Viatorus

I see no reasons and tend to decline changes.

puzrin avatar Aug 12 '22 07:08 puzrin

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?

Viatorus avatar Aug 12 '22 13:08 Viatorus

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.

puzrin avatar Aug 13 '22 10:08 puzrin

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.

embeddedt avatar Aug 13 '22 14:08 embeddedt

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

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

puzrin avatar Aug 13 '22 16:08 puzrin

@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.

Viatorus avatar Aug 14 '22 11:08 Viatorus

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"?

puzrin avatar Aug 14 '22 17:08 puzrin