aspiers / aspiers/ly2video

Fonts can be less painful

Open
#116 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
192
Forks
30
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the handling for --title-at-start and --title-ttf, then inspect where Pillow's ImageFont.truetype call is made. Check whether C059-Roman.otf can be found on the relevant platforms and determine how the no-font case should behave. Done means title generation works with a default font where supported, with the limitation or fallback made explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.