import sys
from zine_maker import Zine


def make_cover(finput, foutput):
    # set font for all text
    zine = Zine(orientation="P", unit="mm", format="A5")

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

    zine.cover(finput, cover_font, max_height=140)
    zine.output(foutput)
    print("PDF saved as {}".format(foutput))


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 = "./input/cover.txt"
        output = "./output/cover.pdf"

    make_cover(inputfile, output)
