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, force=False):
18 self.m = Metric(self, cover.m._scale)
19 super().__init__(cover)
28 self.m = Metric(self, self.m._scale * .99)
29 print('lower to', self.m.font_size)
36 title_font = PIL.ImageFont.truetype(
37 get_resource('fonts/SourceSans3VF-Roman.ttf'),
39 layout_engine=PIL.ImageFont.LAYOUT_BASIC
41 title_font.set_variation_by_axes([800])
43 lines = self.lines or (int(self.height * (176/200) / self.m.leading) - 0)
48 split_words(self.cover.title),
55 self.margin_top = self.tb.margin_top
57 def build(self, w, h):
58 return self.tb.as_pil_image(self.cover.color_scheme['text'])