Skip to content

Fonts can be less painful #116

@jstma

Description

@jstma

Passing a font in through --tittleTtfFile is a bit painful. It can be less painful by having a default font.

Lilypond installations will have the following fonts available.

C059, Century SchoolBook URW, Century Schoolbook L, TeX Gyre Schola, DejaVu Serif, …, serif

Pillow needs a file name so we could use one of those fonts by default with ImageFont.truetype('C059-Roman.otf', 20) which works on Linux (Ubuntu 20.04). I don't know if it works on other platforms. If it does, a simple change is required:

    if options.titleAtStart and options.titleTtfFile is None:
        progress("No font specified with --title-ttf=FONT-FILE, using default font.")
        options.titleTtfFile = 'C059-Roman.otf'  # should be available via lilypond

        # Test font loading here, before continuing
        testFont = ImageFont.truetype(options.titleTtfFile)
        if testFont is None:
            fatal("Must specify --title-ttf=FONT-FILE with --title-at-start")

I can't test windows or mac so I don't know if that file is available on those platforms too or if Pillow can find it.

Another option could be to add 'C059-Roman.otf' to the ly2video repo (it's only 96KB), but then using it becomes tricky. I think it needs to be copied to the /tmp/ly2video.../ directory for Pillow to see it. Otherwise you need an absolute path to the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions