Bug 1566 : PDF Library doesn't support createFont on Linux
Last modified: 2010-06-04 01:58




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P2
Severity:
normal

 

Reporter:
Matthias Breuer
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2010-05-26 09:54
Since the processing.pdf.PGraphicsPDF class doesn't yet load fonts on Linux
I suggest the following fix:

Many Linux distributions place their fonts in /usr/share/fonts

Changes in static protected DefaultFontMapper getMapper():

else if (PApplet.platform == PApplet.LINUX) {
File folder = new File("/usr/share/fonts/");
if (folder.exists()) {
mapper.insertDirectory("/usr/share/fonts");
traverseDir(mapper, folder);
}
}

Since fonts can be placed in subdirectories the following method will take
care of finding relevant directories:

static protected void traverseDir(DefaultFontMapper mapper, File folder) {
File[] files = folder.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
mapper.insertDirectory(files[i].getPath());
traverseDir(mapper, new File(files[i].getPath()));
}
}
}
Additional Comment #1 From fry 2010-06-04 01:57
cool, thanks for this. i've now added it to svn for the next release. cheers!