Loading...
Logo
Processing Forum
I'm noticing some fonts won't render in Processing, particularly certain "graphic" fonts such as ZapfDingbatsITC. When using the Tools > Create Font... menu option,  ZapfDingbatsITC doesn't display properly in the Create Font import interface. Similarly, using createFont() programmatically doesn't appear to make a difference, and it isn't affected by different textMode() parameters. In both cases, the code executes without error and text is displayed, but it's just the default sans-serif font and not ZapfDingbatsITC.

Is there a fundamental reason as to why this font wouldn't be supported? I'm not sure if it's because it's a more "graphical"/"pictorial" font, though others like it do work. Or, perhaps it's the font file type?

Replies(2)

It wasn't obvious...
I used a good font utility named BabelMap. It shown me that the characters in such fonts live in the Private Use Area. Apparently, Windows uses some magic to map these characters to the Ascii range.
I used createFont with the character set parameter to access this area. Little test sketch:
Copy code
  1. PFont f;

  2. void setup()
  3. {
  4.   size(800, 600);
  5.   smooth();
  6.   int start = 0xF020;
  7.   char[] charset = new char[128];
  8.   for (int i = 0; i < charset.length; i++)
  9.   {
  10.     charset[i] = (char) (start + i);
  11.   }
  12.   f = createFont("Wingding", 48, true, charset);
  13.   textFont(f);
  14. }
  15.  
  16. void draw()
  17. {
  18.   background(0);
  19.   text("  ", 200, 200);
  20. }
As expected, the forum ate my escaped sequences (it wants to interpret any encoding it sees, curiously. Already reported the bug to Zoho). You must read "/uF021 /uF030 /uF040" with backslashes in place of the forward slashes.
Thanks! This got me pointed in the right direction. I also had to access the PUA characters for Zapf Dingbats. I was able to find a few different references for their Unicode character codes here (along with other dingbats):

As you suggested, once I had the proper character codes, I could step through them successfully and display them using createFont() as you suggested. Just for posterity, here's my simple test code:

Copy code
  1.  size(800,600);
  2. smooth();
  3. background(255);
  4. int start = 0x2701;
  5. char[] charset = new char[192]; // 192 total dingbats
  6. String[] chars = new String[charset.length];
  7. for (int i = 0; i < charset.length; i++) {
  8.   charset[i] = char(start + i);
  9.   chars[i] = str(char(start + i));
  10. }
  11. PFont f = createFont("ZapfDingbatsITC", 16, true, charset);
  12. textFont(f);
  13. fill(0);
  14. String allChars = join(chars,"");
  15. text("✁✂✃✄☎✆✇✈✉☛☞✌✍✎✏", 0, height/2);
  16. text(char(0x2701), 0, height/2 + 100);
  17. text(allChars, 0, height/2 + 200);
Thanks again for the help!