Trying to make new font


(Scott) #21

There’s a sample sketch PerosaFont3x5.ino included in @Pharap’s repository.


(Pharap) #22

As @MLXXXp says, the .ino file is a demo program that prints all the characters, the .h and .cpp files are the actual font code.

I don’t think it will work if you just put it in the library folder because it doesn’t have a library.properties file (it might, I’m not sure).

I think it would be easier to just put the .h and the .cpp in the same folder as your game’s .ino file and use it like it’s used in the example .ino.

That means you need to put #include "PerosaFont3x5.h" at the top and create a PerosaFont3x5 object.
Like the example:

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

Arduboy2Base arduboy;
PerosaFont3x5 font3x5;

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

void loop()
{
	if (!arduboy.nextFrame())
		return;

	arduboy.clear();
	
	font3x5.setCursor(12, 12);
	font3x5.println(F("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
	font3x5.println(F("0123456789"));
	font3x5.println(F("!\"#$%&'()*+,-./"));
	font3x5.println(F(":;<=>?@"));
	font3x5.println(F("[\\]^_`"));
	font3x5.println(F("{|}~"));
	
	arduboy.display();
}

Also note that Arduboy2Base is used in the example instead of Arduboy2.
This is done to save memory.

Arduboy2Base has all the same functionality of Arduboy2,
but without the text printing parts.
Since you’re using a custom font, you won’t need Arduboy2's text printing capabilities.


(Marcus L. Sanders II) #23

Ah! Thanks very much for your help man. I wouldn’t know what to do - like at all.


(Scott) #24

It will work without a library.properties file (as a “legacy” library) if PerosaFont3x5.h and PerosaFont3x5.cpp are in the root of a folder in the libraries folder. However, for a “new style” library you would include a library.properties file and put the .h and .cpp files in a sub-folder named src.

In either case, the PerosaFont3x5.ino file should be placed in a sub-folder named examples if you want it to be available from the IDE’s File > Examples menu.