Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.GraphicsEnvironment;
- import java.awt.geom.Rectangle2D;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- public class Generator {
- public static void main(String arg[]) throws IOException {
- String s = "";
- for(int i=0;i<26;i++){
- s = ((char)(65+i))+"";
- drawLetter(s);
- }
- //if you want to see what fonts you have in your system, uncomment the following
- // displayFonts();
- }
- public static void drawLetter(String key) throws IOException{
- final int SIZE = 300;
- BufferedImage bufferedImage = new BufferedImage(300, 300,
- BufferedImage.TYPE_INT_RGB);
- Graphics graphics = bufferedImage.getGraphics();
- graphics.setColor(new Color(0xff5252));
- // graphics.setColor((Color.WHITE));
- graphics.fillRect(0, 0, 300, 300);
- graphics.setColor(Color.WHITE);
- // graphics.setColor(new Color(0xff5252));
- graphics.setFont(new Font("GT Walsheim", Font.BOLD, 200));
- FontMetrics fm = graphics.getFontMetrics();
- int x = (SIZE - fm.stringWidth(key)) / 2;
- int y = (fm.getAscent() + (SIZE - (fm.getAscent() + fm.getDescent())) / 2);
- graphics.drawString(key, x, y);
- ImageIO.write(bufferedImage, "png", new File(
- "Documents/op_default_pics/default_profile_dark_"+key.toLowerCase()+".png"));
- System.out.println("Image Created "+ key);
- }
- //Call this method to see what fonts your machine has installed and can be used
- public static void displayFonts(){
- String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
- for ( int i = 0; i < fonts.length; i++ )
- {
- System.out.println(fonts[i]);
- }
- }
- }
Add Comment
Please, Sign In to add comment