You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • A more angular font would be a great idea!

    I'm not sure I understand about the greyscale value? On something like the Pixl sadly the LCD will only handle black or white (there is a hack to get 1 level of greyscale, but it uses loads of power & CPU).

    I guess one option would be to make a bit of JavaScript to render the existing font data (or to tweak the firmware such that we could have custom vector fonts), and then you could iterate quite quickly with different data?

    var VECTOR_FONT_POLY_SEPARATOR = 128;
    
    function drawChar(c, x, y, scale) {
      var poly = [];
      for (var i=0;i<c.length;i+=2) {
        poly.push(x+(c[i]&127)*scale,y+(c[i+1]&1­27)*scale);
        if (c[i+1]&VECTOR_FONT_POLY_SEPARATOR) {
          g.fillPoly(poly);
          poly = [];
        }
      }
    }
    
    var char = [
    // Character code 50
    	16,34,
    	23,21,
    	19,12,
    	10,21,
    	7,32|VECTOR_FONT_POLY_SEPARATOR,
    	19,12,
    	23,21,
    	36,17|VECTOR_FONT_POLY_SEPARATOR,
    	19,86,
    	55,50,
    	44,47,
    	9,83,
    	4,96|VECTOR_FONT_POLY_SEPARATOR,
    	19,86,
    	4,96,
    	63,96,
    	63,86|VECTOR_FONT_POLY_SEPARATOR,
    	62,39,
    	61,23,
    	51,27,
    	44,47,
    	55,50|VECTOR_FONT_POLY_SEPARATOR,
    	36,17,
    	51,27,
    	61,23|VECTOR_FONT_POLY_SEPARATOR,
    	53,13,
    	32,8,
    	19,12,
    	36,17,
    	61,23|VECTOR_FONT_POLY_SEPARATOR,
    ];
    
    g.clear();
    drawChar(char, 0,0, 0.6);
    drawChar(char, 64,0, 0.3);
    drawChar(char, 96,0, 0.2);
    drawChar(char, 96,32, 0.1);
    g.flip();
    

    For instance if you try the above, it'll print 2 a few times at different sizes. You can see the annoying 'pip' on the top of it, and that's the highest point (which has a y value of 8). If you make that 12 you can get rid of the pip, but then it's flat on top.

    As far as I know, the fillPoly and line handling is pretty standard - but I'd love to be proven wrong. If it could be improved I'd love to tweak it.

    As far as building, check out https://github.com/espruino/Espruino/blo­b/master/README_Building.md#for-nordic-s­emiconductors-nrf51nrf52-series-devices - there's some info there. Realistically unless you want to buy an nRF52DK you'll have to update via Bluetooth LE, which will be slow.

    But there's no need to build it for Pixl.js itself. You can do a build for Linux or Raspberry Pi (or I think Mac OS) just by cloning the repo and doing make. You can compile in SDL graphics support, or you could just run a command-line script that created an offscreen buffer and then wrote it out to an image that you could then view in an image viewer. That'd make changes really easy to view.

About

Avatar for Gordon @Gordon started