File size: 858 Bytes
58e6885
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""临时调研脚本: 看 PIL 在 font_metrics 里对每个 font_family 实际用什么字体文件 + 测得宽度。"""
import sys
sys.path.insert(0, '.')
from modules.title_styler.font_metrics import get_font_metrics

fm = get_font_metrics()
SAMPLE = "Americas Largest Tech Companies"
CASES = [
    ("Georgia", "bold"),
    ("Georgia", "normal"),
    ("Times New Roman", "bold"),
    ("Arial", "bold"),
    ("Comic Sans MS", "bold"),
    ("Impact", "normal"),
    ("Helvetica", "bold"),
    ("Montserrat", "bold"),
    ("Roboto", "bold"),
    ("Oswald", "bold"),
    ("Open Sans", "bold"),
]
for family, weight in CASES:
    font = fm.get_font(family, 48, weight)
    actual = font.path.split("/")[-1] if font else "NONE"
    w, _ = fm.measure_text(SAMPLE, family, 48, weight)
    print(f"{family:18s} {weight:6s}  PIL_uses={actual:35s}  W_pil={w:6.1f}")