Font Reflection

The past few days I’ve been looking into tooling for the ThorType website.

The project is available here.

One such project is a Swing GUI application where I use Apache FontBox/PDFBox to along with reflection to create a tree of information about any font I load.

The development is fairly straightforward. I use a method that recursively goes through the declared fields of each instance, with failsafes for circular coupling and then create TreeNodes for each field. This is of course a lot easier said than done, and I find that one of the limits of Java reflection is that the getDeclaredFields-method can break with inheritance as a subclass will usually just add a few new methods while the superclass also has to be iterated on if you want all of the information.

Another issue are the primitive data types, Strings and Java Collections, these also need their special cases which quickly adds to the complexity.

The code might be fast to write, but will easily end up brittle and buggy.

In addition to all that I experimented with using the IntelliJ GUI designer. I found out that it needs to be set to generate Java source code if you want to run it using Maven.