Since the documentation at http://processing.js is still tailored for processing code, I’ll post an example of how to port font usage to JS (assuming you have an “inArray” function like jQuery’s). It shows how you can store all the fonts you need in an associative array for easy reference afterward:
var fonts = {}; processing.setup = function() { var fontList = processing.PFont.list(); if (jQuery.inArray('sans-serif', fontList) >= 0) { fonts['sans-serif'] = {'12': pr.createFont('sans-serif', 12, true)}; } else { // Error } } // Somewhere else in your code ... processing.textFont(fonts['sans-serif']['12']); processing.text("Hello world", 10, 10);