You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
import time
from reportlab.lib.units import mm, cm, inch, pica
from reportlab.lib.pagesizes import A4, A5, LETTER, LEGAL
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from chordsheet.common import scriptDir
from chordsheet.document import Document, Style, Chord, Block, Section
from chordsheet.render import Renderer
from chordsheet.parsers import parseFingering, parseName
import _version
pdfmetrics.registerFont(
TTFont('FreeSans', os.path.join(scriptDir, 'fonts', 'FreeSans.ttf')))
if sys.platform == "darwin":
pdfmetrics.registerFont(
TTFont('HelveticaNeue', 'HelveticaNeue.ttc', subfontIndex=0))
if len(sys.argv) == 2:
inputFilePath = sys.argv[1]
else:
print("Please provide a .cml, .xml, or .cma file to process.")
sys.exit()
doc = Document()
if inputFilePath[-4:] == ".cma":
doc.loadCSMacro(inputFilePath)
else:
doc.loadXML(inputFilePath)
style = Style()
renderer = Renderer(doc, style)
outputFilePath = ".".join(inputFilePath.split(".")[:-1]) + ".pdf"
renderer.savePDF(outputFilePath)