• I am back to this topic since the DK08 watch clock screen could use some nice fonts and has this fontchip too. (BTW it is in sale for $14 now) Thanks for the last suggestion, tried again and it (almost) works!!! The {msb:true} with setRotation(3,1) was the key. So my current version is something like this

    function createFont(off,bs,w,h,c){
      var f=require("Flash");
      var fg=Graphics.createArrayBuffer(w,h,1,{ver­tical_byte:true}); // one letter
      var fnt=Graphics.createArrayBuffer(h,w*c,1,{­msb:true}); // whole font in correct format
      fnt.setRotation(3,1);
      off+=0x60000000;
      var len=w*h/8;
      var x=0;
      while(c--){
        fg.buffer=f.read(len,off);off+=bs;
        fg.buffer[0]=0; // letter width for proportional font, clear
        fnt.drawImage(fg.asImage(),x,0);
        x+=w;
      }
      return fnt;
    //  return new Uint8Array(fnt.asImage().buffer);
    //return E.toString(fnt.asImage().buffer);
    }
    
    /*
    var fnt=createFont(0x199e0e,322,40,64,10);
    g.setFontCustom(E.toString(fnt),0x30,40,­64);
    g.drawString("01234");
    g.flip();
    */
    

    However currently the biggest issue for me is that setFontCustom accepts only String type as the font bitmap and I have byte array. Unfortunately for larger fonts than just few letters E.toString() mostly returns 'undefined' possibly because the font buffer is too big so it cannot make flat string out out of that due to low/fragmented memory. Is there Uint8Array to String conversion that would always succeed i.e. share the same buffer? or could setFontCustom easily accept Uint8Array too? Now it fails with Uncaught Error: Font bitmap must be a String as per
    https://github.com/espruino/Espruino/blo­b/master/libs/graphics/jswrap_graphics.c­#L1070

About

Avatar for fanoush @fanoush started