mintfig 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. mintfig/__init__.py +162 -0
  2. mintfig/_explain/__init__.py +1 -0
  3. mintfig/_explain/change.py +392 -0
  4. mintfig/_explain/compare.py +1308 -0
  5. mintfig/_explain/compare_grouped.py +472 -0
  6. mintfig/_explain/core.py +2005 -0
  7. mintfig/_explain/distribution.py +1268 -0
  8. mintfig/_explain/flow.py +508 -0
  9. mintfig/_explain/layout.py +2012 -0
  10. mintfig/_explain/matrix.py +623 -0
  11. mintfig/_explain/relate.py +1318 -0
  12. mintfig/_explain/timeline.py +595 -0
  13. mintfig/_explain/trend.py +2557 -0
  14. mintfig/_explain/waterfall.py +459 -0
  15. mintfig/_table.py +691 -0
  16. mintfig/_tabular.py +738 -0
  17. mintfig/annotations.py +1165 -0
  18. mintfig/assets/AGENTS_SNIPPET.md +11 -0
  19. mintfig/assets/SKILL.md +143 -0
  20. mintfig/assets/__init__.py +1 -0
  21. mintfig/assets/references/publication.md +79 -0
  22. mintfig/assets/references/scientific_and_recipes.md +213 -0
  23. mintfig/audit.py +179 -0
  24. mintfig/brief.py +518 -0
  25. mintfig/bundle.py +333 -0
  26. mintfig/cli.py +1300 -0
  27. mintfig/edit.py +347 -0
  28. mintfig/epistemic.py +1083 -0
  29. mintfig/explainer.py +194 -0
  30. mintfig/export.py +247 -0
  31. mintfig/inspect_data.py +583 -0
  32. mintfig/interactive.py +1028 -0
  33. mintfig/palettes.py +233 -0
  34. mintfig/plate.py +784 -0
  35. mintfig/preflight.py +2398 -0
  36. mintfig/proof.py +627 -0
  37. mintfig/runner.py +403 -0
  38. mintfig/skill.py +167 -0
  39. mintfig/specs.py +291 -0
  40. mintfig/style.py +151 -0
  41. mintfig/terminal.py +785 -0
  42. mintfig/themes.py +660 -0
  43. mintfig-0.2.0.dist-info/METADATA +239 -0
  44. mintfig-0.2.0.dist-info/RECORD +47 -0
  45. mintfig-0.2.0.dist-info/WHEEL +4 -0
  46. mintfig-0.2.0.dist-info/entry_points.txt +2 -0
  47. mintfig-0.2.0.dist-info/licenses/LICENSE +21 -0
