Add fonts, text, img, output folders

This commit is contained in:
Mara Karagianni 2021-12-10 01:24:22 +02:00
parent 5b507017a6
commit 65e2860b65
24 changed files with 56 additions and 69 deletions

BIN
body/images.pdf Normal file

Binary file not shown.

BIN
body/oulipo.pdf Normal file

Binary file not shown.

BIN
body/oulipo1.pdf Normal file

Binary file not shown.

View file

@ -1,4 +1,5 @@
import sys import sys
import random
from zine_maker import Zine from zine_maker import Zine
@ -12,17 +13,19 @@ def make_colophon():
# cover font # cover font
zine.add_font( zine.add_font(
'CasaleNBP', '', r"/home/mara/.fonts/CasaletwoNbp-Bp4V.ttf", uni=True) 'CasaleNBP', '', r"fonts/CasaletwoNbp-Bp4V.ttf", uni=True)
cover_font = 'CasaleNBP' cover_font = 'CasaleNBP'
# text font # text font
zine.add_font( zine.add_font(
'Kpalter', '', 'Kpalter', '',
r"/home/mara/.fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True) r"fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True)
text_font = 'Kpalter' text_font = 'Kpalter'
zine.set_font(text_font, '', size=text_font_size) zine.set_font(text_font, '', size=text_font_size)
zine.colophon(inputfile) # you can change the font to text_font
# or add your fonts
zine.colophon(inputfile, cover_font)
zine.output(output) zine.output(output)
@ -34,6 +37,6 @@ if __name__ == '__main__':
inputfile = sys.argv[1] inputfile = sys.argv[1]
else: else:
inputfile = "./text/colophon.txt" inputfile = "./text/colophon.txt"
output = './covers/colophon.pdf' output = "./colophones/colophon{}.pdf".format(random.randint(1, 40))
make_colophon() make_colophon()

BIN
colophones/colophon.pdf Normal file

Binary file not shown.

View file

@ -1,41 +1,26 @@
import sys import sys
import random
from zine_maker import Zine from zine_maker import Zine
def make_cover(): def make_cover():
# Variables # Variables
header_font = 'helvetica'
header_font_size = 14
text_font_size = 12 text_font_size = 12
top_margin = 20
left_margin = 20
right_margin = 20
left_max_margin = 160
max_height = 190
left_x = 20
top_y = 30
cell_width = 110
cell_header_height = 16
cell_height = 6
# set font for all text # set font for all text
zine = Zine(orientation="P", unit="mm", format="A5") zine = Zine(orientation="P", unit="mm", format="A5")
# cover font # cover font
zine.add_font('CasaleNBP', '', r"/home/mara/.fonts/CasaletwoNbp-Bp4V.ttf", uni=True) zine.add_font('CasaleNBP', '', r"fonts/CasaletwoNbp-Bp4V.ttf", uni=True)
cover_font = 'CasaleNBP' cover_font = 'CasaleNBP'
# text font # text font
zine.add_font( zine.add_font(
'Kpalter', '', r"/home/mara/.fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True) 'Kpalter', '', r"fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True)
text_font = 'Kpalter' text_font = 'Kpalter'
zine.set_font(text_font, '', size=text_font_size) zine.set_font(text_font, '', size=text_font_size)
zine.cover("deconstruct mailman", cover_font, max_height=140) zine.cover(inputfile, cover_font, max_height=140)
# import random
# zine.output("cover{}.pdf".format(random.randint(10, 20)))
zine.output(output) zine.output(output)
@ -47,6 +32,6 @@ if __name__ == '__main__':
inputfile = sys.argv[1] inputfile = sys.argv[1]
else: else:
inputfile = "./text/cover.txt" inputfile = "./text/cover.txt"
output = './covers/cover.pdf' output = "./covers/cover{}.pdf".format(random.randint(1, 40))
make_cover() make_cover()

BIN
covers/cover.pdf Normal file

Binary file not shown.

View file

@ -1,4 +1,5 @@
import sys import sys
import random
from zine_maker import Zine from zine_maker import Zine
@ -20,26 +21,21 @@ def make():
cell_header_height = 16 cell_header_height = 16
cell_height = 6 cell_height = 6
# Image variables
# img_x = 20
# img_y = 80
# img_len = 120
# set font for all text # set font for all text
zine = Zine(orientation="P", unit="mm", format="A5") zine = Zine(orientation="P", unit="mm", format="A5")
# cover font # cover font
zine.add_font( zine.add_font(
'CasaleNBP', '', r"/home/mara/.fonts/CasaletwoNbp-Bp4V.ttf", uni=True 'CasaleNBP', '', r"fonts/CasaletwoAlternatesNbp-RgRM.ttf", uni=True
) )
cover_font = 'CasaleNBP' cover_font = 'CasaleNBP'
# text font # text font
zine.add_font( zine.add_font(
'Kpalter', '', 'Kpalter', '',
r"/home/mara/.fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True r"fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True
) )
text_font = 'Helvetica' text_font = 'Kpalter'
zine.set_font(text_font, '', size=text_font_size) zine.set_font(text_font, '', size=text_font_size)
zine.create_pages(inputfile, max_height, left_margin, zine.create_pages(inputfile, max_height, left_margin,
@ -57,7 +53,7 @@ if __name__ == '__main__':
output = sys.argv[2] output = sys.argv[2]
inputfile = sys.argv[1] inputfile = sys.argv[1]
else: else:
inputfile = "./text/notes_sample" inputfile = "./text/oulipo1.txt"
output = './finals/test.pdf' output = "./body/body{}.pdf".format(random.randint(1, 40))
make() make()

Binary file not shown.

Binary file not shown.

BIN
fonts/CasaletwoNbp-Bp4V.pkl Normal file

Binary file not shown.

BIN
fonts/CasaletwoNbp-Bp4V.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -253,7 +253,7 @@ class Zine(FPDF):
top_margin = 20 top_margin = 20
margin = 25 margin = 25
self.add_font( self.add_font(
'CasaleNBP', '', r"/home/mara/.fonts/CasaletwoNbp-Bp4V.ttf", 'CasaleNBP', '', r"fonts/CasaletwoNbp-Bp4V.ttf",
uni=True) uni=True)
self.set_margins(margin, top_margin, margin) self.set_margins(margin, top_margin, margin)
size = 13 size = 13
@ -288,12 +288,12 @@ else:
zine = Zine(orientation="P", unit="mm", format="A5") zine = Zine(orientation="P", unit="mm", format="A5")
# cover font # cover font
zine.add_font('CasaleNBP', '', r"/home/mara/.fonts/CasaletwoNbp-Bp4V.ttf", uni=True) zine.add_font('CasaleNBP', '', r"fonts/CasaletwoNbp-Bp4V.ttf", uni=True)
cover_font = 'CasaleNBP' cover_font = 'CasaleNBP'
# text font # text font
zine.add_font( zine.add_font(
'Kpalter', '', r"/home/mara/.fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True) 'Kpalter', '', r"fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True)
text_font = 'Kpalter' text_font = 'Kpalter'
zine.set_font(text_font, '', size=text_font_size) zine.set_font(text_font, '', size=text_font_size)

BIN
thumbs/compiler.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
thumbs/libs-black.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
thumbs/libs-green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
thumbs/mailman-config.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
thumbs/system-config.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
thumbs/venv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -202,50 +202,53 @@ class Zine(FPDF):
# self.footer() # self.footer()
def cover(self, title, cover_font, max_height): def cover(self, file_title, cover_font, max_height):
col = 10 col = 10
margin = 15 margin = 15
import random import random
self.set_margins(margin, margin, margin) self.set_margins(margin, margin, margin)
self.add_page() self.add_page()
for letter in title: try:
if self.get_y() >= max_height: title = open(file_title, 'r')
self.set_xy(margin+col, margin) except Exception as e:
col += 40 print(e, "Make sure the path and the file exists!", end="\n")
size = random.randrange(30, 50, 15) else:
self.set_font(cover_font, '', size) for line in title.readlines():
variable_x = margin+col for letter in line:
print("LETTER {}, POSITION Y {}".format(letter, self.get_y())) if self.get_y() >= max_height:
print("VAR X {}".format(variable_x)) self.set_xy(margin+col, margin)
self.set_xy(variable_x, self.get_y()) col += 40
size = random.randrange(30, 50, 15)
self.set_font(cover_font, '', size)
variable_x = margin+col
print("LETTER {}, POSITION Y {}".format(letter, self.get_y()))
print("VAR X {}".format(variable_x))
self.set_xy(variable_x, self.get_y())
self.cell(size, size, letter) self.cell(size, size, letter)
self.line(size, size, self.get_x(), self.get_y()) self.line(size, size, self.get_x(), self.get_y())
if(size % 2 == 0): if(size % 2 == 0):
var = "DF" var = "DF"
# r = 138, 43, 226 R = random.randrange(30, 255, 40)
R = random.randrange(30, 255, 40) G = random.randrange(0, 55, 55)
G = random.randrange(0, 55, 55) B = random.randrange(0, 155, 50)
B = random.randrange(0, 155, 50) self.set_fill_color(R, G, B)
self.set_fill_color(R, G, B) else:
else: var = "D"
var = "D" print(var)
print(var) self.rect(
self.rect( float(self.get_x()), float(self.get_y()),
float(self.get_x()), float(self.get_y()), float(size/2), float(size*4), style=var)
float(size/2), float(size*4), style=var) self.ln(size/2)
self.ln(size/2)
def colophon(self, text): title.close()
def colophon(self, text, cover_font):
lines = open(text, 'r').readlines() lines = open(text, 'r').readlines()
top_margin = 20 top_margin = 20
margin = 25 margin = 25
self.add_font(
'CasaleNBP', '', r"/home/mara/.fonts/CasaletwoNbp-Bp4V.ttf",
uni=True)
self.set_margins(margin, top_margin, margin) self.set_margins(margin, top_margin, margin)
size = 13 size = 13
cover_font = 'CasaleNBP'
self.set_font(cover_font, '', size) self.set_font(cover_font, '', size)
self.add_page() self.add_page()
for line in lines: for line in lines: