fix: bad hyphenation on Hangul because the code was always assuming left part of the 'hyphenated' text always ends with a hyphen

This commit is contained in:
minjaesong
2024-05-14 00:34:53 +09:00
parent a58abd813f
commit 385dc8bdff

View File

@@ -212,9 +212,10 @@ class MovableType(
// add the hyphHead to the slug copy // add the hyphHead to the slug copy
val nextPosX = (slug.lastOrNull()?.getEndPos() ?: 0) val nextPosX = (slug.lastOrNull()?.getEndPos() ?: 0)
slug.add(Block(nextPosX, hyphHead)) // now ends with 'word-' slug.add(Block(nextPosX, hyphHead)) // now ends with 'word-' (but not in Hangul)
val hasHyphen = hyphHead.penultimateCharOrNull == 0x2D
val slugWidth1 = slug.last().getEndPos() - exdentSize - hyphenWidth val slugWidth1 = slug.last().getEndPos() - exdentSize - hyphenWidth * hasHyphen.toInt()
val difference = paperWidth - slugWidth1 val difference = paperWidth - slugWidth1
val badness = penaliseHyphenation(difference.absoluteValue, availableGlues.toDouble()) val badness = penaliseHyphenation(difference.absoluteValue, availableGlues.toDouble())
@@ -1137,7 +1138,8 @@ class MovableType(
return out return out
} }
inline fun Boolean.toInt(shift: Int = 0) = if (this) 1.shl(shift) else 0
} // end of companion object } // end of companion object
} }