Skip to content

Commit

Permalink
Generate metrics sample
Browse files Browse the repository at this point in the history
  • Loading branch information
rbanffy committed Nov 8, 2023
1 parent fc45897 commit 000558f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion generate_sample_image.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env python3
"""
Generate a sample rendering of the base font.
Generate sample renderings of the 3270 font
The sample rendering is an animated GIF with all the different
formats and styles of the font shown in sequence.
The metrics rendering shows the font compared to the original,
with the original at the default 14 points (set in x3270) and
the SemiCondensed TrueType font at size 17.
"""

from PIL import Image, ImageColor, ImageDraw, ImageFont
Expand All @@ -13,6 +20,10 @@
LINE_COLOR = ImageColor.getrgb("#88f")
TEXT_COLOR = ImageColor.getrgb("black")

X3270_SAMPLE_TEXT = (
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
)

FONT_FILES = (
"./build/3270-Regular.ttf",
"./build/3270-Regular.otf",
Expand Down Expand Up @@ -67,7 +78,16 @@ def draw_readability_test(font_file, factor):
return img


def metrics_sample(size):
img = Image.open("x3270_sample.png")
font = ImageFont.truetype("build/3270SemiCondensed-Regular.ttf", size=17)
draw = ImageDraw.Draw(img)
draw.text((5, 15), X3270_SAMPLE_TEXT, fill="black", font=font)
return img


if __name__ == "__main__":
# Generate samples
samples = []
for font in FONT_FILES:
sample = draw_sample(font)
Expand All @@ -83,3 +103,6 @@ def draw_readability_test(font_file, factor):
duration=1000,
loop=0,
)

# Generate metrics sample
metrics_sample(17).save("build/3270_metrics.png")
Binary file added x3270_sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 000558f

Please sign in to comment.