-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
198 lines (190 loc) · 5.85 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# sheet size is 2480 * 3508
# we have margins of 120 and 48
from PIL import Image
import os
img = Image.open("Canvas/sheet.png")
img.save("sheet.png")
print("Choose Your Font:")
print("1. Lamptey\n2. Alexandria\n3. Mersey")
print("Your Choice: ", end='')
choice = int(input())
if choice == 1:
#open the file
f = open('data.txt', 'r')
data = f.read()
xP = 120
yP = 48
data += " "
for i in range(len(data)):
try:
if i == len(data) - 1:
continue
#open the image
image = Image.open('sheet.png')
#os.remove('sheet.png')
if data[i] == " ":
char = "LampteyFont/space.png"
elif data[i] == ".":
char = "LampteyFont/dot.png"
elif data[i] == "~":
char = "LampteyFont/tilde.png"
elif data[i] == "/":
char = "LampteyFont/fslash.png"
elif data[i] == '\n':
xP = 120
yP += 120
if yP > 3494:
break
continue
else:
char = data[i]+".png"
char = "LampteyFont/" + char
img2 = Image.open(char)
pos = ((xP), (yP))
image.paste(img2, pos, img2)
image.save("sheet.png")
xP += 60
if xP > 2360:
xP = 120
yP += 120
if yP > 3460:
break
if xP >= 2240:
if data[i+1] == " " or data[i+1] == "\n" or data[i+1] == "'" or data[i+1] == "-":
continue
else:
char = "LampteyFont/-.png"
img2 = Image.open(char)
pos = ((xP), (yP))
image.paste(img2, pos, img2)
image.save("sheet.png")
xP = 120
yP += 120
if yP > 3460:
break
except:
print("Invalid Character")
break
print("Image is now Complete.")
elif choice == 2:
#open the file
f = open('data.txt', 'r')
data = f.read()
xP = 120
yP = 48
data += " "
for i in range(len(data)):
try:
if i == len(data) - 1:
continue
#open the image
image = Image.open('sheet.png')
#os.remove('sheet.png')
if data[i] == " ":
char = "AlexandriaFont/space.png"
elif data[i] == ".":
char = "AlexandriaFont/dot.png"
elif data[i] == "~":
char = "AlexandriaFont/tilde.png"
elif data[i] == "/":
char = "AlexandriaFont/fslash.png"
elif data[i] == '\n':
xP = 120
yP += 120
if yP > 3494:
break
continue
else:
char = data[i]+".png"
char = "AlexandriaFont/" + char
img2 = Image.open(char)
(x, y) = img2.size
pos = ((xP), (yP))
image.paste(img2, pos, img2)
image.save("sheet.png")
xP += x
if xP > 2360:
xP = 120
yP += 120
if yP > 3460:
break
if xP >= 2240:
if data[i+1] == " " or data[i+1] == "\n" or data[i+1] == "'" or data[i+1] == "-":
continue
else:
char = "AlexandriaFont/-.png"
img2 = Image.open(char)
pos = ((xP), (yP))
image.paste(img2, pos, img2)
image.save("sheet.png")
xP = 120
yP += 120
if yP > 3460:
break
except:
print("Invalid Character")
break
print("Image is now Complete.")
elif choice == 3:
#open the file
f = open('data.txt', 'r')
data = f.read()
xP = 120
yP = 48
data += " "
for i in range(len(data)):
try:
if i == len(data) - 1:
continue
#open the image
image = Image.open('sheet.png')
#os.remove('sheet.png')
if data[i] == " ":
char = "MerseyFont/space.png"
elif data[i] == ".":
char = "MerseyFont/dot.png"
elif data[i] == "~":
char = "MerseyFont/tilde.png"
elif data[i] == "/":
char = "MerseyFont/fslash.png"
elif data[i] == '\n':
xP = 120
yP += 120
if yP > 3494:
break
continue
else:
char = data[i]+".png"
char = "MerseyFont/" + char
img2 = Image.open(char)
(x, y) = img2.size
pos = ((xP), (yP))
image.paste(img2, pos, img2)
image.save("sheet.png")
xP += x
if xP > 2360:
xP = 120
yP += 120
if yP > 3460:
break
if xP >= 2240:
if data[i+1] == " " or data[i+1] == "\n" or data[i+1] == "'" or data[i+1] == "-":
continue
else:
char = "MerseyFont/-.png"
img2 = Image.open(char)
pos = ((xP), (yP))
image.paste(img2, pos, img2)
image.save("sheet.png")
xP = 120
yP += 120
if yP > 3460:
break
except:
print("Invalid Character")
break
print("Image is now Complete.")
else:
print("Invalid Choice.")
image.save('sheet.pdf')
print("PDF is Ready.")