Example usage for java.awt GraphicsEnvironment getAllFonts

List of usage examples for java.awt GraphicsEnvironment getAllFonts

Introduction

In this page you can find the example usage for java.awt GraphicsEnvironment getAllFonts.

Prototype

public abstract Font[] getAllFonts();

Source Link

Document

Returns an array containing a one-point size instance of all fonts available in this GraphicsEnvironment .

Usage

From source file:MainClass.java

public static void main(String[] a) {
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = e.getAllFonts(); // Get the fonts
    for (Font f : fonts) {
        System.out.println(f.getFontName());
    }/*w  w  w .j  a v a 2 s  .c  o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = ge.getAllFonts();
    for (Font font : fonts) {
        String fontName = font.getName();
        String familyName = font.getFamily();

        System.out.println("Font: " + fontName + "; family: " + familyName);
    }/*from   w  w w  . j a  v a 2s . c o m*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = ge.getAllFonts();

    for (int i = 0; i < fonts.length; i++) {
        System.out.print(fonts[i].getFontName() + " : ");
        System.out.print(fonts[i].getFamily() + " : ");
        System.out.print(fonts[i].getName());
        System.out.println();/*from w  w  w.  jav  a  2s.c o m*/
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Map<String, List<String>> fontFaceNames = new HashMap<String, List<String>>();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = ge.getAllFonts();

    for (int i = 0; i < fonts.length; i++) {
        String familyName = fonts[i].getFamily();
        String faceName = fonts[i].getName();

        List<String> list = fontFaceNames.get(familyName);
        if (list == null) {
            list = new ArrayList<String>();
            fontFaceNames.put(familyName, list);
        }//  ww w  . j a  v  a2 s. co m
        list.add(faceName);
    }
    System.out.println(fontFaceNames);

}

From source file:org.lobzik.home_sapiens.pi.BoxRegistrator.java

/**
 * @param args the command line arguments
 *///  w w  w . j  a v  a 2s  .c  o m
public static void main(String[] args) {
    // TODO code application logic here
    try {
        /*
        if (BoxCommonData.BOX_ID > 0) {
        System.err.println("Box registered already, " + BoxCommonData.BOX_ID_FILE + " exists. Exiting.");
        return;
        }
                
        JSONObject boxJson = new JSONObject();
        boxJson.put("ssid", BoxCommonData.SSID);
        boxJson.put("public_key", new String(Files.readAllBytes(Paths.get(BoxCommonData.PUBLIC_KEY_FILE)), "UTF-8"));
        boxJson.put("version", BoxCommonData.BOX_VERSION);
        boxJson.put("wpa_psk", BoxCommonData.WPA_PSK);
                
        JSONObject reqJson = new JSONObject();
        reqJson.put("action", "register_request");
        reqJson.put("box_data", boxJson);
                
        URL url = new URL(BoxCommonData.REGISTER_SERVER_URL);
                
        URLConnection conn = url.openConnection();
        conn.setDoInput(true);
        conn.setDoOutput(true);
        OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
        out.write(reqJson.toString());
        out.close();
                
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String decodedString;
        StringBuffer sb = new StringBuffer();
        while ((decodedString = in.readLine()) != null) {
        sb.append(decodedString);
        }
        in.close();
        JSONObject response = new JSONObject(sb.toString());
        if (response.has("register_result") && response.getString("register_result").equals("success")) {
                
        int id = response.getInt("box_id");
        File boxIdFile = new File(BoxCommonData.BOX_ID_FILE);
        FileOutputStream fos = new FileOutputStream(boxIdFile);
        OutputStreamWriter idFileOs = new OutputStreamWriter(fos);
        idFileOs.write("box_id=" + id + "\n");
        idFileOs.flush();
        idFileOs.close();
        fos.flush();
        fos.close();
        System.out.println("Box registered successfully");
        System.out.println("Box ID: " + id);
        System.out.println("Box SSID: " + BoxCommonData.SSID);
        System.out.println("Box WPA_PSK: " + BoxCommonData.WPA_PSK); //print on a sticker
        System.out.println("Box RSA public key: " + BoxCommonData.PUBLIC_KEY);
        System.out.println("Box registration done");
        } else {
        System.err.println("Error while registering device ");
        System.err.println(sb.toString());
        }
        //boxIdFile.
         */

        GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Font[] fonts = e.getAllFonts(); // Get the fonts
        for (Font f : fonts) {
            System.out.println(f.getFontName());
        }

    } catch (Throwable e) {
        System.err.println("Error while registering device ");
        e.printStackTrace();
    }
}

