diff --git a/fontconverter.js b/fontconverter.js index 23ca873..732bf1d 100644 --- a/fontconverter.js +++ b/fontconverter.js @@ -506,7 +506,11 @@ Font.prototype.removeUnifontPlaceholders = function() { }); }; -// Outputs as JavaScript for a custom font +/* Outputs as JavaScript for a custom font. + options = { + compressed : bool + } +*/ Font.prototype.getJS = function(options) { // options.compressed options = options||{}; @@ -613,7 +617,7 @@ Font.prototype.getHeaderFile = function() { return header; } -// Output as a PBF file +// Output as a PBF file, returns as a Uint8Array Font.prototype.getPBF = function() { // https://github.com/pebble-dev/wiki/wiki/Firmware-Font-Format // setup to ensure we're not writing entire glyphs @@ -809,19 +813,70 @@ JsVar *jswrap_graphics_setFont${options.name}(JsVar *parent) { `); }; +// Renders the given text to a on object { width, height, bpp:32, data : Uint32Array } +Font.prototype.renderString = function(text) { + // work out width + var width = 0; + for (var i=0;i>bpp; + c |= c>>(bpp*2); + c |= c>>(bpp*4); + c = 255-c; + var px = x+ox; + if ((px>=0) && (px < width) && (y>=0) && (ya+r.max+1-r.min, 0); + } + return ranges; }