fnp
/
librarian.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bit longer author field
[librarian.git]
/
src
/
librarian
/
covers
/
utils
/
textbox.py
diff --git
a/src/librarian/covers/utils/textbox.py
b/src/librarian/covers/utils/textbox.py
index
a5097ed
..
e82bee4
100644
(file)
--- a/
src/librarian/covers/utils/textbox.py
+++ b/
src/librarian/covers/utils/textbox.py
@@
-1,3
+1,6
@@
+# This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
+#
import PIL.Image
import PIL.ImageDraw
import PIL.Image
import PIL.ImageDraw
@@
-18,7
+21,8
@@
def split_words(text):
def text_with_tracking(draw, tracking, pos, text, fill=None, font=None):
x, y = pos
for c in text:
def text_with_tracking(draw, tracking, pos, text, fill=None, font=None):
x, y = pos
for c in text:
- width = font.getsize(c)[0]
+ # TODO: adjust for kerning?
+ width = font.getlength(c)
draw.text((x, y), c, fill=fill, font=font)
x += width + tracking
draw.text((x, y), c, fill=fill, font=font)
x += width + tracking
@@
-80,6
+84,8
@@
class TextBox:
def find_grouping(self, groups, ngroups, glue):
best = None
best_var = None
def find_grouping(self, groups, ngroups, glue):
best = None
best_var = None
+ if not groups:
+ return []
mean = sum(g[0] for g in groups) + (len(groups) - ngroups) * glue
if mean > self.width * ngroups:
mean = sum(g[0] for g in groups) + (len(groups) - ngroups) * glue
if mean > self.width * ngroups: