The Config#setFonts currently accepts a list of font files, and constructs Font objects from that. But we do not always have access to the font files. It would be more flexible to allow setting the Font objects directly. Consider e.g.
import java.awt.font;
// ...
final var fontSize = (int) (Math.round(HEIGHT * 0.8d));
final var fonts = List.of(
new Font("Arial", Font.ITALIC, fontSize),
new Font("Comic Sans MS", Font.PLAIN, fontSize),
new Font("Georgia", Font.PLAIN, fontSize),
new Font("Verdana", Font.PLAIN, fontSize));
final var config = new Config();
config.setFonts(fonts); // doesn't work, as it currently only accepts file names as string
The problem with the default behavior of randomly selecting from every font available on the system is that not all installed fonts even support basic latin letters, e.g. fonts such as Noto Sans Sinhala Regular or icon fonts. Then the rendered captcha is not readable.
There's no way to get file paths from fonts, and something like new Font("Arial", Font.ITALIC, fontSize) can resolve to a list of font files:

The
Config#setFontscurrently accepts a list of font files, and constructsFontobjects from that. But we do not always have access to the font files. It would be more flexible to allow setting theFontobjects directly. Consider e.g.The problem with the default behavior of randomly selecting from every font available on the system is that not all installed fonts even support basic latin letters, e.g. fonts such as
Noto Sans Sinhala Regularor icon fonts. Then the rendered captcha is not readable.There's no way to get file paths from fonts, and something like
new Font("Arial", Font.ITALIC, fontSize)can resolve to a list of font files: