From d6e2801cc77ce5ffc1cb4e81043c16c721f3e17a Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Fri, 25 May 2018 15:22:01 -0700 Subject: [PATCH] Add NodeJS font printing example --- UsingCustomFonts.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/UsingCustomFonts.md b/UsingCustomFonts.md index 4fa9906..c5880a9 100644 --- a/UsingCustomFonts.md +++ b/UsingCustomFonts.md @@ -39,6 +39,20 @@ We are planning to add registration support within XML in [#168](https://github. ...where file_name is the full path to the directory where the font is located (e.g., "/home/user/mapnik/fonts/unifont-Medium.ttf"). The c++ demo (source:trunk/demo/c++/rundemo) also provides an good example of how to add additional fonts. +### NodeJS + +```js +var mapnik = require('mapnik'); +mapnik.register_default_fonts(); +mapnik.fonts().forEach( function(e) { console.log(e); }); +``` + +The NodeJS interpreter might add an extra line in interactive mode. To avoid this, do + +```shell +nodejs -e "var mapnik = require('mapnik');mapnik.register_default_fonts();mapnik.fonts().forEach( function(e) { console.log(e); });" +``` + ## 2) Figure out the exact 'face_name' * Ask Mapnik to print all registered face names (*note*: this only will show fonts already auto-registered in the `fontscollectionpath`):