Skip to content

Instantly share code, notes, and snippets.

@dwins
Created October 13, 2011 19:38
Show Gist options
  • Select an option

  • Save dwins/1285284 to your computer and use it in GitHub Desktop.

Select an option

Save dwins/1285284 to your computer and use it in GitHub Desktop.
What fonts can Java find which are able to render Chinese text?
// 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