Created
October 13, 2011 19:38
-
-
Save dwins/1285284 to your computer and use it in GitHub Desktop.
What fonts can Java find which are able to render Chinese text?
This file contains hidden or 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
| // Run with 'jrunscript fonts.js' or just copy/paste in the jrunscript interactive interpreter | |
| var GraphicsEnvironment = Packages.java.awt.GraphicsEnvironment; | |
| var fonts = | |
| GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); | |
| var test = "\u4e00"; // a String, you can replace it with your own test text if you care about a different language. | |
| // this value came from http://www.chinesecomputing.com/programming/java.html regarding Chinese text handling in Java | |
| for (var i = 0; i < fonts.length; i++) | |
| if (fonts[i].canDisplayUpTo(test) === -1) | |
| Packages.java.lang.System.out.println(fonts[i].getFontName()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment