Guest User

Untitled

a guest
Jan 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.FontMetrics;
  4. import java.awt.Graphics;
  5. import java.awt.GraphicsEnvironment;
  6. import java.awt.geom.Rectangle2D;
  7. import java.awt.image.BufferedImage;
  8. import java.io.File;
  9. import java.io.IOException;
  10. import javax.imageio.ImageIO;
  11.  
  12. public class Generator {
  13. public static void main(String arg[]) throws IOException {
  14. String s = "";
  15. for(int i=0;i<26;i++){
  16. s = ((char)(65+i))+"";
  17. drawLetter(s);
  18. }
  19. //if you want to see what fonts you have in your system, uncomment the following
  20. // displayFonts();
  21. }
  22.  
  23. public static void drawLetter(String key) throws IOException{
  24. final int SIZE = 300;
  25. BufferedImage bufferedImage = new BufferedImage(300, 300,
  26. BufferedImage.TYPE_INT_RGB);
  27. Graphics graphics = bufferedImage.getGraphics();
  28. graphics.setColor(new Color(0xff5252));
  29. // graphics.setColor((Color.WHITE));
  30. graphics.fillRect(0, 0, 300, 300);
  31. graphics.setColor(Color.WHITE);
  32. // graphics.setColor(new Color(0xff5252));
  33. graphics.setFont(new Font("GT Walsheim", Font.BOLD, 200));
  34.  
  35. FontMetrics fm = graphics.getFontMetrics();
  36. int x = (SIZE - fm.stringWidth(key)) / 2;
  37. int y = (fm.getAscent() + (SIZE - (fm.getAscent() + fm.getDescent())) / 2);
  38. graphics.drawString(key, x, y);
  39. ImageIO.write(bufferedImage, "png", new File(
  40. "Documents/op_default_pics/default_profile_dark_"+key.toLowerCase()+".png"));
  41. System.out.println("Image Created "+ key);
  42. }
  43.  
  44. //Call this method to see what fonts your machine has installed and can be used
  45. public static void displayFonts(){
  46. String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
  47. for ( int i = 0; i < fonts.length; i++ )
  48. {
  49. System.out.println(fonts[i]);
  50. }
  51. }
  52. }
Add Comment
Please, Sign In to add comment