--Write a Java program to check if there is a font that can use Japanese with AWS Lambda + Java --Check if various characters can be used with Font # canDisplay --At this time, there are no fonts in the system that can use Japanese (Hiragana, Katakana, Kanji).
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class FontList implements RequestHandler<Map<String, Object>, Map<String, Object>> {
/**
*This is the entry point when running as a standalone Java application.
*
* @param args not used
*/
public static void main(String[] args) {
Map<String, Object> output = new FontList().invoke();
//Output font information
for (Map font : (List<Map>) output.get("fonts")) {
System.out.println(font);
}
//System information
System.out.println(output.get("system"));
}
/**
*Entry point when executing AWS Lambda function(Handler method)is.
*
* @param input input data
* @param context AWS Lambda Context object
* @return output data
*/
@Override
public Map<String, Object> handleRequest(Map<String, Object> input, Context context) {
return invoke();
}
/**
*Returns information about available fonts.
*
* @return Information on available fonts
*/
private static Map<String, Object> invoke() {
//Get a list of available fonts
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] allFonts = ge.getAllFonts();
//Find out if you can use various characters
List<Map> fonts = Arrays.stream(allFonts)
.sorted(Comparator.comparing(Font::getNumGlyphs)) //Sort by glyph number
.map(f -> {
Map m = new HashMap<String, Object>();
m.put("name", f.getName());
m.put("number_of_glyphs", f.getNumGlyphs());
m.put("display_number", f.canDisplay('0'));
m.put("display_alphabet", f.canDisplay('A'));
m.put("display_hiragana", f.canDisplay('Ah'));
m.put("display_katakana", f.canDisplay('A'));
m.put("display_kanji", f.canDisplay('Sub'));
return m;
})
.collect(Collectors.toList());
//Get system information
Map system = new HashMap<String, String>();
system.put("os.name", getSystemProperty("os.name"));
system.put("os.arch", getSystemProperty("os.arch"));
system.put("os.version", getSystemProperty("os.version"));
system.put("java.version", getSystemProperty("java.version"));
system.put("java.specification.version", getSystemProperty("java.specification.version"));
system.put("java.runtime.name", getSystemProperty("java.runtime.name"));
system.put("java.runtime.version", getSystemProperty("java.runtime.version"));
system.put("java.vm.name", getSystemProperty("java.vm.name"));
system.put("java.vm.version", getSystemProperty("java.vm.version"));
//Build output data
Map output = new HashMap<String, Object>();
output.put("fonts", fonts);
output.put("system", system);
return output;
}
/**
*Gets the system properties indicated by the specified key.
*
* @param key The name of the system property
* @return System property string value(Null if no property with that key exists)
*/
private static String getSystemProperty(String key) {
try {
return System.getProperty(key);
} catch (SecurityException e) {
return e.toString();
}
}
}
Unfortunately, at this time, there are no fonts in the system that can use Japanese (Hiragana, Katakana, Kanji).
{
"system": {
"java.runtime.name": "OpenJDK Runtime Environment",
"java.specification.version": "1.8",
"java.version": "1.8.0_201",
"java.vm.version": "25.201-b09",
"os.arch": "amd64",
"java.runtime.version": "1.8.0_201-b09",
"os.name": "Linux",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"os.version": "4.14.133-97.112.amzn2.x86_64"
},
"fonts": [
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 155,
"name": "Cursor",
"display_number": false,
"display_alphabet": false
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 190,
"name": "Standard Symbols L",
"display_number": true,
"display_alphabet": false
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 203,
"name": "Dingbats ",
"display_number": false,
"display_alphabet": false
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 224,
"name": "Hershey Plain- Duplex",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 224,
"name": "Hershey Plain- Duplex- Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 224,
"name": "Hershey Plain- Triplex",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 224,
"name": "Hershey Plain- Triplex- Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 224,
"name": "Hershey Script- Complex",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 224,
"name": "Hershey Script- Simplex",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 228,
"name": "Hershey Gothic- English",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 228,
"name": "Hershey Gothic- German",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 228,
"name": "Hershey Gothic- Italian",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Bitstream Charter",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Bitstream Charter Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Bitstream Charter Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Bitstream Charter Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Courier 10 Pitch",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Courier 10 Pitch Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Courier 10 Pitch Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Courier 10 Pitch Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Utopia Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Utopia Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Utopia Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 229,
"name": "Utopia Regular",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 503,
"name": "URW Chancery L Medium Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 512,
"name": "URW Bookman L Demi Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 519,
"name": "URW Bookman L Demi Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 519,
"name": "URW Bookman L Light Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 522,
"name": "DialogInput.bolditalic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 522,
"name": "Monospaced.bolditalic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 522,
"name": "Nimbus Mono L Bold Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 522,
"name": "URW Palladio L Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 523,
"name": "URW Palladio L Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 523,
"name": "URW Palladio L Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 525,
"name": "URW Palladio L Roman",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 533,
"name": "DialogInput.italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 533,
"name": "Monospaced.italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 533,
"name": "Nimbus Mono L Regular Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 535,
"name": "Nimbus Roman No9 L Medium Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 535,
"name": "Nimbus Roman No9 L Regular Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 540,
"name": "DialogInput.bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 540,
"name": "Monospaced.bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 540,
"name": "Nimbus Mono L Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 545,
"name": "URW Bookman L Light",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 561,
"name": "Nimbus Sans L Bold Condensed",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Century Schoolbook L Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Century Schoolbook L Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Century Schoolbook L Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Century Schoolbook L Roman",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "DialogInput.plain",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Monospaced.plain",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Mono L Regular",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Roman No9 L Medium",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Roman No9 L Regular",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Sans L Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Sans L Bold Condensed Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Sans L Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Sans L Regular",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Sans L Regular Condensed",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Sans L Regular Condensed Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "Nimbus Sans L Regular Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "URW Gothic L Book",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "URW Gothic L Book Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "URW Gothic L Demi",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 563,
"name": "URW Gothic L Demi Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 1915,
"name": "DejaVu Sans ExtraLight",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3320,
"name": "DejaVu Serif Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3320,
"name": "DejaVu Serif Condensed Bold Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3320,
"name": "Serif.bolditalic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3321,
"name": "DejaVu Serif Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3321,
"name": "DejaVu Serif Condensed Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3321,
"name": "Serif.bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3399,
"name": "DejaVu Serif",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3399,
"name": "DejaVu Serif Condensed",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3399,
"name": "Serif.plain",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3449,
"name": "DejaVu Serif Condensed Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3449,
"name": "DejaVu Serif Italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 3449,
"name": "Serif.italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5085,
"name": "DejaVu Sans Bold Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5085,
"name": "DejaVu Sans Condensed Bold Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5085,
"name": "Dialog.bolditalic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5085,
"name": "SansSerif.bolditalic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5155,
"name": "DejaVu Sans Condensed Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5155,
"name": "DejaVu Sans Oblique",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5155,
"name": "Dialog.italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5155,
"name": "SansSerif.italic",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5854,
"name": "DejaVu Sans Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5854,
"name": "DejaVu Sans Condensed Bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5854,
"name": "Dialog.bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5854,
"name": "SansSerif.bold",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5928,
"name": "DejaVu Sans",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5928,
"name": "DejaVu Sans Condensed",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5928,
"name": "Dialog.plain",
"display_number": true,
"display_alphabet": true
},
{
"display_hiragana": false,
"display_katakana": false,
"display_kanji": false,
"number_of_glyphs": 5928,
"name": "SansSerif.plain",
"display_number": true,
"display_alphabet": true
}
]
}