package demos; import java.awt.Font; import java.awt.GraphicsEnvironment; import plotter.Graphic; import plotter.Plotter; import plotter.TextObject; public class ZeigeDameUnicode { public static void main(String[] args) { Graphic graphic = new Graphic("Dame"); Plotter plotter = graphic.getPlotter(); String DAME = "\u2655"; // unicode for white queen Font font = testFonts(); if( font != null ){ TextObject t = plotter.setText(DAME, 0, 0); font = font.deriveFont(80.f).deriveFont(Font.BOLD); t.setFont(font); } else { plotter.setText("Keinen passenden Font gefunden", 0, 0); } graphic.repaint(); } /** * Search a font with a glyph for chess pieces * * @return the font or null if no matching font was found */ private static Font testFonts() { // erfrage alle verfuegbaren Fonts GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); // das Feld fonts enthaelt alle fonts Font[] fonts = ge.getAllFonts(); System.out.println("insgesamt " + fonts.length + " Fonts gefunden"); for (Font f : fonts) { if (f.canDisplay(0x2655)) { System.out.println("Font : " + f); return f; } } System.out.println("Keinen passenden Font gefunden"); return null; } }