mintfig/proof.py ADDED
@@ -0,0 +1,627 @@
1
+ """Visual preflight proof-sheet generator with CVD and grayscale verification."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import io
6
+ import textwrap
7
+ from dataclasses import dataclass
8
+ from pathlib import Path
9
+
10
+ import numpy as np
11
+ from matplotlib.backends.backend_agg import FigureCanvasAgg
12
+ from matplotlib.figure import Figure
13
+ from matplotlib.patches import FancyBboxPatch, Rectangle
14
+ from PIL import Image
15
+
16
+ from .palettes import simulate_cvd
17
+ from .preflight import PreflightReport
18
+ from .specs import get_spec
19
+ from .style import resolved_font_name
20
+
21
+ # Clean editorial UI palette for the proof sheet
22
+ _BG_CANVAS = "#F4F6F9"
23
+ _BG_HEADER = "#0F172A"
24
+ _BG_CARD = "#FFFFFF"
25
+ _BORDER_CARD = "#DCE3EC"
26
+ _BORDER_FIG = "#CBD5E1"
27
+ _TEXT_DARK = "#0F172A"
28
+ _TEXT_MUTED = "#475569"
29
+ _TEXT_LIGHT = "#94A3B8"
30
+ _DIM_COLOR = "#334155"
31
+
32
+ _STATUS_STYLES = {
33
+ "pass": {"bg": "#DCFCE7", "fg": "#15803D", "label": "PASS"},
34
+ "warn": {"bg": "#FEF3C7", "fg": "#B45309", "label": "WARN"},
35
+ "fail": {"bg": "#FEE2E2", "fg": "#B91C1C", "label": "FAIL"},
36
+ }
37
+
38
+ # Scorecard row typography (points) and vertical budget per row
39
+ _ROW_TITLE_PT = 8.3
40
+ _ROW_MSG_PT = 6.9
41
+ _ROW_MSG_LINESPACING = 1.18
42
+ _ROW_PAD_TOP_PT = 3.0
43
+ _ROW_TITLE_BAND_PT = 12.5
44
+ _ROW_BADGE_PT = 11.0
45
+ _ROW_GAP_PT = 1.5
46
+ _ROW_PAD_BOTTOM_PT = 3.5
47
+ # Conservative height of one rendered text line relative to its font size
48
+ # (ascent + descent); real sans-serif fonts are ~1.15-1.2.
49
+ _LINE_EXTENT = 1.3
50
+ _ROW_DIVIDER_COLOR = "#EEF2F6"
51
+
52
+
53
+ @dataclass(frozen=True)
54
+ class _ScorecardRow:
55
+ """Vertical geometry (normalized canvas units) for one scorecard row."""
56
+
57
+ top: float
58
+ bottom: float
59
+ title_y: float
60
+ message_top: float
61
+ badge_h: float
62
+ scale: float
63
+ lines: tuple[str, ...]
64
+
65
+
66
+ def _wrap_check_message(message: str) -> tuple[str, ...]:
67
+ """Wrap a check message to at most two lines for the scorecard."""
68
+ wrapped = textwrap.wrap(message, width=54) or [""]
69
+ if len(wrapped) > 2:
70
+ wrapped = [wrapped[0], wrapped[1][:51].rstrip() + "..."]
71
+ return tuple(wrapped)
72
+
73
+
74
+ def _row_required_pt(n_lines: int) -> float:
75
+ """Height in points a row needs at scale 1 for ``n_lines`` of message text."""
76
+ msg_h = _ROW_MSG_PT * (_LINE_EXTENT + _ROW_MSG_LINESPACING * (n_lines - 1))
77
+ return _ROW_PAD_TOP_PT + _ROW_TITLE_BAND_PT + _ROW_GAP_PT + msg_h + _ROW_PAD_BOTTOM_PT
78
+
79
+
80
+ def _layout_scorecard_rows(
81
+ messages: list[tuple[str, ...]],
82
+ *,
83
+ list_top: float,
84
+ list_bot: float,
85
+ canvas_h_in: float,
86
+ ) -> list[_ScorecardRow]:
87
+ """Stack scorecard rows top-down so no message reaches its row divider.
88
+
89
+ Each row gets the height its own message needs (one- and two-line messages
90
+ differ). If the rows do not fit, all row typography is scaled down
91
+ uniformly; any leftover space is shared equally between rows.
92
+ """
93
+ if not messages:
94
+ return []
95
+ pt = 1.0 / (canvas_h_in * 72.0) # one point in normalized canvas units
96
+ required = [_row_required_pt(len(m)) for m in messages]
97
+ avail_pt = (list_top - list_bot) / pt
98
+ scale = min(1.0, avail_pt / sum(required))
99
+ extra_pt = max(0.0, avail_pt - scale * sum(required)) / len(messages)
100
+
101
+ rows: list[_ScorecardRow] = []
102
+ cursor = list_top
103
+ for lines, req in zip(messages, required):
104
+ height = (req * scale + extra_pt) * pt
105
+ band_top = cursor - (_ROW_PAD_TOP_PT * scale + extra_pt / 2.0) * pt
106
+ title_y = band_top - (_ROW_TITLE_BAND_PT * scale / 2.0) * pt
107
+ message_top = band_top - ((_ROW_TITLE_BAND_PT + _ROW_GAP_PT) * scale) * pt
108
+ rows.append(
109
+ _ScorecardRow(
110
+ top=cursor,
111
+ bottom=cursor - height,
112
+ title_y=title_y,
113
+ message_top=message_top,
114
+ badge_h=_ROW_BADGE_PT * scale * pt,
115
+ scale=scale,
116
+ lines=lines,
117
+ )
118
+ )
119
+ cursor -= height
120
+ return rows
121
+
122
+
123
+ def _rasterize_figure_rgb(fig: Figure, dpi: int) -> np.ndarray:
124
+ """Render a Matplotlib figure to an HxWx3 uint8 RGB numpy array cleanly."""
125
+ buf = io.BytesIO()
126
+ fig.savefig(
127
+ buf,
128
+ format="png",
129
+ dpi=dpi,
130
+ facecolor="white",
131
+ bbox_inches=None,
132
+ )
133
+ buf.seek(0)
134
+ with Image.open(buf) as img:
135
+ return np.asarray(img.convert("RGB"), dtype=np.uint8)
136
+
137
+
138
+ def _draw_card(
139
+ ax: object,
140
+ x: float,
141
+ y: float,
142
+ w: float,
143
+ h: float,
144
+ *,
145
+ facecolor: str = _BG_CARD,
146
+ edgecolor: str = _BORDER_CARD,
147
+ radius: float = 0.008,
148
+ lw: float = 0.9,
149
+ ) -> None:
150
+ """Draw a clean rounded white card on a normalized [0, 1] canvas axes."""
151
+ patch = FancyBboxPatch(
152
+ (x, y),
153
+ w,
154
+ h,
155
+ boxstyle=f"round,pad=0,rounding_size={radius}",
156
+ facecolor=facecolor,
157
+ edgecolor=edgecolor,
158
+ linewidth=lw,
159
+ zorder=1,
160
+ )
161
+ ax.add_patch(patch) # type: ignore[attr-defined]
162
+
163
+
164
+ def _fit_box(
165
+ box_x: float,
166
+ box_y: float,
167
+ box_w: float,
168
+ box_h: float,
169
+ img_w: int,
170
+ img_h: int,
171
+ canvas_w_in: float,
172
+ canvas_h_in: float,
173
+ ) -> tuple[float, float, float, float]:
174
+ """Center-fit an image inside a normalized box preserving true aspect ratio."""
175
+ box_w_in = box_w * canvas_w_in
176
+ box_h_in = box_h * canvas_h_in
177
+ img_aspect = img_w / max(img_h, 1)
178
+ box_aspect = box_w_in / max(box_h_in, 1e-6)
179
+
180
+ if img_aspect >= box_aspect:
181
+ draw_w_in = box_w_in
182
+ draw_h_in = draw_w_in / img_aspect
183
+ else:
184
+ draw_h_in = box_h_in
185
+ draw_w_in = draw_h_in * img_aspect
186
+
187
+ draw_w = draw_w_in / canvas_w_in
188
+ draw_h = draw_h_in / canvas_h_in
189
+ draw_x = box_x + (box_w - draw_w) / 2.0
190
+ draw_y = box_y + (box_h - draw_h) / 2.0
191
+ return draw_x, draw_y, draw_w, draw_h
192
+
193
+
194
+ def render_proof_sheet(
195
+ fig: Figure,
196
+ report: PreflightReport,
197
+ out_path: str | Path,
198
+ *,
199
+ dpi: int = 220,
200
+ ) -> Path:
201
+ """Render a publication-grade preflight proof sheet PNG with CVD & print checks."""
202
+ out = Path(out_path)
203
+ out.parent.mkdir(parents=True, exist_ok=True)
204
+
205
+ spec = get_spec(report.journal)
206
+ font_name = resolved_font_name(spec)
207
+
208
+ # Render source figure & compute CVD + grayscale simulations
209
+ rgb = _rasterize_figure_rgb(fig, dpi=dpi)
210
+ rgb_deut = simulate_cvd(rgb, "deuteranopia")
211
+ rgb_prot = simulate_cvd(rgb, "protanopia")
212
+ rgb_gray = simulate_cvd(rgb, "grayscale")
213
+ img_h, img_w = rgb.shape[:2]
214
+
215
+ # Proof sheet dimensions (wide editorial landscape layout)
216
+ canvas_w_in = 14.0
217
+ canvas_h_in = 9.4
218
+
219
+ proof_fig = Figure(figsize=(canvas_w_in, canvas_h_in), dpi=dpi, facecolor=_BG_CANVAS)
220
+ FigureCanvasAgg(proof_fig)
221
+
222
+ # Full-bleed normalized [0, 1] layout layer
223
+ ui_ax = proof_fig.add_axes((0.0, 0.0, 1.0, 1.0))
224
+ ui_ax.set_xlim(0.0, 1.0)
225
+ ui_ax.set_ylim(0.0, 1.0)
226
+ ui_ax.set_axis_off()
227
+ ui_ax.set_facecolor(_BG_CANVAS)
228
+
229
+ # ── 1. HEADER BANNER ────────────────────────────────────────────────────
230
+ header_h = 0.088
231
+ header_y = 1.0 - header_h
232
+ ui_ax.add_patch(
233
+ Rectangle(
234
+ (0.0, header_y),
235
+ 1.0,
236
+ header_h,
237
+ facecolor=_BG_HEADER,
238
+ edgecolor="none",
239
+ zorder=2,
240
+ )
241
+ )
242
+ # Thin accent strip beneath banner
243
+ accent_color = "#16A34A" if report.passed else "#DC2626"
244
+ ui_ax.add_patch(
245
+ Rectangle(
246
+ (0.0, header_y - 0.0035),
247
+ 1.0,
248
+ 0.0035,
249
+ facecolor=accent_color,
250
+ edgecolor="none",
251
+ zorder=3,
252
+ )
253
+ )
254
+
255
+ ui_ax.text(
256
+ 0.025,
257
+ header_y + header_h * 0.62,
258
+ "MINTFIG PREFLIGHT PROOF",
259
+ color="#FFFFFF",
260
+ fontsize=14.5,
261
+ fontweight="bold",
262
+ fontfamily=font_name,
263
+ va="center",
264
+ ha="left",
265
+ zorder=4,
266
+ )
267
+
268
+ n_pass = sum(1 for c in report.checks if c.status == "pass")
269
+ n_warn = len(report.warnings)
270
+ n_fail = len(report.failures)
271
+ meta_parts = [
272
+ spec.display_name,
273
+ f"{report.width_mm:.1f} × {report.height_mm:.1f} mm",
274
+ f"{n_pass}/{len(report.checks)} passed",
275
+ ]
276
+ if n_warn:
277
+ meta_parts.append(f"{n_warn} warn")
278
+ if n_fail:
279
+ meta_parts.append(f"{n_fail} fail")
280
+
281
+ ui_ax.text(
282
+ 0.025,
283
+ header_y + header_h * 0.26,
284
+ " | ".join(meta_parts),
285
+ color="#CBD5E1",
286
+ fontsize=9.2,
287
+ fontfamily=font_name,
288
+ va="center",
289
+ ha="left",
290
+ zorder=4,
291
+ )
292
+
293
+ # Status pill badge on top right
294
+ pill_w = 0.088
295
+ pill_h = 0.044
296
+ pill_x = 1.0 - 0.025 - pill_w
297
+ pill_y = header_y + (header_h - pill_h) / 2.0
298
+ pill_bg = "#16A34A" if report.passed else "#DC2626"
299
+ pill_text = "PASS" if report.passed else "FAIL"
300
+ ui_ax.add_patch(
301
+ FancyBboxPatch(
302
+ (pill_x, pill_y),
303
+ pill_w,
304
+ pill_h,
305
+ boxstyle="round,pad=0,rounding_size=0.010",
306
+ facecolor=pill_bg,
307
+ edgecolor="none",
308
+ zorder=4,
309
+ )
310
+ )
311
+ ui_ax.text(
312
+ pill_x + pill_w / 2.0,
313
+ pill_y + pill_h / 2.0,
314
+ pill_text,
315
+ color="#FFFFFF",
316
+ fontsize=11.5,
317
+ fontweight="bold",
318
+ fontfamily=font_name,
319
+ va="center",
320
+ ha="center",
321
+ zorder=5,
322
+ )
323
+
324
+ # ── 2. MIDDLE ROW: PRIMARY FIGURE + SCORECARD ───────────────────────────
325
+ pad_x = 0.022
326
+ gap_x = 0.018
327
+ mid_top = header_y - 0.022
328
+ mid_bot = 0.325
329
+ mid_h = mid_top - mid_bot
330
+
331
+ left_w = 0.605
332
+ left_x = pad_x
333
+ right_x = left_x + left_w + gap_x
334
+ right_w = 1.0 - pad_x - right_x
335
+
336
+ # Left card: Primary figure preview with mm dimension rules
337
+ _draw_card(ui_ax, left_x, mid_bot, left_w, mid_h)
338
+ ui_ax.text(
339
+ left_x + 0.016,
340
+ mid_top - 0.024,
341
+ "FULL-COLOR PROOF",
342
+ color=_TEXT_DARK,
343
+ fontsize=9.2,
344
+ fontweight="bold",
345
+ fontfamily=font_name,
346
+ va="center",
347
+ ha="left",
348
+ zorder=3,
349
+ )
350
+ ui_ax.text(
351
+ left_x + left_w - 0.016,
352
+ mid_top - 0.024,
353
+ f"Exact physical aspect · {dpi} DPI raster check",
354
+ color=_TEXT_MUTED,
355
+ fontsize=7.8,
356
+ fontfamily=font_name,
357
+ va="center",
358
+ ha="right",
359
+ zorder=3,
360
+ )
361
+
362
+ # Reserve space inside left card for top & right millimeter callout rulers
363
+ fig_box_x = left_x + 0.022
364
+ fig_box_y = mid_bot + 0.020
365
+ fig_box_w = left_w - 0.068
366
+ fig_box_h = mid_h - 0.095
367
+ fx, fy, fw, fh = _fit_box(
368
+ fig_box_x, fig_box_y, fig_box_w, fig_box_h, img_w, img_h, canvas_w_in, canvas_h_in
369
+ )
370
+
371
+ # Render main figure inset axes
372
+ main_ax = proof_fig.add_axes((fx, fy, fw, fh))
373
+ main_ax.imshow(rgb, interpolation="antialiased")
374
+ main_ax.set_xticks([])
375
+ main_ax.set_yticks([])
376
+ for spine in main_ax.spines.values():
377
+ spine.set_edgecolor(_BORDER_FIG)
378
+ spine.set_linewidth(0.8)
379
+
380
+ # Top width millimeter callout rule
381
+ rule_y = fy + fh + 0.015
382
+ tick_h = 0.006
383
+ ui_ax.plot(
384
+ [fx, fx + fw], [rule_y, rule_y], color=_DIM_COLOR, lw=0.85, zorder=4
385
+ )
386
+ ui_ax.plot(
387
+ [fx, fx], [rule_y - tick_h, rule_y + tick_h], color=_DIM_COLOR, lw=0.85, zorder=4
388
+ )
389
+ ui_ax.plot(
390
+ [fx + fw, fx + fw],
391
+ [rule_y - tick_h, rule_y + tick_h],
392
+ color=_DIM_COLOR,
393
+ lw=0.85,
394
+ zorder=4,
395
+ )
396
+ ui_ax.text(
397
+ fx + fw / 2.0,
398
+ rule_y + 0.003,
399
+ f" {report.width_mm:.1f} mm ",
400
+ color=_DIM_COLOR,
401
+ fontsize=8.2,
402
+ fontweight="bold",
403
+ fontfamily=font_name,
404
+ va="bottom",
405
+ ha="center",
406
+ bbox={"facecolor": _BG_CARD, "edgecolor": "none", "pad": 1.0},
407
+ zorder=5,
408
+ )
409
+
410
+ # Right height millimeter callout rule
411
+ rule_x = fx + fw + 0.012
412
+ tick_w = 0.0045
413
+ ui_ax.plot(
414
+ [rule_x, rule_x], [fy, fy + fh], color=_DIM_COLOR, lw=0.85, zorder=4
415
+ )
416
+ ui_ax.plot(
417
+ [rule_x - tick_w, rule_x + tick_w], [fy, fy], color=_DIM_COLOR, lw=0.85, zorder=4
418
+ )
419
+ ui_ax.plot(
420
+ [rule_x - tick_w, rule_x + tick_w],
421
+ [fy + fh, fy + fh],
422
+ color=_DIM_COLOR,
423
+ lw=0.85,
424
+ zorder=4,
425
+ )
426
+ ui_ax.text(
427
+ rule_x + 0.006,
428
+ fy + fh / 2.0,
429
+ f"{report.height_mm:.1f} mm",
430
+ color=_DIM_COLOR,
431
+ fontsize=8.2,
432
+ fontweight="bold",
433
+ fontfamily=font_name,
434
+ va="center",
435
+ ha="left",
436
+ rotation=90,
437
+ zorder=5,
438
+ )
439
+
440
+ # Right card: Compliance Scorecard
441
+ _draw_card(ui_ax, right_x, mid_bot, right_w, mid_h)
442
+ ui_ax.text(
443
+ right_x + 0.016,
444
+ mid_top - 0.024,
445
+ "COMPLIANCE SCORECARD",
446
+ color=_TEXT_DARK,
447
+ fontsize=9.2,
448
+ fontweight="bold",
449
+ fontfamily=font_name,
450
+ va="center",
451
+ ha="left",
452
+ zorder=3,
453
+ )
454
+ ui_ax.plot(
455
+ [right_x + 0.014, right_x + right_w - 0.014],
456
+ [mid_top - 0.044, mid_top - 0.044],
457
+ color=_BORDER_CARD,
458
+ lw=0.75,
459
+ zorder=3,
460
+ )
461
+
462
+ checks = report.checks
463
+ list_top = mid_top - 0.056
464
+ list_bot = mid_bot + 0.052
465
+ rows = _layout_scorecard_rows(
466
+ [_wrap_check_message(c.message) for c in checks],
467
+ list_top=list_top,
468
+ list_bot=list_bot,
469
+ canvas_h_in=canvas_h_in,
470
+ )
471
+
472
+ badge_w = 0.044
473
+ text_x = right_x + 0.016 + badge_w + 0.010
474
+
475
+ for idx, (check, row) in enumerate(zip(checks, rows)):
476
+ style = _STATUS_STYLES[check.status]
477
+
478
+ # Pill badge
479
+ ui_ax.add_patch(
480
+ FancyBboxPatch(
481
+ (right_x + 0.015, row.title_y - row.badge_h / 2.0),
482
+ badge_w,
483
+ row.badge_h,
484
+ boxstyle="round,pad=0,rounding_size=0.004",
485
+ facecolor=style["bg"],
486
+ edgecolor="none",
487
+ zorder=3,
488
+ )
489
+ )
490
+ ui_ax.text(
491
+ right_x + 0.015 + badge_w / 2.0,
492
+ row.title_y,
493
+ style["label"],
494
+ color=style["fg"],
495
+ fontsize=7.2 * row.scale,
496
+ fontweight="bold",
497
+ fontfamily=font_name,
498
+ va="center",
499
+ ha="center",
500
+ zorder=4,
501
+ )
502
+
503
+ # Rule name
504
+ rule_label = check.rule.replace("_", " ")
505
+ ui_ax.text(
506
+ text_x,
507
+ row.title_y,
508
+ rule_label,
509
+ color=_TEXT_DARK,
510
+ fontsize=_ROW_TITLE_PT * row.scale,
511
+ fontweight="bold",
512
+ fontfamily=font_name,
513
+ va="center",
514
+ ha="left",
515
+ zorder=4,
516
+ )
517
+
518
+ # Concise wrapped detail (at most 2 lines), sized so it ends above the divider
519
+ ui_ax.text(
520
+ text_x,
521
+ row.message_top,
522
+ "\n".join(row.lines),
523
+ color=_TEXT_MUTED,
524
+ fontsize=_ROW_MSG_PT * row.scale,
525
+ fontfamily=font_name,
526
+ va="top",
527
+ ha="left",
528
+ linespacing=_ROW_MSG_LINESPACING,
529
+ zorder=4,
530
+ )
531
+
532
+ # Subtle row divider at the bottom edge of the row's reserved band
533
+ if idx < len(rows) - 1:
534
+ ui_ax.plot(
535
+ [right_x + 0.014, right_x + right_w - 0.014],
536
+ [row.bottom, row.bottom],
537
+ color=_ROW_DIVIDER_COLOR,
538
+ lw=0.6,
539
+ zorder=2,
540
+ )
541
+
542
+ # Scorecard footer spec line
543
+ ui_ax.plot(
544
+ [right_x + 0.014, right_x + right_w - 0.014],
545
+ [mid_bot + 0.040, mid_bot + 0.040],
546
+ color=_BORDER_CARD,
547
+ lw=0.75,
548
+ zorder=3,
549
+ )
550
+ spec_footer = (
551
+ f"Spec: {spec.font_min_pt:.0f}–{spec.font_max_pt:.0f} pt sans-serif · "
552
+ f"min stroke {spec.min_linewidth_pt:.2f} pt · "
553
+ f"max H {spec.max_height_mm:.0f} mm"
554
+ )
555
+ ui_ax.text(
556
+ right_x + right_w / 2.0,
557
+ mid_bot + 0.020,
558
+ spec_footer,
559
+ color=_TEXT_MUTED,
560
+ fontsize=7.3,
561
+ fontfamily=font_name,
562
+ va="center",
563
+ ha="center",
564
+ zorder=4,
565
+ )
566
+
567
+ # ── 3. BOTTOM 3-COLUMN ACCESSIBILITY & PRINT STRIP ─────────────────────
568
+ bot_top = mid_bot - 0.020
569
+ bot_y = 0.022
570
+ bot_h = bot_top - bot_y
571
+ col_gap = 0.016
572
+ col_w = (1.0 - 2.0 * pad_x - 2.0 * col_gap) / 3.0
573
+
574
+ cvd_panels = [
575
+ ("DEUTERANOPIA", "Red-green CVD (~6% male)", rgb_deut),
576
+ ("PROTANOPIA", "Red-blind CVD (~2% male)", rgb_prot),
577
+ ("GRAYSCALE PRINT", "Rec. 709 luminance check", rgb_gray),
578
+ ]
579
+
580
+ for idx, (title, subtitle, sim_rgb) in enumerate(cvd_panels):
581
+ cx = pad_x + idx * (col_w + col_gap)
582
+ _draw_card(ui_ax, cx, bot_y, col_w, bot_h)
583
+
584
+ ui_ax.text(
585
+ cx + 0.014,
586
+ bot_top - 0.021,
587
+ title,
588
+ color=_TEXT_DARK,
589
+ fontsize=8.4,
590
+ fontweight="bold",
591
+ fontfamily=font_name,
592
+ va="center",
593
+ ha="left",
594
+ zorder=3,
595
+ )
596
+ ui_ax.text(
597
+ cx + col_w - 0.014,
598
+ bot_top - 0.021,
599
+ subtitle,
600
+ color=_TEXT_LIGHT,
601
+ fontsize=7.1,
602
+ fontfamily=font_name,
603
+ va="center",
604
+ ha="right",
605
+ zorder=3,
606
+ )
607
+
608
+ sx, sy, sw, sh = _fit_box(
609
+ cx + 0.014,
610
+ bot_y + 0.014,
611
+ col_w - 0.028,
612
+ bot_h - 0.052,
613
+ img_w,
614
+ img_h,
615
+ canvas_w_in,
616
+ canvas_h_in,
617
+ )
618
+ sub_ax = proof_fig.add_axes((sx, sy, sw, sh))
619
+ sub_ax.imshow(sim_rgb, interpolation="antialiased")
620
+ sub_ax.set_xticks([])
621
+ sub_ax.set_yticks([])
622
+ for spine in sub_ax.spines.values():
623
+ spine.set_edgecolor(_BORDER_FIG)
624
+ spine.set_linewidth(0.75)
625
+
626
+ proof_fig.savefig(str(out), format="png", dpi=dpi, facecolor=_BG_CANVAS)
627
+ return out