Random Typography Project: jeder einzelne Charakter wird in eine zufällig ausgesuchte Schrift konvertiert. Da Schrift-Daten nicht nur Buchstaben, sondern auch Grafiken enthalten können, ergibt sich eine typographische Collage mit den entsprechenden Schriften, deren Parameter (size, kerning, leading) alle geändert werden können. Alle Fonts von
dafont.com
#!/bin/bash
# Random Font Typography Script
# Each character from the text file is rendered with a random font from the list below
OFILE="$RANDOM"
# --- Input / Output (Hardwired) ---
INPUT="./input.txt"
OUTPUT="./$OFILE.png"
# --- Fonts (Full Paths) ---
FONTS=(
"./fonts/EmojiFont.ttf"
"./fonts/LEDLIGHT.otf"
"./fonts/Logos tfb.ttf"
"./fonts/BluetagBoldItalic_PERSONAL_USE_ONLY.otf"
"./fonts/Positive System.otf"
"./fonts/ArabTVlogos.ttf"
"./fonts/clothing logos.ttf"
"./fonts/Sci-Fi-Logos.ttf"
"./fonts/the world-'s best logos.ttf"
"./fonts/WarnerLogoFontNine.TTF"
"./fonts/code128.ttf"
"./fonts/Eau de rose.ttf"
"./fonts/Grunge Strokes 01.ttf"
"./fonts/Logos I love.ttf"
"./fonts/openlogos.ttf"
"./fonts/THEBOMB.TTF"
"./fonts/WC_Rhesus_B_Bta.ttf"
"./fonts/Dripping.ttf"
"./fonts/meeksa.ttf"
"./fonts/RFX Splatz.ttf"
"./fonts/Sneakers.ttf"
"./fonts/splatter.ttf"
)
# --- Config ---
FONT_SIZE=80
BG_COLOR="black"
TEXT_COLOR="white"
KERNING=-8
LEADING=-25
CHARS_PER_LINE=12
TMPDIR=$(mktemp -d)
# --- Read text file ---
if [[ ! -f "$INPUT" ]]; then
echo "❌ Text file not found: $INPUT"
exit 1
fi
TEXT=$(cat "$INPUT" | tr -d '\r')
# --- Split text into lines ---
LINES=()
while IFS= read -r LINE; do
while [[ -n "$LINE" ]]; do
LINES+=("${LINE:0:$CHARS_PER_LINE}")
LINE="${LINE:$CHARS_PER_LINE}"
done
done <<< "$TEXT"
# --- Function: render a single line ---
render_line() {
local LINE="$1"
local OUTFILE="$2"
local x_offset=0
local TMP_CANVAS="$TMPDIR/canvas.miff"
magick -size 2000x2000 xc:none "$TMP_CANVAS"
for (( c=0; c<${#LINE}; c++ )); do
CHAR="${LINE:$c:1}"
# Handle spaces and special characters safely
if [[ "$CHAR" == " " ]]; then
CHAR=" " # just skip drawing empty glyph
fi
SAFE_CHAR=$(printf '%s' "$CHAR" | sed "s/'/\\\\'/g; s/\"/\\\\\"/g")
FONT="${FONTS[$((RANDOM % ${#FONTS[@]}))]}"
# Only try to render printable characters
if [[ "$CHAR" =~ [[:print:]] ]]; then
magick -background none -fill "$TEXT_COLOR" \
-font "$FONT" -pointsize "$FONT_SIZE" \
label:"$SAFE_CHAR" "$TMPDIR/char_$c.png" 2>/dev/null || continue
composite -geometry +$x_offset+0 "$TMPDIR/char_$c.png" "$TMP_CANVAS" "$TMP_CANVAS"
fi
x_offset=$((x_offset + FONT_SIZE + KERNING))
done
mv "$TMP_CANVAS" "$OUTFILE"
}
# --- Render all lines ---
line_y=0
magick -size 1000x1000 xc:"$BG_COLOR" "$TMPDIR/final.miff"
for (( i=0; i<${#LINES[@]}; i++ )); do
render_line "${LINES[$i]}" "$TMPDIR/line_$i.miff"
composite -geometry +0+$line_y "$TMPDIR/line_$i.miff" "$TMPDIR/final.miff" "$TMPDIR/final.miff"
line_y=$((line_y + FONT_SIZE + LEADING))
done
# --- Output ---
magick "$TMPDIR/final.miff" "$OUTPUT"
rm -rf "$TMPDIR"
echo "✅ Done! Created overlapping typography at: $OUTPUT"