Skip to content

Instantly share code, notes, and snippets.

@mcculley
Created July 25, 2020 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcculley/5a7f1d7848394e62086e3d7c7415114a to your computer and use it in GitHub Desktop.
Save mcculley/5a7f1d7848394e62086e3d7c7415114a to your computer and use it in GitHub Desktop.
// This is a gross hack to make it possible to run without any fonts in the Lambda environment.
private static void configureStubFontConfiguration() {
final Properties p = new Properties();
p.put("version", "1");
p.put("sequence.allfonts", "nonexistent"); // Just need at least one entry to satisfy FontManager.
try {
final File targetFile = File.createTempFile("fontconfig.properties", null);
targetFile.deleteOnExit();
try (FileOutputStream o = new FileOutputStream(targetFile)) {
p.store(o, "stub to make sun.awt.FontConfiguration not break when no fonts are available");
}
System.setProperty("sun.awt.fontconfig", targetFile.getPath());
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment