abridged font files

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Barton
 
Posts: 17
Joined: Tue Jun 28, 2016 1:12 am

abridged font files

Post by Barton »

Hi I was wondering if it is possible to create "abridged" font include files, say I only want to use the capital letters only of a font, for example. The point being to make the file smaller thus leaving more room for the program (or other fonts).

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: abridged font files

Post by Franklin97355 »

It is possible but how hard it would be, that I don't know.

User avatar
HandyGuy
 
Posts: 26
Joined: Tue Jan 05, 2016 1:28 pm

Re: abridged font files

Post by HandyGuy »

I'd like to bump this thread if possible. I am facing the same issue with a clock project. I am using an UNO with a 7" TFT display attached to a RA8875 driver board. Since it's a clock I only need the digit characters, so I'd like to jettison the rest of the font to save (a lot) of memory. I looked at the "font".h header file and it looks like it defines 2 arrays of hex numbers, one of glyphs and the other of bitmaps. The glyphs are nicely labeled with the character each set of hex numbers represents, but the bitmaps are just a long string of hex numbers with (seemingly) no rhyme or reason to it.

The bottom of the font header says "Approx. 8815 bytes", and my project is already pushing the boundaries of the Uno's memory, so eliminating everything I don't need would be a *big* help.

Is there a reference doc somewhere which defines the format of the font definition header? From there I can probably figure out how to edit the file to help Barton and me out.

Thanks.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: abridged font files

Post by adafruit_support_mike »

The GFX tutorial explains the `fontconvert` tool, which you can use to create new font files:

https://learn.adafruit.com/adafruit-gfx ... sing-fonts

User avatar
HandyGuy
 
Posts: 26
Joined: Tue Jan 05, 2016 1:28 pm

Re: abridged font files

Post by HandyGuy »

PROBLEM SOLVED!

I created a program to extract only the characters I needed from a font header file and leave the rest out. For example, I was using the FreeSansBold24pt7b font in my project. Using my tool I was able to shrink the amount of memory the font uses from 8.8k to around 2.4k!

The code is available on GitHub: https://github.com/HandyGuySoftware/FontShrink

The code is freely available for you to use or modify. Barton, I hope this solves your problem the way it did for me.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: abridged font files

Post by adafruit_support_mike »

Nice solution. Thanks for posting the code!

User avatar
vishal5109
 
Posts: 1
Joined: Thu Nov 17, 2016 9:39 am

Re: abridged font files

Post by vishal5109 »

i have downloaded font from these link http://www.rinkydinkelectronics.com/r_fonts.php but all those files are in .c so get error , can you tell me how i can convert those .c files into .h as in these link https://github.com/adafruit/Adafruit-GF ... ter/Fonts

User avatar
HandyGuy
 
Posts: 26
Joined: Tue Jan 05, 2016 1:28 pm

Re: abridged font files

Post by HandyGuy »

The conversion program I wrote was written specifically for the Adafruit font libraries. I'm not sure how other font libraries are formatted, so I'm not able to tell you how to do the conversion. Sorry.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”