58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
import sys
|
|
from zine_maker import Zine
|
|
|
|
|
|
def make(inputfile, output):
|
|
# Variables
|
|
text_font_size = 10
|
|
|
|
top_margin = 20
|
|
left_margin = 20
|
|
right_margin = 20
|
|
left_max_margin = 160
|
|
|
|
max_height = 190
|
|
cell_width = 110
|
|
cell_header_height = 22
|
|
cell_height = 8
|
|
|
|
# set font for all text
|
|
zine = Zine(orientation="P", unit="mm", format="A5")
|
|
|
|
# text font
|
|
zine.add_font( 'chinese', '', r"fonts/tinming.ttf")
|
|
zine.add_font( 'korean', '', r"fonts/GmarketSansTTFMedium.ttf")
|
|
zine.add_font( 'english', '', r"./fonts/CasaletwoNbp-Bp4V.ttf")
|
|
# zine.add_font( 'english', '', r"fonts/tinming.ttf")
|
|
header_font = 'english'
|
|
english_font = 'english'
|
|
chinese_font = 'chinese'
|
|
korean_font = 'korean'
|
|
# zine.set_font(chinese_font, '', size=text_font_size)
|
|
zine.set_font(english_font, '', size=text_font_size)
|
|
zine.set_text_shaping(True)
|
|
|
|
zine.create_pages(inputfile, max_height, left_margin,
|
|
left_max_margin, top_margin, right_margin,
|
|
cell_width, cell_height, cell_header_height,
|
|
header_font, english_font, chinese_font, korean_font,
|
|
text_font_size)
|
|
|
|
zine.output(output)
|
|
print("PDF saved as {}".format(output))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# input text and output pdf
|
|
if len(sys.argv) > 1:
|
|
if len(sys.argv) == 2:
|
|
output = "./output/body.pdf"
|
|
if len(sys.argv) == 3:
|
|
output = sys.argv[2]
|
|
inputfile = sys.argv[1]
|
|
else:
|
|
inputfile = "./input/body.txt"
|
|
output = "./output/body.pdf"
|
|
|
|
make(inputfile, output)
|