2 from librarian import get_resource
3 from librarian.cover import Metric
4 from ..utils.textbox import TextBox, split_words
5 from .base import Widget
8 class TitleBox(Widget):
13 def __init__(self, cover, width, height, lines, scale=1):
17 self.m = Metric(self, cover.m._scale * scale)
18 super().__init__(cover)
21 title_font = PIL.ImageFont.truetype(
22 get_resource('fonts/SourceSans3VF-Roman.ttf'),
24 layout_engine=PIL.ImageFont.LAYOUT_BASIC
26 title_font.set_variation_by_axes([800])
28 lines = self.lines or (int(self.height * (176/200) / self.m.leading) - 0)
33 split_words(self.cover.title),
40 self.margin_top = self.tb.margin_top
42 def build(self, w, h):
43 return self.tb.as_pil_image(self.cover.color_scheme['text'])