import sys
import random
from zine_maker import Zine


def make_colophon(inputfile, output):

    # set font for all text
    zine = Zine(orientation="P", unit="mm", format="A5")

    # you can change the font to text_font 1 or 2
    # or add your fonts

    # colophon font
    zine.add_font(
        'CasaleNBP', '', r"./fonts/CasaletwoNbp-Bp4V.ttf", uni=True)
    text_font1 = 'CasaleNBP'

    # colophon font alternate
    zine.add_font(
        'Kpalter', '',
        r"fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True)
    # text_font2 = 'Kpalter'

    zine.colophon(inputfile, text_font1)
    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) == 3:
            output = sys.argv[2]
        inputfile = sys.argv[1]
    else:
        inputfile = "./text/colophon_readme.txt"
        output = "./colophons/colophon_readme.pdf".format(random.randint(1, 40))

    make_colophon(inputfile, output)
