Skip to content

Commit ac316ce

Browse files
authored
Merge pull request #188 from 1738348785/fix-line-spacing-187
Fix line spacing calculation for multipliers < 1.0 (#187)
2 parents 04373de + c2350a4 commit ac316ce

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

manga_translator/rendering/text_render.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,11 @@ def _normalize_line_spacing(line_spacing: float) -> float:
761761

762762

763763
def resolve_horizontal_line_spacing_multiplier(line_spacing: float) -> float:
764-
value = _normalize_line_spacing(line_spacing)
765-
return 1.0 + (value - 1.0) * 10.0 if value > 1.0 else value
766-
764+
return _normalize_line_spacing(line_spacing)
767765

768766
def calc_horizontal_line_spacing_px(font_size: int, line_spacing: float) -> int:
769-
return int(font_size * 0.01 * resolve_horizontal_line_spacing_multiplier(line_spacing))
767+
value = _normalize_line_spacing(line_spacing)
768+
return int(font_size * (value - 1.0))
770769

771770

772771
def _scale_advance(advance: int, letter_spacing: float) -> int:
@@ -1285,7 +1284,12 @@ def put_text_vertical(
12851284
_ = (h, region_count)
12861285
stroke_ratio = _resolve_stroke_ratio(config, stroke_width)
12871286
bg_size = int(max(font_size * stroke_ratio, 1)) if bg is not None else 0
1288-
spacing_x = int(font_size * 0.2 * (_normalize_line_spacing(line_spacing) or 1.0))
1287+
1288+
val_ls = _normalize_line_spacing(line_spacing)
1289+
if val_ls >= 1.0:
1290+
spacing_x = int(font_size * 0.2 * val_ls)
1291+
else:
1292+
spacing_x = int(font_size * (val_ls - 0.8))
12891293
block_cache = {}
12901294
stage_t0 = perf_counter() if profile_stats is not None else None
12911295
layouts = [

0 commit comments

Comments
 (0)