Ejemplo n.º 1
0
  public static void reloadFonts() {
    String font1Path = Config.getString("font1_file");
    String font2Path = Config.getString("font2_file");

    int font1Type = font1Path.endsWith(".ttf") ? Font.TRUETYPE_FONT : Font.TYPE1_FONT;
    int font2Type = font2Path.endsWith(".ttf") ? Font.TRUETYPE_FONT : Font.TYPE1_FONT;

    File font1 = new File(font1Path);
    File font2 = new File(font2Path);

    try {
      fonts =
          new Font[] {
            Font.createFont(font1Type, font1)
                .deriveFont(Font.BOLD, Integer.parseInt(Config.getString("font1_size"))),
            Font.createFont(font2Type, font2)
                .deriveFont(Font.BOLD, Integer.parseInt(Config.getString("font2_size"))),
          };
    } catch (IOException | FontFormatException e) {
      JOptionPane.showMessageDialog(
          instance,
          "Font failed to load: " + e,
          Constants.SOFTWARE_NAME,
          JOptionPane.WARNING_MESSAGE);
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  static {
    try (InputStream is =
        CrashServer.class
            .getClassLoader()
            .getResourceAsStream("AnonymousPro-1.002.001/Anonymous Pro.ttf")) {
      // "ScoreFont.ttf");
      font = Font.createFont(Font.TRUETYPE_FONT, is);
      System.out.println(font);
    } catch (IOException | FontFormatException ex) {
      ex.printStackTrace();
      System.err.println("Font absent from res!");
      font = Font.decode("Arial 12");
    }

    try {
      bg = ImageIO.read(CrashServer.class.getClassLoader().getResourceAsStream("sunset-bg.png"));
    } catch (IOException | IllegalArgumentException e1) {
      bg = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB);
      Graphics g = bg.getGraphics();
      g.setColor(MAROON);
      g.fillRect(0, 0, W, H);
    }
  }