• Glad to hear you having fun... there is enough code grief around...

    interview in German

    even google.de could not get me there... (US 'Zensur'). What is the url?

    some address mapping...

    You got that already... may be you have to develop your own Graphics.drawString()... or override the method where the bitmap is looked up.... or you do the transformation before and not supplying the full matrix for the backing font... (I do not know if the Graphics object can handle that).

    parsing a C file and creating javascript

    Absolutely... create modules for each character... and you could even think of simple compression - before load or even for draw - and forget drawString() all together: just mapping memory to memory, and if you make it compiled, it will be very fast... (needs of course to put sufficient meta data into each char definition... in byte string or as object with properties). I'm working on a ui core with ui elements extension that work exactly in such way: require("base").addAndDelete(require("c8­0"),"c80") - load module into cache, use its data - delete it from cache. Get yourself an (serial) FlashEEPROM mounted for the font modules... then you can do it all dynamic with variable driven require(moduleName); (or you use (one of the) free pages on Espruino FlashEEPROM... and use - of course - something different than require(...) for loading the raw data...).

    In your code:

    // ----- pull in chars base and desired characters
    var cs = require("chars").ld("0123456789ABCM");
    

    chars.js module:

    // chars.js module
    exports =
    { hex:"0123456789abcdef"
    , ld: function( // load font bit map for characters to support
          cs // chars as string for which font bit map has to be loaded
        ) {
      var csl = cs.length // length cs string
        , cdx             // idx to individual char in cs
        , cmn             // character font bit map module name 
        , cspec           // char spec, for example:
                          //   { id: "80" // id
                          //   , w: 23    // used width in pixel
                          //   , h: 56    // used height in pixel
                          //   , x: 5     // offset from left in px (char spacing)
                          //   , y: 3     // offset from top in px (placing w/in line height)
                          //   , s: 143   // size of bit map in bytes (uncompressed
                          //   , cbm: "ffffff....." // coded bit map as string (?compressed)
                          //   }
        , cbm             // coded bit map as string
        , bma             // bit map array
        , nibCnt          // nibbles count (length of cbm string)
        , ndx             // nibble index
        , bdx             // byte index into Uint8Array
        ;
      for (cdx = 0; cdx < csl; cdx++) {
        cmn = "c" + cs.charCodeAt(cdx);
        cspec = require(cmn);
        this[cspec.id] = { w: cspec.w, h: cspec.h, x: cspec.x, y: cspec.y
                         , bma: (bma = new Uint8Array(cspec.s)
                         };
        nibCnt = (cbm = cspec.cbm).length;
        bdx = 0; ndx = 0;
        while (ndx < nibCnt) { // not supporting compression yet... :(
          bma[bdx] =   (this.hex.indexOf(cbm.charAt(ndx))<<4)
                     | this.hex.indexOf(cbm.charAt(ndx+1));
          bdx++; ndx += 2;
        }
        Modules.removeCached(cmn);
      }
    };
    

    Example character module: P - 80

    exports = // ----- P ----- c80.js -----
    { id: "80"
    , w: 23
    , h: 56
    , x: 5
    , y: 3
    , s: 143
    , cbm: ""ffffff001122ffff"
    }
    

    ...and I'm sure you'll do better than that... ;-) NB: code only partially verified :|

    PS: you can test the code 'mechanics' without FlashEEPROM card: just add the requires for the characters statically before loading chars.

    require("c80");
    ...
    ...
    var cs = require("chars").ld("0123456789ABCM");
    ...
    
About

Avatar for allObjects @allObjects started