There might be a case where you need to take a small font in Espruino and double the size of it (maybe to save memory, maybe because it looks cool).
There's nothing built in, but this bit of code might be handy and is reasonably fast:
// txt=text string, px=>x position, py=>y position, h=height of font
Graphics.prototype.drawStringDbl = (txt,px,py,h)=>{
var g2 = Graphics.createArrayBuffer(128,h,2,{msb:true});
// set your custom font here if you need to
var w = g2.stringWidth(txt);
var c = (w+3)>>2;
g2.drawString(txt);
var img = {width:w*2,height:1,transparent:0,buffer:new ArrayBuffer(c)};
var a = new Uint8Array(img.buffer);
for (var y=0;y<h;y++) {
a.set(new Uint8Array(g2.buffer,32*y,c));
this.drawImage(img,px,py+y*2);
this.drawImage(img,px,py+1+y*2);
}
};
g.clear()
g.drawStringDbl("Hello",0,0,5)
g.flip()
The built-in font is very small and upscaling it isn't ideal, but some of the fonts from http://www.espruino.com/Fonts upscale a lot better.
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.
There might be a case where you need to take a small font in Espruino and double the size of it (maybe to save memory, maybe because it looks cool).
There's nothing built in, but this bit of code might be handy and is reasonably fast:
The built-in font is very small and upscaling it isn't ideal, but some of the fonts from http://www.espruino.com/Fonts upscale a lot better.