I am attempting to create a java.awt.Font instance from a TTF file on my system, but only some fonts are able to load without error. The code below is some test code I found
OK, so after some digging, it turns out that this problem is due to a bug (feature!) in the java.awt implementation. Namely, loading a physical TrueType font fails if the font file's name table does not include family name and full name records.
To identify the problem, I used GrepCode to trace backward from the relevant exception in OpenJDK's AWT implementation. Once I had discovered the name table issue, I used ttx, a no-frills TrueType metadata editor to add the name entries Java looks for. Ex:
American Typewriter
American Typewriter
The new TTF files generated by ttx could now be opened by Java. Yay!