Clarify variable names in BdfFontFile

Co-authored-by: Yay295 <Yay295@users.noreply.github.com>
This commit is contained in:
Aarni Koskela 2023-02-24 09:58:51 +02:00
parent 879e77a446
commit f52bbf8950

View File

@ -64,16 +64,25 @@ def bdf_char(f):
bitmap.append(s[:-1])
bitmap = b"".join(bitmap)
[x, y, l, d] = [int(p) for p in props["BBX"].split()]
[dx, dy] = [int(p) for p in props["DWIDTH"].split()]
# The word BBX followed by the width in x (BBw), height in y (BBh),
# and x and y displacement (BBox, BBoy) of the lower left corner
# from the origin of the character.
width, height, x_disp, y_disp = [int(p) for p in props["BBX"].split()]
bbox = (dx, dy), (l, -d - y, x + l, -d), (0, 0, x, y)
# The word DWIDTH followed by the width in x and y of the character in device units.
dx, dy = [int(p) for p in props["DWIDTH"].split()]
bbox = (
(dx, dy),
(x_disp, -y_disp - height, width + x_disp, -y_disp),
(0, 0, width, height),
)
try:
im = Image.frombytes("1", (x, y), bitmap, "hex", "1")
im = Image.frombytes("1", (width, height), bitmap, "hex", "1")
except ValueError:
# deal with zero-width characters
im = Image.new("1", (x, y))
im = Image.new("1", (width, height))
return id, int(props["ENCODING"]), bbox, im