Fonts: Difference between revisions

From Arduboy Wiki
Jump to navigation Jump to search
(Created page with "=== Font3x5 === Font3x5 is a simple library that provides a 3 x 5 pixel font which has the upper- and lower-case alphabet, numbers and the exclamation mark and the period. You can easily add extra characters if you like. There is a #define that allows you to remove the lower case letters. Doing so strips out 108 bytes. A sample program is shown below: <pre> #include <Arduboy2.h> #include "src/fonts/Font3x5.h" Arduboy2Base arduboy; Font3x5 font3x5 = Font3x5(); void...")
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Font3x5 ===
 
== Default Font ==
 
 
 
The Arduboy2 Class contains a 5 x 7 pixel font. Additional details can be found in the repo [https://mlxxxp.github.io/documents/Arduino/libraries/Arduboy2/Doxygen/html/classPrint.html here]
 
A sample program is shown below:
 
<pre>
#include <Arduboy2.h>
#include "src/fonts/Font3x5.h"
 
Arduboy2 arduboy;
 
void setup() {
  arduboy.boot();
}
 
void loop() {
 
    if (!(arduboy.nextFrame())) return;
 
    arduboy.clear();
    arduboy.setCursor(0, 0);
    arduboy.print(F("ABCDEFGHIJKLMNOPQRSTU\nabcdefghijklmnopqrstu\n1234567890./?!@#$"));
 
    arduboy.display();
 
}
</pre>[[File:DefaultFont2.png|frameless]]
 
== TinyFont ==
 
 
 
TinyFont is a 4x4 font which conforms to small ''ASCII'' from 32-127.
 
It stores 4 letters in 8 bytes and uses masks to draw the correct letter which makes the sprites 224 bytes in size.
 
Additional details can be found [https://community.arduboy.com/t/tinyfont-for-arduboy/3136 here] and the repo [https://github.com/yinkou/Arduboy-TinyFont here]
 
A sample program is shown below:
 
<pre>
#include <Arduboy2.h>
#include "Tinyfont.h"
 
Arduboy2 arduboy;
Tinyfont tinyfont = Tinyfont(arduboy.sBuffer, Arduboy2::width(), Arduboy2::height());
 
void setup() {
    arduboy.begin();
}
 
void loop() {
 
    if (!(arduboy.nextFrame())) return;
 
    arduboy.clear();
    tinyfont.setCursor(1, 0);
    tinyfont.print(F("THE QUICK BROWN FOX JUMPS\nOVER THE LAZY DOG."));
    tinyfont.setCursor(1, 11);
    tinyfont.print(F("The quick brown fox jumps\nover the lazy dog."));
 
    arduboy.display();
 
}
</pre>
 
[[File:TnyFont.png|frameless]]
 
== Font3x5 ==
 
 
Font3x5 is a simple library that provides a 3 x 5 pixel font which has the upper- and lower-case alphabet, numbers and the exclamation mark and the period.  You can easily add extra characters if you like.
Font3x5 is a simple library that provides a 3 x 5 pixel font which has the upper- and lower-case alphabet, numbers and the exclamation mark and the period.  You can easily add extra characters if you like.


There is a #define that allows you to remove the lower case letters.  Doing so strips out 108 bytes.
There is a #define that allows you to remove the lower case letters.  Doing so strips out 108 bytes. Additional details can be found [https://community.arduboy.com/t/3x5-font-for-those-with-good-eyesight/4920 here] and the repo [https://github.com/filmote/Font3x5 here]


A sample program is shown below:
A sample program is shown below:
Line 14: Line 88:


void setup() {
void setup() {
 
   arduboy.begin();
   arduboy.boot();
 
}
}


Line 34: Line 106:
}
}
</pre>
</pre>
You can also pass a line height to the constructor, as shown below:
<code>Font3x5 font3x5 = Font3x5( 11 );</code>
The two images below show the standard line height - 8 - and 11.
[[File:Font3x5 00.png|frameless]]  [[File:Font3x5 01.png|frameless]]
== Font4x6 ==
Font4x6 is a simple library that provides a 4 x 6 pixel font which has the upper- and lower-case alphabet, numbers and the exclamation mark and the period.  You can easily add extra characters if you like.
There is a #define that allows you to remove the lower case letters.  Doing so strips out 108 bytes. Additional details can be found [https://community.arduboy.com/t/4x6-font-for-the-arduboy/5589 here] and the repo [https://github.com/filmote/Font4x6 here]
A sample program is shown below:
<pre>
#include <Arduboy2.h>
#include "src/fonts/Font4x6.h"
Arduboy2Base arduboy;
Font4x6 font4x6 = Font4x6();
void setup() {
    arduboy.boot();
}
void loop() {
    if (!(arduboy.nextFrame())) return;
    arduboy.clear();
    font4x6.setCursor(12, 12);
    font4x6.print(F("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    font4x6.print(F("\nabcdefghijklmnopqrstuvwxyz"));
    font4x6.print(F("\n0123456789"));
    font4x6.print(F("\n!."));
    arduboy.display();
}
</pre>
You can also pass a line height to the constructor, as shown below:
<code>Font4x6 font4x6 = Font4x6( 11 );</code>
[[File:Font4x6.png|frameless]]

Latest revision as of 03:44, 25 August 2024

Default Font

The Arduboy2 Class contains a 5 x 7 pixel font. Additional details can be found in the repo here

A sample program is shown below:

#include <Arduboy2.h>
#include "src/fonts/Font3x5.h"

Arduboy2 arduboy;

void setup() {
  arduboy.boot();
}

void loop() {

    if (!(arduboy.nextFrame())) return;

    arduboy.clear();
    arduboy.setCursor(0, 0);
    arduboy.print(F("ABCDEFGHIJKLMNOPQRSTU\nabcdefghijklmnopqrstu\n1234567890./?!@#$"));

    arduboy.display();

}

TinyFont

TinyFont is a 4x4 font which conforms to small ASCII from 32-127.

It stores 4 letters in 8 bytes and uses masks to draw the correct letter which makes the sprites 224 bytes in size.

Additional details can be found here and the repo here

A sample program is shown below:

#include <Arduboy2.h>
#include "Tinyfont.h"

Arduboy2 arduboy;
Tinyfont tinyfont = Tinyfont(arduboy.sBuffer, Arduboy2::width(), Arduboy2::height());

void setup() {
    arduboy.begin();
}

void loop() {

    if (!(arduboy.nextFrame())) return;

    arduboy.clear();
    tinyfont.setCursor(1, 0);
    tinyfont.print(F("THE QUICK BROWN FOX JUMPS\nOVER THE LAZY DOG."));
    tinyfont.setCursor(1, 11);
    tinyfont.print(F("The quick brown fox jumps\nover the lazy dog."));

    arduboy.display();

}

Font3x5

Font3x5 is a simple library that provides a 3 x 5 pixel font which has the upper- and lower-case alphabet, numbers and the exclamation mark and the period. You can easily add extra characters if you like.

There is a #define that allows you to remove the lower case letters. Doing so strips out 108 bytes. Additional details can be found here and the repo here

A sample program is shown below:

#include <Arduboy2.h>
#include "src/fonts/Font3x5.h"

Arduboy2Base arduboy;
Font3x5 font3x5 = Font3x5();

void setup() {
   arduboy.begin();
}

void loop() {

    if (!(arduboy.nextFrame())) return;

    arduboy.clear();
    font3x5.setCursor(12, 12);
    font3x5.print(F("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    font3x5.print(F("\nabcdefghijklmnopqrstuvwxyz"));
    font3x5.print(F("\n0123456789"));
    font3x5.print(F("\n!."));

    arduboy.display();

}

You can also pass a line height to the constructor, as shown below:

Font3x5 font3x5 = Font3x5( 11 );

The two images below show the standard line height - 8 - and 11.

Font4x6

Font4x6 is a simple library that provides a 4 x 6 pixel font which has the upper- and lower-case alphabet, numbers and the exclamation mark and the period. You can easily add extra characters if you like.

There is a #define that allows you to remove the lower case letters. Doing so strips out 108 bytes. Additional details can be found here and the repo here

A sample program is shown below:

#include <Arduboy2.h>
#include "src/fonts/Font4x6.h"

Arduboy2Base arduboy;
Font4x6 font4x6 = Font4x6();

void setup() {

    arduboy.boot();

}

void loop() {

    if (!(arduboy.nextFrame())) return;

    arduboy.clear();
    font4x6.setCursor(12, 12);
    font4x6.print(F("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    font4x6.print(F("\nabcdefghijklmnopqrstuvwxyz"));
    font4x6.print(F("\n0123456789"));
    font4x6.print(F("\n!."));

    arduboy.display();

}

You can also pass a line height to the constructor, as shown below:

Font4x6 font4x6 = Font4x6( 11 );