Skip to content

Commit 445036a

Browse files
committed
fix: apply line break optimization to balloon fill
1 parent b4cbac7 commit 445036a

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

doc/CHANGELOG_v2.2.10.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- 修复了 PaddleOCR-VL 偶尔产生重复符号或字符串幻觉的问题。
2323
- 修复了启用气泡英文排版时,可能因写入只读属性导致任务中断的问题。
2424
- 修复了 AI 渲染默认提示词只清除编号框未清除数字的问题。
25+
-`balloon_fill` 排版模式接入 AI 断句自动扩大文字逻辑,可复用已有 `[BR]` 组合优化以减少不必要断行、提升可用字号。
2526

2627
### 图像兼容性提升
2728
- 修复了输入带透明通道或非标准格式(如 RGBA)的图片在进行 AI 上色、渲染或超分辨率处理(Real-CUGAN等)时可能崩溃或异常的问题。

manga_translator/rendering/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,17 @@ def resize_regions_to_font_size(img: np.ndarray, text_regions: List['TextBlock']
15211521
layout_target_font_size = int(max(target_font_size, layout_min_font_size))
15221522
configured_fixed_font_size = _resolve_configured_fixed_font_size(config)
15231523

1524+
if config.render.optimize_line_breaks and has_br:
1525+
optimized_text, _ = optimize_line_breaks_for_region(
1526+
region,
1527+
config,
1528+
layout_target_font_size,
1529+
float(line_box_width),
1530+
float(line_box_height),
1531+
)
1532+
region.translation = optimized_text
1533+
has_br = bool(re.search(r'(\[BR\]|【BR】|<br>)', region.translation, flags=re.IGNORECASE))
1534+
15241535
if has_br:
15251536
if configured_fixed_font_size <= 0:
15261537
layout_target_font_size = max(

0 commit comments

Comments
 (0)