Created
July 25, 2020 19:28
-
-
Save mcculley/5a7f1d7848394e62086e3d7c7415114a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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