From 227d85d81f5b002b9be5f95681349c5533d8799e Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 15 May 2026 21:12:43 +0200 Subject: [PATCH] arrange polygons: limit width ratio when merging boxes --- src/svgfill/src/arrange_polygons.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/svgfill/src/arrange_polygons.cpp b/src/svgfill/src/arrange_polygons.cpp index 1f42a4792b..260b22809e 100644 --- a/src/svgfill/src/arrange_polygons.cpp +++ b/src/svgfill/src/arrange_polygons.cpp @@ -1457,6 +1457,13 @@ std::pair merge_score(const MergedBoxRecord& a, const MergedBoxR } bool clusters_can_merge(const BoxCluster& a, const BoxCluster& b, double angle_tol_deg = 5., double axis_overlap_ratio_limit = 0.5) { + auto min_width = a.box.avg_width < b.box.avg_width ? a.box.avg_width : b.box.avg_width; + auto max_width = a.box.avg_width > b.box.avg_width ? a.box.avg_width : b.box.avg_width; + if (min_width > 1.e-9) { + if (max_width / min_width > 5) { + return false; + } + } if (!aabb_overlap(a.box.bbox, b.box.bbox)) { return false; }