X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/8495b2ce8e9aebe778db74217b60fb68c0b5f9f2..ae2d55ccb56e2634956ada31b51fbee9879cf837:/src/librarian/covers/marquise.py diff --git a/src/librarian/covers/marquise.py b/src/librarian/covers/marquise.py index 283a2be..d0ce49e 100644 --- a/src/librarian/covers/marquise.py +++ b/src/librarian/covers/marquise.py @@ -17,6 +17,8 @@ class MarquiseCover(Cover): height = 2970 margin = 100 logo_h = 177 + author_width = 1300 + title_box_top = 262 color_schemes = [ @@ -56,7 +58,7 @@ class MarquiseCover(Cover): self.scale_after = final_width / self.width if final_height is not None: - self.height = round(final_height / self.m._scale) + self.height = round(final_height / self.scale_after / self.m._scale) self.square_variant = self.height / self.width < 250 / 210 @@ -97,20 +99,25 @@ class MarquiseCover(Cover): (self.m.marquise_xl, None), ] - for marquise_h, lines in layout_options: - title_box_height = marquise_h - self.m.title_box_top - self.m.margin - try: - title_box = TitleBox( - self, - self.m.width - 2 * self.m.margin, - title_box_height, - lines, - force=lines is None - ) - except DoesNotFit: - continue - else: - break + # Trying all the layout options with decreasing scale. + title_box = None + title_scale = 1 + while title_box is None: + for marquise_h, lines in layout_options: + title_box_height = marquise_h - self.m.title_box_top - self.m.margin + try: + title_box = TitleBox( + self, + self.m.width - 2 * self.m.margin, + title_box_height, + lines, + scale=title_scale + ) + except DoesNotFit: + continue + else: + break + title_scale *= .99 self.marquise_height = marquise_h marquise = Marquise(self, marquise_h) @@ -138,8 +145,8 @@ class MarquiseCover(Cover): marquise.title_box_position[1], ) - AuthorBox(self, self.m.width - self.m.margin).apply( - img, 0, self.m.margin + AuthorBox(self, self.m.author_width).apply( + img, self.m.width - self.m.margin - self.m.author_width, self.m.margin ) WLLogo(self).apply(img, self.m.margin, self.m.margin, None, self.m.logo_h)