Fonts are not generated after restart

Issue

You added fonts to your application (/apps/yourapplication/fonts/). Fonts are displayed correctly until you restart your instance. After the restart, the fonts are system fonts. You use com.day.image.Font.

Solution

Use com.day.cq.image.Font instead of com.day.image.Font.

This class is a wrapper for the com.day.image.Font class, which provides the functionality to seamlessly support multiple font formats and sources. All API methods are delegated to an instance of (an extension of) the com.day.image.Font class, which is set up in the constructor.

The constructor tries a list of configured font providers to get the delegatee. It falls back to the com.day.image.Font class if none of the configured font providers can provide the desired font.

Additional information

When the font is imported (that is "added to the fonts directory"), the system loads the font through the java.awt.Font class for registration in the .fontlist. Then, the font is not only known to the ContentBus, but also to the system. com.day.image.Font only knows about the fonts, which are also known to the Java VM through the java.awt.Font class. Therefore, the script works after import, but not after restart, when the system does not know the font anymore.