From source file:TextBouncer.java

public static void main(String[] args) {

    String s = "Java Source and Support";
    final int size = 64;
    if (args.length > 0)
        s = args[0];/*from w  ww .  j a v  a  2s  . c  o  m*/

    Panel controls = new Panel();
    final Choice choice = new Choice();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] allFonts = ge.getAllFonts();
    for (int i = 0; i < allFonts.length; i++)
        choice.addItem(allFonts[i].getName());
    Font defaultFont = new Font(allFonts[0].getName(), Font.PLAIN, size);

    final TextBouncer bouncer = new TextBouncer(s, defaultFont);
    Frame f = new AnimationFrame(bouncer);
    f.setFont(new Font("Serif", Font.PLAIN, 12));
    controls.add(bouncer.createCheckbox("Antialiasing", TextBouncer.ANTIALIASING));
    controls.add(bouncer.createCheckbox("Gradient", TextBouncer.GRADIENT));
    controls.add(bouncer.createCheckbox("Shear", TextBouncer.SHEAR));
    controls.add(bouncer.createCheckbox("Rotate", TextBouncer.ROTATE));
    controls.add(bouncer.createCheckbox("Axes", TextBouncer.AXES));

    Panel fontControls = new Panel();
    choice.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            Font font = new Font(choice.getSelectedItem(), Font.PLAIN, size);
            bouncer.setFont(font);
        }
    });
    fontControls.add(choice);

    Panel allControls = new Panel(new GridLayout(2, 1));
    allControls.add(controls);
    allControls.add(fontControls);
    f.add(allControls, BorderLayout.NORTH);
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:TrueTypeJokerman.java

public TrueTypeJokerman() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.getAllFonts();

    Font font = new Font("Jokerman", Font.PLAIN, 35);
    JLabel textLabel = new JLabel(textMessage);
    textLabel.setFont(font);/*from   ww w  .  ja  va  2  s . c  o m*/

    getContentPane().add(textLabel);
    setVisible(true);
}

From source file:Main.java

public Main() {
    super("TrueType Font Demonstration");

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.getAllFonts();

    Font font = new Font("Jokerman", Font.PLAIN, 35);
    JLabel textLabel = new JLabel(textMessage);
    textLabel.setFont(font);//www  . java2s.c  o  m

    getContentPane().add(textLabel);
    setVisible(true);
}

From source file:TrueTypeTest.java

public TrueTypeTest() {
    super("TrueType Font Demonstration");

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.getAllFonts();

    Font font = new Font("Jokerman", Font.PLAIN, 35);
    JLabel textLabel = new JLabel(textMessage);
    textLabel.setFont(font);/*from   w w w.  j  ava 2  s .c o  m*/

    getContentPane().add(textLabel);
    show();
}

From source file:PaintAllFontsFromGraphicEvironment.java

public void paint(Graphics g) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

    Font[] allFonts = ge.getAllFonts();

    for (int i = 0; i < allFonts.length; i++) {
        Font f = allFonts[i].deriveFont(10.0f);
        g.setFont(f);//w  ww  .j  a  v a 2 s .  c  o  m

        g.setColor(Color.black);
        g.drawString("Hello!", 10, 20 * i);

    }
}