• Direction graph: gap 2, char gap 0.6, alignment 1.5, font ratio 1.5, aspect tolerance 1; connected-component majority assigns horizontal/vertical.
• Merge graph: aspect tolerance 1.3, font ratio 2, char gaps 1/3; rotated candidates require angle ≤15° and relative font delta ≤0.25.
• For 3+ lines, build complete weighted graph → Kruskal MST → keep if max edge ≤ mean + 2σ or ≤1.5× font; else cut largest edge and recurse.
• Assemble blocks top-to-bottom or right-to-left; CJK joins without spaces; minimum line font wins; angle <3° snaps to zero; fit minimum-area rectangle.
Bubble Geometry & Three Typesetting Strategies
• Geometry: heuristic pixel carriers or YOLO11n segmentation; associate OCR boxes, resolve shared chambers, suppress small fragments, and measure candidates with the selected font. Curved shared chambers use reflex-neck decomposition then contour-clipped anchor partitioning; rejected groups can roll back.
• Contour DP (contour): fixed layouts with supplied contours take priority; rounded geometry can also select this route. Polygon scanline profiles, DP line selection, common horizontal center, and coarse-to-refined font probes produce positionedLines. Local font bounds are Kites policy, not proof of donor equivalence.
• Simple Rect (simple): backend runs the contour solver on a rectangle. Studio simple edits instead use greedy rectangular wrapping at the current font size; do not assume identical reflow behavior.
• Auto Balloon (balloon): free-box route without accepted fixed bubble geometry, using source-aware expansion and line fitting. Legacy ellipse values normalize to contour on restore; a generated ellipse is geometry fallback, not a fourth strategy.
• Mode labels alone do not prove the solver used: fixed contours can override simple, and rejected geometry can leave saved carrier metadata differing from the baked route. Canvas measurement, painting, and Studio lifecycle have no established end-to-end visual parity guarantee.
Parallel Compute + Output Contract
• Translation: Google GTX chunks ≤1800 chars with ⟦index⟧ delimiters; LLM batches 15 tagged segments and writes results back by tag index.
• Inpaint: raw surviving line polygons only; Simple uses luminance ≥180 RGB median, Telea-like FMM radius 3, neural tiers (LaMa/AOT-GAN) use 64px dynamic patch bucketing with UNCLIP 1.8 stroke expansion.
• Scheduling: network translation overlaps vision work; local GPU translation is serialized with vision inference. Composition waits for translated text and clean plate; raw DBNet masks remain rejected to protect non-text bubble art.
• Persist clean image plus editable fitted lines in Dexie; return a separate baked PNG data URL for immediate DOM replacement.