I have an app that now uses 7 custom fonts. The font is selected from a settings menu.
So I only need one active font to be loaded when the App starts up.
At the moment I have 7 seperate font functions that really bloat the App in terms of memory footprint.
I guess I should really just load the one font I need from storage for the lifespan of the App.
Just trying to get my head round how I physically do this - what code goes where and how it is loaded.
Graphics.prototype.setFontArchitect = function() {
// Actual height 40 (41 - 2)
var widths = atob("CBolByEeJykkJCYhCg...==");
var font = atob("AAAAAAAAAAAAAAMAAAAAAAAAAAAA....=");
var scale = 1; // size multiplier for this font
g.setFontCustom(font, 46, widths, 58+(scale<<8)+(1<<16));
};
Would you recommend that I create a module for each of these fonts that basically does something similar to:
How do I tell the apps.json file that the code has 7 custom font files ?
I think the answer is the way that modules are loaded - example gpssetup
The module file drops the .js from the source file name.
Then the App does require("myfont");
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
I have an app that now uses 7 custom fonts. The font is selected from a settings menu.
So I only need one active font to be loaded when the App starts up.
At the moment I have 7 seperate font functions that really bloat the App in terms of memory footprint.
I guess I should really just load the one font I need from storage for the lifespan of the App.
Just trying to get my head round how I physically do this - what code goes where and how it is loaded.
Would you recommend that I create a module for each of these fonts that basically does something similar to:
https://www.espruino.com/modules/FontDylex7x13.js
How do I tell the apps.json file that the code has 7 custom font files ?
I think the answer is the way that modules are loaded - example gpssetup
The module file drops the .js from the source file name.
Then the App does require("myfont");
Then I think I would just load settings at the top of the code and run this bit of one time code for the lifetime of the App.