Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ability to include only specific characters to save flash #461

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

leres
Copy link

@leres leres commented Jan 6, 2025

(Unused characters in the first to last range are set to ' ')
Use -I.. to find gfxfont.h
Add -L/usr/local/lib to improve chances of finding freetype library use static buffers instead of malloc()
Use buffer overflow safe snprintf() and strlcpy()
Output the command line as a comment
Add missing newlines to some error messages

To generate code for ., /, and 0-9 you can use:

./fontconvert /usr/local/share/fonts/webfonts/comic.ttf 20 46 57 > comic1.h

To generate the same code using the new command line syntax use:

./fontconvert /usr/local/share/fonts/webfonts/comic.ttf 20 \
    46 47 48 49 50 51 52 53 54 55 56 57 > comic2.h

To generate code for just . and 0-9, use:

./fontconvert /usr/local/share/fonts/webfonts/comic.ttf 20 \
    46 48 49 50 51 52 53 54 55 56 57 comic3.h

This saves ~70 bytes of flash:

ice 1685 % diff comic2.h comic3.h | tail -28
74,84c68,78
<   {     4,  17,  33,  21,    2,  -30 },   // 0x2F '/'
<   {    75,  21,  31,  24,    2,  -29 },   // 0x30 '0'
<   {   157,  12,  30,  18,    3,  -29 },   // 0x31 '1'
<   {   202,  18,  30,  24,    3,  -29 },   // 0x32 '2'
<   {   270,  18,  31,  24,    3,  -29 },   // 0x33 '3'
<   {   340,  22,  31,  24,    1,  -29 },   // 0x34 '4'
<   {   426,  19,  31,  24,    3,  -29 },   // 0x35 '5'
<   {   500,  19,  31,  24,    2,  -29 },   // 0x36 '6'
<   {   574,  22,  29,  24,    2,  -27 },   // 0x37 '7'
<   {   654,  19,  31,  24,    3,  -29 },   // 0x38 '8'
<   {   728,  20,  32,  24,    2,  -29 } }; // 0x39 '9'
---
>   {     4,   1,   1,  12,    0,    0 },   // 0x2F '  '
>   {     5,  21,  31,  24,    2,  -29 },   // 0x30 '0'
>   {    87,  12,  30,  18,    3,  -29 },   // 0x31 '1'
>   {   132,  18,  30,  24,    3,  -29 },   // 0x32 '2'
>   {   200,  18,  31,  24,    3,  -29 },   // 0x33 '3'
>   {   270,  22,  31,  24,    1,  -29 },   // 0x34 '4'
>   {   356,  19,  31,  24,    3,  -29 },   // 0x35 '5'
>   {   430,  19,  31,  24,    2,  -29 },   // 0x36 '6'
>   {   504,  22,  29,  24,    2,  -27 },   // 0x37 '7'
>   {   584,  19,  31,  24,    3,  -29 },   // 0x38 '8'
>   {   658,  20,  32,  24,    2,  -29 } }; // 0x39 '9'
91c85
< // Approx. 899 bytes
---
> // Approx. 829 bytes

leres added 3 commits January 6, 2025 14:03
(Unused characters in the first to last range are set to ' ')
Use -I.. to find gfxfont.h
Add -L/usr/local/lib to improve chances of finding freetype library
use static buffers instead of malloc()
Use buffer overflow safe snprintf() and strlcpy()
Output the command line as a comment
Add missing newlines to some error messages
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant