Golf me an ASCII Alphabet
Python 3, 375 bytes
f=lambda i:"\n\n".join("\n".join(map(" ".join,zip(*[[x.replace("0"," ")[a*5:a*5+5]for a in range(5)]for x in[["{:025b}".format(int(c,36))for c in'0 JPCFL J2UKE 92Y3Y J2KAM JOMCF JOMC0 92B72 AYP81 JFM3J JFMHO AZC7M AB6ZJ B5I5T B43N5 92YWE J2UJ4 92YY7 J2UQC 926UM JFM2S AYE5Q AY8G4 AYHKH AT6Q9 AT6KK AWU7'.split()][x!=" "and ord(x)-64]for x in j.upper()]])))for j in i.split("\n"))
See this code running on ideone.com.
The same code, but somehow nicely indented, formatted and commented:
f = lambda i: \
# join multiline strings together using an empty line as separator:
"\n\n".join(
# join the string lines of one big output line together:
"\n".join(
# join the corresponding rows of the letters together using " ":
map(" ".join, zip(*
# make a list (output line) of list (output characters)
# of strings (single character's rows):
[
# replace 0s with spaces and split the bit strings into
# chunks of 5 characters - the rows of each letter:
[x.replace("0", " ")[a*5 : a*5+5] for a in range(5)]
for x in [
# split the space separated character codes and
# convert them from base 36 to
# base 2 strings of length 25:
["{:025b}".format(int(c, 36)) for c in
# the encoded font data (reformatted):
'0 JPCFL J2UKE 92Y3Y J2KAM JOMCF JOMC0 92B72 '
'AYP81 JFM3J JFMHO AZC7M AB6ZJ B5I5T B43N5 92YWE '
'J2UJ4 92YY7 J2UQC 926UM JFM2S AYE5Q AY8G4 AYHKH '
'AT6Q9 AT6KK AWU7'.split()]
# select element 0 if we want a space, else find
# out the index from the ASCII code of the letter:
[x != " " and ord(x) - 64]
# repeat for every character in the input line:
for x in j.upper()
]
]
))
# repeat for every line in the input
) for j in i.split("\n")
)
I also decided to go for base 36 encoding as that's the highest base Python's built-in int()
natively supports. Here is a short Python 3 script I wrote (ungolfed) that converts font definitions like in the question into base 36 codes: My converter on ideone.com
The result consists of the character 1
as enabled pixel and a space
as disabled pixel. Here's a single example run:
Input (line break as \n
):
Hello World
Python rocks
Output:
1 1 11111 1 1 111 1 1 111 1111 1 1111
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11111 1111 1 1 1 1 1 1 1 1 1 1111 1 1 1
1 1 1 1 1 1 1 11 11 1 1 11 1 1 1
1 1 11111 11111 11111 111 1 1 111 1 1 11111 1111
1111 1 1 11111 1 1 111 1 1 1111 111 111 1 1 111
1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1
1111 1 1 11111 1 1 1 1 1 1111 1 1 1 111 111
1 1 1 1 1 1 1 1 11 11 1 1 1 1 1 1 1
1 1 1 1 1 111 1 1 1 1 111 111 1 1 111
Clojure, 552 bytes
(defn t[s](print(reduce #(str %1"\n"%2)(map #(apply str %)(let[a[:jpcfl :j2uke :92y3y :j2kam :jomcf :jomc0 :92b72 :ayp81 :jfm3j :jfmho :azc7m :ab6zj :b5i5t :b43n5 :92ywe :j2uj4 :92yy7 :j2uqc :926um :jfm2s :aye5q :ay8g4 :ayhkh :at6q9 :at6kk :je7mn :0]](map(fn[o](map #(str(.replace %"0"" ")"\n")(map(fn[w](reduce #(str %1(.substring %2 w(+ w 5))"0")""(map #(str(apply str(repeat(- 25(count %))"0"))%)(map #(Integer/toString(Integer/valueOf(name %)36)2)(map a(map #(if(= % \space)26(-(int %)97))(.toLowerCase o)))))))(range 0 25 5))))(.split s"\n")))))))
Each letter in ascii is represented as a binary string with # - 1, space - 0. Then it's converted to base 36 so that it only takes 5 chars to store + ":" to let Clojure know that it should be treated as symbol. Then the input is split by newline symbol and for each line we convert a letter in 36 base back to binary base and get first [0:5] symbols add newline symbols, get next [5:10] symbols and so on.
You can see it running here - https://ideone.com/y99ST5