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"]),
|
||||
},
|
||||
)
|
||||
)
|
||||
|
|
|
@ -741,10 +741,10 @@
|
|||
id="title"
|
||||
x="964.69553"
|
||||
y="793.00591"
|
||||
style="font-size:74.6667px;line-height:1;font-family:'DIN 1451 Mittelschrift';-inkscape-font-specification:'DIN 1451 Mittelschrift, Normal';text-align:center;writing-mode:lr-tb;direction:ltr;white-space:pre;shape-inside:url(#rect4);display:inline;fill:#fae7e3;stroke:#e7ad52;stroke-width:5.6;stroke-linecap:round;stroke-linejoin:round;stroke:none;width:100%;text-anchor:middle">$title</text>
|
||||
style="font-size:74.6667px;line-height:1;font-family:'DIN 1451 Mittelschrift';-inkscape-font-specification:'DIN 1451 Mittelschrift, Normal';writing-mode:lr-tb;direction:ltr;white-space:pre;shape-inside:url(#rect4);display:inline;fill:#fae7e3;stroke:#e7ad52;stroke-width:5.6;stroke-linecap:round;stroke-linejoin:round;stroke:none;width:100%;text-anchor:middle;">$title</text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
id="persons"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:55px;line-height:1;font-family:'DIN 1451 Mittelschrift';-inkscape-font-specification:'DIN 1451 Mittelschrift, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:center;writing-mode:lr-tb;direction:ltr;white-space:pre;shape-inside:url(#rect5);display:inline;fill:#fae7e3;stroke:none;stroke-width:5.6;stroke-linecap:round;stroke-linejoin:round;width:100%;text-anchor:middle"
|
||||
x="964.69553"
|
||||
y="977.51959">$personnames</text></svg>
|
||||
y="1040.51959">$personnames</text></svg>
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
@ -30,7 +30,7 @@ class SVGTemplate:
|
|||
|
||||
def replacetext(self):
|
||||
for key in self.task.parameters.keys():
|
||||
self.svgstr = self.svgstr.replace(key, xmlescape(str(self.task.parameters[key])))
|
||||
self.svgstr = self.svgstr.replace(key, str(self.task.parameters[key]))
|
||||
|
||||
def transform(self, frame):
|
||||
parser = etree.XMLParser(huge_tree=True)
|
||||
|
|
Loading…
Add table
Reference in a new issue