How can I load a custom font in C?

HI,
I created a custom font with caps (Sign In), but I don't know how to load it into the playdate!
I'm using C but the C doc sucks!!! >___<
Where do I have to put my *.fnt files to load them!?!

Hi @legicore if from the root of your project you have (for example) Source/fonts/Roobert-24-Medium.fnt and Source/fonts/Roobert-24-Medium-table-36-36.png you can then do

const char* errMsg = NULL;
LCDFont* roobert24 = playdate->graphics->loadFont("fonts/Roobert-24-Medium", &errMsg);

PS if you download the linux SDK you can look under PlaydateSDK-1.11.1\C_API\Examples, I found these very useful.

3 Likes

Hi @timboe ,
sorry for the late response - we had holidays in Germany and I visited my family...
But thank you very much for your post - it solved my problem!

Explanation:
Before, I already had a look at the C_API examples, but they seem to be partly outdated.^^
The "Hello World" example was my base, and it used the fontpath "/System/Fonts/Asheville-Sans-14-Bold.pft", which made no sense to me and I couldn't figure out how that path came together.
With your help, I put my font now in the folder "Source/fonts/" and loaded it now in code from the fontpath "fonts/arduboy_15x24" (the fonts-folder holds the files arduboy_15x24.fnt and arduboy_15x24-table-15-24.png).

Again - thank you very much! :wink:

1 Like

Right, you will also find PlaydateSDK-1.11.1\Disk\System\Fonts in the linux SDK if you want to explore what is available at this path, but there are very few options here. There are many more in PlaydateSDK-1.11.1\Resources\Fonts which can be redistributed in your pdx under OFL.

1 Like