Regarding the code below, I’m having difficulties using font.canDisplayUpTo() – I think it’s an issue with the URL being passed to Font font =… ? The fonts are all fine, so it’s something to do with how Font is being fed the file locations?
Thanks in advance if you have any ideas,
Dan
int sizeWidth = 800;
int sizeHeight = 800;
int frameRate = 22;
File fontDir;
File [] fontFiles;
String fontFolder = "/Volumes/macOS/Users/****USERNAME****/Desktop/Fonts/";
String theWord = "fonte";
String [] fontArray;
PFont pfont;
Font font;
ArrayList<File> fontName = new ArrayList<File>();
import java.awt.Font;
void settings() {
size(sizeWidth, sizeHeight);
}
void setup() {
frameRate(frameRate);
char [] arr = theWord.toCharArray();
println(arr);
fontDir = new File(fontFolder);
fontFiles = fontDir.listFiles();
for (int i = 0; i < fontFiles.length; i++) {
if (fontFiles[i].getName().startsWith("._")) {
fontFiles[i].delete();
}
if (fontFiles[i].toString().matches(".*(ttf|otf)$")) {
// ERROR: Unhandled exception type FontFormatException...
Font font = Font.createFont(Font.TRUETYPE_FONT, fontFiles[i]);
if (font.canDisplayUpTo(arr, 0, arr.length) == -1) {
fontName.add(fontFiles[i]);
}
}
}
}