Python Program to print with your own font
In this tutorial, we will perform a trick to print your own font. In this program, the user will give input and the output will be printed in our own designed font.
In this, we will see output designed from "#" and ".". For better understanding let's see the input and output.
In the above diagram, we can see that the font is created with the help of "#" and ".". Let us now see the approach of the program.
Approach
We have seen the input-output part of the program. The approach is very easy as we just need to follow up with the loop to construct pattern font which is below in the algorithm followed by the code:
Algorithm
Let us now look at the algorithm:
- Accept the user input
- calculate the input length
- Create a for loop and until the length (calculated)
- Create an if loop for all the 26 alphabets which gives the pattern
- Mark the pattern from A to Z with "#" and "."
- The output printed will be the desired font
Program
As of now, we have a rough understanding of printing our own font. Let us now dive deep into the code for understanding:
n = input("Enter the name to print: ")
length = len(n)
l = ""
for a in range(0, length):
b= name[a]
b = b.upper()
if (b == "A"):
print("..######..\n..#....#..\n..######..", end = " ")
print("\n..#....#..\n..#....#..\n")
elif (b == "B"):
print("..######..\n..#....#..\n..#####...", end = " ")
print("\n..#....#..\n..######..\n")
elif (b == "C"):
print("..######..\n..#.......\n..#.......", end = " ")
print("\n..#.......\n..######..\n")
elif (b == "D"):
print("..#####...\n..#....#..\n..#....#..", end = " ")
print("\n..#....#..\n..#####...\n")
elif (b == "E"):
print("..######..\n..#.......\n..#####...", end = " ")
print("\n..#.......\n..######..\n")
elif (b == "F"):
print("..######..\n..#.......\n..#####...", end = " ")
print("\n..#.......\n..#.......\n")
elif (b == "G"):
print("..######..\n..#.......\n..#.####..", end = " ")
print("\n..#....#..\n..#####...\n")
elif (b == "H"):
print("..#....#..\n..#....#..\n..######..", end = " ")
print("\n..#....#..\n..#....#..\n")
elif (b == "I"):
print("..######..\n....##....\n....##....", end = " ")
print("\n....##....\n..######..\n")
elif (b == "J"):
print("..######..\n....##....\n....##....", end = " ")
print("\n..#.##....\n..####....\n")
elif (b == "K"):
print("..#...#...\n..#..#....\n..##......", end = " ")
print("\n..#..#....\n..#...#...\n")
elif (b == "L"):
print("..#.......\n..#.......\n..#.......", end = " ")
print("\n..#.......\n..######..\n")
elif (b == "M"):
print("..#....#..\n..##..##..\n..#.##.#..", end = " ")
print("\n..#....#..\n..#....#..\n")
elif (b == "N"):
print("..#....#..\n..##...#..\n..#.#..#..", end = " ")
print("\n..#..#.#..\n..#...##..\n")
elif (b == "O"):
print("..######..\n..#....#..\n..#....#..", end = " ")
print("\n..#....#..\n..######..\n")
elif (b == "P"):
print("..######..\n..#....#..\n..######..", end = " ")
print("\n..#.......\n..#.......\n")
elif (b == "Q"):
print("..######..\n..#....#..\n..#.#..#..", end = " ")
print("\n..#..#.#..\n..######..\n")
elif (b == "R"):
print("..######..\n..#....#..\n..#.##...", end = " ")
print("\n..#...#...\n..#....#..\n")
elif (b == "S"):
print("..######..\n..#.......\n..######..", end = " ")
print("\n.......#..\n..######..\n")
elif (b == "T"):
print("..######..\n....##....\n....##....", end = " ")
print("\n....##....\n....##....\n")
elif (b == "U"):
print("..#....#..\n..#....#..\n..#....#..", end = " ")
print("\n..#....#..\n..######..\n")
elif (b == "V"):
print("..#....#..\n..#....#..\n..#....#..", end = " ")
print("\n...#..#...\n....##....\n")
elif (b == "W"):
print("..#....#..\n..#....#..\n..#.##.#..", end = " ")
print("\n..##..##..\n..#....#..\n")
elif (b == "X"):
print("..#....#..\n...#..#...\n....##....", end = " ")
print("\n...#..#...\n..#....#..\n")
elif (b == "Y"):
print("..#....#..\n...#..#...\n....##....", end = " ")
print("\n....##....\n....##....\n")
elif (b == "Z"):
print("..######..\n......#...\n.....#....", end = " ")
print("\n....#.....\n..######..\n")
elif (b == " "):
print("..........\n..........\n..........", end = " ")
print("\n..........\n\n")
elif (b == "."):
print("----..----\n\n")
Enter the name to print:
Shubh
..######..
..#.......
..######..
.......#..
..######..
..#....#..
..#....#..
..######..
..#....#..
..#....#..
..#....#..
..#....#..
..#....#..
..#....#..
..######..
..######..
..#....#..
..#####...
..#....#..
..######..
..#....#..
..#....#..
..######..
..#....#..
..#....#..
Conclusion
In this tutorial, we have printed names with our own desired font with help of "#" and ".", you can try with different symbols and structures.