Go Down

Topic: AdafruitGFX: Help for editing one of the font files. (Read 91 times) previous topic - next topic

siriusbg

Hello to everyone!
I need help editing one of the font files. I want to use only the numeric values(0-9) and to remove the rest of the buffer for memory purposes. I'm not so advanced, so any help will be much appreciated.

Thanks in advance and sorry for my bad english!

david_prentice


siriusbg

The file is: FreeSerifBold24pt7b
Sorry, forgot about this important piece of information. :)

david_prentice

#3
Jun 16, 2016, 03:09 pm Last Edit: Jun 16, 2016, 03:23 pm by david_prentice
Code: [Select]

const uint8_t FreeSerifBoldNum24pt7bBitmaps[] PROGMEM = {
  0x00, 0xFC, 0x00,
  0x0F, 0x3C, 0x00, 0x78, 0x78, 0x03, 0xE1, 0xF0, 0x1F, 0x03, 0xE0, 0x7C,
  0x0F, 0x83, 0xF0, 0x3F, 0x0F, 0xC0, 0xFC, 0x7F, 0x03, 0xF9, 0xFC, 0x0F,
  0xE7, 0xF0, 0x3F, 0xBF, 0xC0, 0xFE, 0xFF, 0x03, 0xFF, 0xFC, 0x0F, 0xFF,
  0xF0, 0x3F, 0xFF, 0xC0, 0xFF, 0xFF, 0x03, 0xFF, 0xFC, 0x0F, 0xFF, 0xF0,
  0x3F, 0xFF, 0xC0, 0xFF, 0xFF, 0x03, 0xFF, 0xFC, 0x0F, 0xFF, 0xF0, 0x3F,
  0x9F, 0xC0, 0xFE, 0x7F, 0x03, 0xF9, 0xFC, 0x0F, 0xE3, 0xF0, 0x3F, 0x0F,
  0xC0, 0xFC, 0x1F, 0x03, 0xE0, 0x7C, 0x0F, 0x80, 0xF8, 0x7C, 0x01, 0xE1,
  0xE0, 0x03, 0xCF, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x18, 0x00, 0x1E, 0x00,
  0x1F, 0x80, 0x1F, 0xE0, 0x1F, 0xF8, 0x1D, 0xFE, 0x00, 0x3F, 0x80, 0x0F,
  0xE0, 0x03, 0xF8, 0x00, 0xFE, 0x00, 0x3F, 0x80, 0x0F, 0xE0, 0x03, 0xF8,
  0x00, 0xFE,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x00, 0x7F, 0x00, 0x03, 0xF8, 0x00, 0x0F, 0xC0, 0x00,
  0x7E, 0x00, 0x03, 0xF0, 0x00, 0x3F, 0x00, 0x01, 0xF0, 0x00, 0x3F, 0x00,
  0x03, 0x80, 0x00, 0x00,
};

const GFXglyph FreeSerifBoldNum24pt7bGlyphs[] PROGMEM = {
  {   909-909,  22,  34,  23,    1,  -32 },   // 0x30 '0'
  {  1003-909,  18,  33,  23,    3,  -32 },   // 0x31 '1'
  {  1078-909,  21,  33,  24,    1,  -32 },   // 0x32 '2'
  {  1165-909,  21,  34,  24,    1,  -32 },   // 0x33 '3'
  {  1255-909,  21,  33,  24,    1,  -32 },   // 0x34 '4'
  {  1342-909,  20,  32,  23,    2,  -31 },   // 0x35 '5'
  {  1422-909,  21,  34,  24,    1,  -32 },   // 0x36 '6'
  {  1512-909,  21,  32,  23,    1,  -31 },   // 0x37 '7'
  {  1596-909,  21,  34,  23,    1,  -32 },   // 0x38 '8'
  {  1686-909,  22,  34,  23,    1,  -32 },   // 0x39 '9'
};

const GFXfont FreeSerifBoldNum24pt7b PROGMEM = {
  (uint8_t  *)FreeSerifBoldNum24pt7bBitmaps,
  (GFXglyph *)FreeSerifBoldNum24pt7bGlyphs,
  0x30, 0x39, 56 };

// Approx. much less bytes


Untested.   You can see the "new" font name.   Save  it in the Fonts directory.   Tell us whether it works.

David.

Edit.  Corrected typo on 3rd to last line: FreeSerifBold2Num4pt7bGlyphs
Edit2. Removed one of the 0x00 from the first line.

I have actually tested it and the edited version works.

siriusbg

That was fast! Thanks David! Will test it tonight and will reply.

david_prentice

For the benefit of anyone else who wants to hand-edit.

1.  Identify start of '0' entry from the Glyphs table = 909
2.  Identify start of ':' entry i.e. end of '9' = 1780
3.  Bitfields start at line 2 with 12 bytes per line.
4.  909/12 = 75.75 i.e. line 77 field 9
5.  1780/12 = 148.33 i.e. line 150 field 4
6.  Delete lines 151- from the bitfields table
7.  Delete lines 2-149
8.  Delete the part fields.
9.  Edit the Glyphs table.  Just leave the 0 to 9 entries.
10.  Edit the GFXfont table to reflect new size and names.

It is not difficult,   but since I made two errors you have to be careful.
In other words,   I should have tested before posting.

Anyway,   I was downstairs drinking a cup of tea.   Thought that I should show how to hand-edit.
In practice,  you would auto generate the Font with the utility program.   i.e. choose size and name.
No typos if you do it that way!

siriusbg

Tested and it works! Thank you again...and for the edit info.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy