From 77e01151b512cfa413c993b8adc45b5c165f3273 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 28 Apr 2024 17:52:41 +0900 Subject: [PATCH] fix: poor handling of pre-hyphenated words --- src/net/torvald/terrarumsansbitmap/MovableType.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/net/torvald/terrarumsansbitmap/MovableType.kt b/src/net/torvald/terrarumsansbitmap/MovableType.kt index cf6afe0..7c9b081 100644 --- a/src/net/torvald/terrarumsansbitmap/MovableType.kt +++ b/src/net/torvald/terrarumsansbitmap/MovableType.kt @@ -122,6 +122,12 @@ class MovableType( } fun getBadnessH(box: TextCacheObj): Pair { + // don't hyphenate if: + // - the word is too short (5 chars or less) + // - the word is pre-hyphenated (ends with hyphen-null) + if (box.text.size < 8 || box.text.penultimate() == 0x2D) + return 10000f to 10000 + val slug = slug.toMutableList() val (hyphHead, hyphTail) = box.text.hyphenate().toList().map { font.createTextCache(it) }