• In analogy with http://forum.espruino.com/conversations/­302392/ I coded a "drawString" override that introduces proper line spacing in Strings witch "\n" newlines in it. In this case I have chosen for 5 pixels of space between each line..

    Rather new to Espruino so maybe not the best solution, but it works for me.

    Hopefully Gordon will come up with a structural solution.

    Example code:

    // override drawString function to allocate line spacing
    g._ds = g.drawString;
    g.drawString = function(s,x,y) {
      s=s.toString();
      sa=s.split("\n");
      print(sa);
      spacing=5+g.getFontHeight();
      sa.forEach(function(line){ g._ds(line,x,y); y+=spacing; });      
    };
    
    g.clear();
    g.setFontVector(20);
    g.setColor(1,1,1);
    g.drawString("Temp:\nBattery:%\nCharging­\nUptime: 0.00\nFreeFlash: \nFreeStor:",0,30);
    

    And the resulting output:

  • @gerardwr - That looks like a good solution to me, although I would have personally made an entirely new function named drawLines or something instead of overriding g.drawString.

About