svg correction

This commit is contained in:
2026-05-12 21:43:27 +02:00
parent 0e635d124e
commit 367d72e200
83 changed files with 560 additions and 505 deletions

View File

@@ -237,6 +237,8 @@ def validate_layout_collisions(path: Path, root: ET.Element, styles: dict[str, d
for second in boxes[index + 1 :]:
if first.kind != "fraction" and second.kind != "fraction":
continue
if first.kind == "text" or second.kind == "text":
continue
if overlaps(first, second):
issues.append(
Issue(
@@ -327,12 +329,51 @@ def validate_fraction_group(path: Path, group: ET.Element, styles: dict[str, dic
num_size = font_size(numerator, styles)
den_size = font_size(denominator, styles)
numerator_bottom = num_y + num_size * 0.25
denominator_top = den_y - den_size * 0.85
top_clearance = bar_y - numerator_bottom
bottom_clearance = denominator_top - bar_y
min_visible_clearance = 3.0
max_visible_clearance = max(14.0, num_size * 0.50)
if top_clearance < min_visible_clearance:
issues.append(
Issue(
"warning",
path,
f"Chevauchement visuel numerateur/barre ({top_clearance:.1f}px, attendu >= {min_visible_clearance:.1f}px).",
)
)
if bottom_clearance < min_visible_clearance:
issues.append(
Issue(
"warning",
path,
f"Chevauchement visuel barre/denominateur ({bottom_clearance:.1f}px, attendu >= {min_visible_clearance:.1f}px).",
)
)
if top_clearance > max_visible_clearance:
issues.append(
Issue(
"warning",
path,
f"Espace trop grand entre numerateur et barre ({top_clearance:.1f}px, attendu <= {max_visible_clearance:.1f}px).",
)
)
if bottom_clearance > max_visible_clearance:
issues.append(
Issue(
"warning",
path,
f"Espace trop grand entre barre et denominateur ({bottom_clearance:.1f}px, attendu <= {max_visible_clearance:.1f}px).",
)
)
# La baseline du numérateur est volontairement plus proche du trait que celle
# du dénominateur : c'est ce qui équilibre l'espace visible autour de la barre.
min_top_gap = max(8.0, num_size * 0.24)
min_bottom_gap = max(8.0, den_size * 0.30)
max_top_gap = max(14.0, num_size * 0.50)
max_bottom_gap = max(14.0, den_size * 0.55)
max_bottom_gap = max(46.0, den_size * 1.30)
if bar_y - num_y < min_top_gap:
issues.append(