"""临时调研脚本: 看 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}")