Last active
March 6, 2017 13:27
-
-
Save paulera/9f6dfccee1090ab58437fd13c4a40b9e to your computer and use it in GitHub Desktop.
List some fonts in Processing and save the result as a png.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PFont defaultFont; | |
int paddingLeft = 25; | |
int paddingTop = 20; | |
int row = 0; | |
int fontSize = 24; | |
int lineHeight = fontSize * 4; | |
int examplesPerColumn = 9; | |
int exampleCount = 0; | |
int columnWidth = 900; | |
void setup() { | |
background (255); | |
defaultFont = createDefaultFont(fontSize); | |
size (1440, 800); | |
fill(0); | |
showTheFont("Arial"); | |
showTheFont("Georgia"); | |
showTheFont("Impact"); | |
showTheFont("Lucida"); | |
showTheFont("Papyrus"); | |
showTheFont("Tahoma"); | |
showTheFont("Verdana"); | |
showTheFont("Courier"); | |
save("fonts.png"); | |
} | |
void showTheFont(String fontName) { | |
int y; | |
int x; | |
PFont font; | |
x = paddingLeft + (int)(exampleCount / examplesPerColumn) * columnWidth; | |
y = paddingTop + fontSize + (row * lineHeight); | |
textFont(defaultFont); | |
text(fontName+":", x, y); | |
y = paddingTop + fontSize + (row * lineHeight) + (int)(fontSize * 2); | |
font = createFont(fontName, fontSize * 2); | |
textFont(font); | |
text("a b c d e f g h 0 1 2 3 4 @ $ % : ? ! , + - = *", x+fontSize, y); | |
row = row + 1; | |
if (row == examplesPerColumn) row = 0; | |
exampleCount = exampleCount + 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment