You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • :) The custom font is slower because Espruino has to unpack it from RAM - in Espruino things sometimes aren't stored in one block of memory to work around fragmentation - so for every access it has to check.

    When using the built-in font it's using very specific, fast code to access flash.

    Did you try the new firmware I linked? That should be a lot faster.

    Actually thinking about it, it seems that atob doesn't create a flat string when it could do.

    You might get faster rendering by doing:

    var font = E.toString(atob("AAAAAPoAwADAAFhw2HDQAGS­S/5JMAGCW+DzSDAxSolIMEsAAPEKBAIFCPABIMOA­wSAAQEHwQEAABBgAQEBAQAAIAAwwwwAB8ipKifAB­A/gBChoqSYgCEkrLSjAAYKEj+CADkoqKinAA8UpK­SDACAgI6wwABskpKSbABgkpKUeAAiAAEmABAoRAA­oKCgoKABEKBAAQIqQYAA8WqW9RDgOOMg4DgD+kpK­SbAB8goKCRAD+goJEOAD+kpKCAP6QkIAAfIKCklw­A/hAQEP4A/gAMAgIC/AD+EChEggD+AgICAP5AIED­+AP7AMAz+AHyCgoJ8AP6QkJBgAHyChoN8AP6QmJR­iAGSSkpJMAICA/oCAAPwCAgL8AOAYBhjgAPAOMA7­wAMYoECjGAMAgHiDAAI6SosIA/4EAwDAMAwCB/wB­AgEAAAQEBAQEBEn6SggQABCoqHgD+IiIcABwiIhQ­AHCIi/gAcKioYACB+oIAAGCUlPgD+ICAeAL4AAQG­+AP4IFCIA/AIAPiAeIB4APiAgHgAcIiIcAD8kJBg­AGCQkPwA+ECAgABIqKiQAIPwiADwCAjwAIBgGGCA­AOAYIBjgAIhQIFCIAIRkGGCAAJioyIgAQboEA5wC­BbhAAQIDAQIAAPFqlpUI8cPh8+HAAcDhwACBg/mA­gAAgM/gwIABA4fBAQABAQfDgQAHxERER8AHxE9CR­cAHxUbFR8AP58OBAAEDh8/gACAAIAAgB8fHx8fAD­+/gD+/gACilIiAgACIlKKAgA+Yu5iPgACAgICAgA­GBgYGBgAODg4ODgAeHh4eHgA+Pj4+PgB+fn5+fgD­+/v7+/gD+/v7+/gAAAAAA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Y="))­;
    
      Graphics.prototype.setFontDennis8 = function() {
        this.setFontCustom(font, 32, widths, 8);
      };
    

    So basically Dennis8, but with E.toString around atob. I'd be interested to see what difference that makes?

    I'll make a note to improve atob - there's no reason it shouldn't use flat strings, which would be a lot faster and more efficient

About

Avatar for Gordon @Gordon started