more intro unfucking
This commit is contained in:
parent
2363e305a8
commit
976927f737
3 changed files with 41 additions and 5 deletions
|
@ -3,6 +3,8 @@
|
|||
from renderlib import *
|
||||
from schedulelib import *
|
||||
from easing import *
|
||||
from xml.sax.saxutils import escape as xmlescape
|
||||
from PIL import ImageFont
|
||||
|
||||
# URL to Schedule-XML
|
||||
scheduleUrl = "https://cfp.ctbk.de/fsck-2025/schedule/export/schedule.xml"
|
||||
|
@ -161,7 +163,37 @@ def debug():
|
|||
# )
|
||||
|
||||
|
||||
def fit_text(string: str, max_width: int, font: ImageFont) -> list[str]:
|
||||
"""Break text into array of strings which fit certain a width (in pixels) for the specified font."""
|
||||
|
||||
split_line = [x.strip() for x in string.split()]
|
||||
lines = []
|
||||
w = 0
|
||||
line = []
|
||||
for word in split_line:
|
||||
new_line = line + [word.rstrip(":")]
|
||||
w = font.getlength(" ".join(new_line))
|
||||
if w > max_width:
|
||||
lines.append(" ".join(line))
|
||||
line = []
|
||||
|
||||
line.append(word.rstrip(":"))
|
||||
|
||||
if word.endswith(":"):
|
||||
lines.append(" ".join(line))
|
||||
line = []
|
||||
|
||||
if line:
|
||||
lines.append(" ".join(line))
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
def tasks(queue, args, idlist, skiplist):
|
||||
font = ImageFont.truetype(
|
||||
"../DIN1451Mittelschrift.ttf", size=74.6667, encoding="unic"
|
||||
)
|
||||
|
||||
# iterate over all events extracted from the schedule xml-export
|
||||
for event in events(scheduleUrl):
|
||||
# if event["room"] not in ("Medientheater", "Vortragssaal", "Blauer Salon"):
|
||||
|
@ -179,14 +211,18 @@ def tasks(queue, args, idlist, skiplist):
|
|||
continue
|
||||
|
||||
# generate a task description and put it into the queue
|
||||
title_segments = fit_text(xmlescape(event["title"]), 1920, font)
|
||||
title = "".join(
|
||||
f'<tspan dy="1.1em" x="964.69553">{el}</tspan>' for el in title_segments
|
||||
)
|
||||
queue.put(
|
||||
Rendertask(
|
||||
infile=["intro.svg", "intro.flac"],
|
||||
outfile=str(event["id"]) + ".ts",
|
||||
sequence=introFrames,
|
||||
parameters={
|
||||
"$title": event["title"],
|
||||
"$personnames": event["personnames"],
|
||||
"$title": title,
|
||||
"$personnames": xmlescape(event["personnames"]),
|
||||
},
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue