--Écrire un programme Java pour savoir s'il existe une police qui peut utiliser le japonais avec AWS Lambda + Java
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>> {
/**
*Il s'agit du point d'entrée lors de l'exécution en tant qu'application Java autonome.
*
* @param args non utilisé
*/
public static void main(String[] args) {
Map<String, Object> output = new FontList().invoke();
//Informations de police de sortie
for (Map font : (List<Map>) output.get("fonts")) {
System.out.println(font);
}
//Informations système
System.out.println(output.get("system"));
}
/**
*Point d'entrée lors de l'exécution de la fonction AWS Lambda(Méthode du gestionnaire)est.
*
* @param input Données d'entrée
* @param context Objet de contexte AWS Lambda
* @renvoyer les données de sortie
*/
@Override
public Map<String, Object> handleRequest(Map<String, Object> input, Context context) {
return invoke();
}
/**
*Renvoie des informations sur les polices disponibles.
*
* @retour Informations sur les polices disponibles
*/
private static Map<String, Object> invoke() {
//Obtenez une liste des polices disponibles
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] allFonts = ge.getAllFonts();
//Vérifiez si différents caractères peuvent être utilisés
List<Map> fonts = Arrays.stream(allFonts)
.sorted(Comparator.comparing(Font::getNumGlyphs)) //Trier par numéro de glyphe
.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('UNE'));
m.put("display_kanji", f.canDisplay('Sous'));
return m;
})
.collect(Collectors.toList());
//Obtenir des informations système
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"));
//Créer des données de sortie
Map output = new HashMap<String, Object>();
output.put("fonts", fonts);
output.put("system", system);
return output;
}
/**
*Obtient les propriétés système indiquées par la clé spécifiée.
*
* @param key Le nom de la propriété système
* @return Valeur de chaîne de propriété système(Null si aucune propriété avec cette clé n'existe)
*/
private static String getSystemProperty(String key) {
try {
return System.getProperty(key);
} catch (SecurityException e) {
return e.toString();
}
}
}
Malheureusement, pour le moment, il n'y a pas de polices dans le système qui peuvent utiliser le japonais (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
}
]
}
Recommended Posts