AZRandomFont.java 412 Bytes
Newer Older
楊慶堂's avatar
楊慶堂 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
package io.github.apollozhu.awt;

import java.awt.*;

public class AZRandomFont {
    public static Font ofSiZe(float size) {
        Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
        int idx = (int) (Math.random() * fonts.length);
        return fonts[idx].deriveFont(style(), size);
    }

    public static int style() {
        return (int) (Math.random() * 4);
    }
}