public static Scriptable jsConstructor(Context cx, Object[] args,
                                       Function ctorObj,
                                       boolean inNewExpr) {
        Font f = new Font();
        String font = cx.toString(args[0]);
        if (font.startsWith("data:")) {
			URI dataUri = null;
			try {
				new URI(font);
			} catch (Exception ex) {
				ex.printStackTrace();
			}
            byte[] fontBytes = org.apache.commons.codec.binary.Base64.decodeBase64(font.substring(font.indexOf(',')+1));
            try {
                f.setFont(java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, new ByteArrayInputStream(fontBytes)));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } else if (font.endsWith(".ttf")) {
            // First, we need to get the currenly loaded game, so we can figure
            // out where the path of this font is.
            Scriptable global = ScriptableObject.getTopLevelScope(ctorObj);
            Scriptable sgf = (Scriptable)global.get("SGF", global);
            Scriptable game = (Scriptable)sgf.get("Game", sgf);
            Game curGame = (Game)game.get("current", game);
            URL fontPath = null;
            try {
                fontPath = new URL(curGame.getRoot(), font);
            } catch (MalformedURLException ex) {
                ex.printStackTrace();
            }

            if (fontPath != null)
                try {
                    f.setFont(java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, fontPath.openStream()));
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
        } else {
            f.setFont(new java.awt.Font(font, java.awt.Font.PLAIN, 1));
        }
        return f;
    }