/win-font

Utility to load fonts from files in Windows fonts directory.

Primary LanguageJavaApache License 2.0Apache-2.0

Java CI with Maven License

Small Java library to obtain instances of java.awt.Font for some standard fonts in Windows font directory (usually c:\Windows\fonts).

Main motivation for having this library is to allow using high quality fonts provided by Windows while preventing legal issues, since bundling and redistributing Windows fonts with 3rd party software is usually forbidden.

Path to the font directory may be explicitly specified via system property org.swingk.winfont.fontDir (e.g. for unit testing).

A viewer application org.swingk.winfont.Viewer is available under test root.

Example:

import org.swingk.winfont.WinFontFactory;
import org.swingk.winfont.WinFont;
import org.swingk.winfont.FontUnavailableException;

java.awt.Font tahomaFont = null;
try {
  tahomaFont = WinFontFactory.getFont(WinFont.TAHOMA);
} catch(FontUnavailableException e) {
  tahomaFont = ...; // provide some substitute
}

This project has no dependencies (except JUnit 5, for testing).

Requires Java 8 or later.