- ]
- except DoesNotFit:
- pass
- else:
- authors_written = True
-
- if not authors_written:
- assert authors
- if len(authors) == 2:
- parts = authors
- elif len(authors) > 2:
- parts = [author + ',' for author in authors[:-1]] + [authors[-1]]
- else:
- parts = split_words(authors[0])
-
- try:
- self.textboxes = [
- TextBox(
- self.width,
- self.m.leading * 2,
- parts,
- author_font,
- 2,
- self.m.leading,
- 0,
- 1, 0
- )
- ]
- except:
- self.textboxes = [
- TextBox(
+ except DoesNotFit:
+ translators.pop()
+ translators_shortened = True
+
+ self.textboxes = [
+ author_box,
+ translator_box
+ ]
+
+ elif authors:
+ author_box = None
+ shortened = False
+ while author_box is None:
+ if not shortened and len(authors) == 2:
+ parts = authors
+ elif len(authors) > 2:
+ parts = [author + ',' for author in authors[:-1]] + [authors[-1]]
+ if shortened:
+ parts.append('i in.')
+ else:
+ parts = split_words(authors[0])
+ if shortened:
+ parts.append('i in.')
+
+ try:
+ if len(parts) > 1:
+ # Author in two lines.
+ author_box = TextBox(
+ self.width,
+ self.m.leading * 2,
+ parts,
+ author_font,
+ 2,
+ self.m.leading,
+ 0,
+ 1, 0
+ )
+ else:
+ # author in one line.
+ author_box = TextBox(
+ self.width,
+ self.m.leading * 2,
+ parts,
+ author_font,
+ 1,
+ self.m.leading,
+ 0,
+ 1, 0
+ )
+ except DoesNotFit:
+ authors.pop()
+ shortened = True
+
+ self.textboxes = [author_box]
+
+ elif translators:
+ translators_shortened = False
+ translator_box = None
+ while translator_box is None:
+ translator_str = 'tłum. ' + ', '.join(translators)
+ if translators_shortened:
+ translator_str += ' i in.'
+ try:
+ translator_box = TextBox(