Add font preview page

This commit is contained in:
jpirnay
2026-05-04 14:27:22 +02:00
parent 2eac3f3e37
commit 830cde615a
25 changed files with 73 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

+29
View File
@@ -0,0 +1,29 @@
# SD Font Preview
This page lists the available SD font families under `assets/sd-fonts` and embeds rendered preview images for each family.
| Font Family | Preview |
|---|---|
| Alegreya | ![Preview of Alegreya](images/sd-font-previews/Alegreya.png) |
| Arimo | ![Preview of Arimo](images/sd-font-previews/Arimo.png) |
| AtkinsonHyperlegibleNext | ![Preview of AtkinsonHyperlegibleNext](images/sd-font-previews/AtkinsonHyperlegibleNext.png) |
| Bitter | ![Preview of Bitter](images/sd-font-previews/Bitter.png) |
| Gelasio | ![Preview of Gelasio](images/sd-font-previews/Gelasio.png) |
| GentiumBookPlus | ![Preview of GentiumBookPlus](images/sd-font-previews/GentiumBookPlus.png) |
| IBMPlexMono | ![Preview of IBMPlexMono](images/sd-font-previews/IBMPlexMono.png) |
| IBMPlexSans | ![Preview of IBMPlexSans](images/sd-font-previews/IBMPlexSans.png) |
| IBMPlexSerif | ![Preview of IBMPlexSerif](images/sd-font-previews/IBMPlexSerif.png) |
| Inter | ![Preview of Inter](images/sd-font-previews/Inter.png) |
| LexicaUltralegible | ![Preview of LexicaUltralegible](images/sd-font-previews/LexicaUltralegible.png) |
| Literata | ![Preview of Literata](images/sd-font-previews/Literata.png) |
| Lora | ![Preview of Lora](images/sd-font-previews/Lora.png) |
| Merriweather | ![Preview of Merriweather](images/sd-font-previews/Merriweather.png) |
| NotoSansExtended | ![Preview of NotoSansExtended](images/sd-font-previews/NotoSansExtended.png) |
| NotoSerifExtended | ![Preview of NotoSerifExtended](images/sd-font-previews/NotoSerifExtended.png) |
| OpenDyslexic | ![Preview of OpenDyslexic](images/sd-font-previews/OpenDyslexic.png) |
| Readerly | ![Preview of Readerly](images/sd-font-previews/Readerly.png) |
| SourceCodePro | ![Preview of SourceCodePro](images/sd-font-previews/SourceCodePro.png) |
| SourceSans3 | ![Preview of SourceSans3](images/sd-font-previews/SourceSans3.png) |
| SourceSerif4 | ![Preview of SourceSerif4](images/sd-font-previews/SourceSerif4.png) |
| Spectral | ![Preview of Spectral](images/sd-font-previews/Spectral.png) |
| Vollkorn | ![Preview of Vollkorn](images/sd-font-previews/Vollkorn.png) |
+44
View File
@@ -0,0 +1,44 @@
"""Generate a markdown font preview page and images for SD font families."""
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
ROOT = Path(__file__).resolve().parent.parent / 'assets' / 'sd-fonts'
OUTPUT_DIR = Path(__file__).resolve().parent.parent / 'docs' / 'images' / 'sd-font-previews'
MD_PATH = Path(__file__).resolve().parent.parent / 'docs' / 'sd-fonts-preview.md'
SAMPLE_TEXT = 'Everyone has the right to freedom of thought...'
DEFAULT_FONT_SIZE = 28
IMAGE_SIZE = (1080, 220)
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
try:
font = ImageFont.truetype('arial.ttf', DEFAULT_FONT_SIZE)
except Exception:
font = ImageFont.load_default()
families = [p.name for p in sorted(ROOT.iterdir()) if p.is_dir()]
lines = [
'# SD Font Preview',
'',
'This page lists the available SD font families under `assets/sd-fonts` and includes preview images showing the family name plus the sample phrase.',
'',
'| Font Family | Preview |',
'|---|---|',
]
for family in families:
text = f'{family} - {SAMPLE_TEXT}'
image = Image.new('RGB', IMAGE_SIZE, color=(255, 255, 255))
draw = ImageDraw.Draw(image)
text_width, text_height = draw.textsize(text, font=font)
x = 20
y = (IMAGE_SIZE[1] - text_height) // 2
draw.text((x, y), text, fill='black', font=font)
output_file = OUTPUT_DIR / f'{family}.png'
image.save(output_file)
lines.append(f'| {family} | ![Preview of {family}](images/sd-font-previews/{family}.png) |')
with MD_PATH.open('w', encoding='utf-8') as md_file:
md_file.write('\n'.join(lines) + '\n')
print(f'Generated {len(families)} preview images and markdown at {MD_PATH}')