mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-03-07 20:01:52 +09:00
fix: bad width calculation on raggedright
This commit is contained in:
@@ -179,7 +179,8 @@ class MovableType(
|
||||
|
||||
if (box.isNotGlue()) {
|
||||
// deal with the hangables
|
||||
val slugWidthForOverflowCalc = if (box.penultimateCharOrNull == null)
|
||||
val slugWidthForOverflowCalc = when (strategy) {
|
||||
TypesettingStrategy.JUSTIFIED -> if (box.penultimateCharOrNull == null)
|
||||
slugWidth
|
||||
else if (hangable.contains(box.penultimateCharOrNull))
|
||||
slugWidth - hangWidth
|
||||
@@ -188,8 +189,16 @@ class MovableType(
|
||||
else
|
||||
slugWidth
|
||||
|
||||
TypesettingStrategy.RAGGED_RIGHT -> slugWidth
|
||||
}
|
||||
|
||||
val truePaperWidth = when (strategy) {
|
||||
TypesettingStrategy.JUSTIFIED -> paperWidth
|
||||
TypesettingStrategy.RAGGED_RIGHT -> paperWidth + 2
|
||||
}
|
||||
|
||||
// if adding the box would cause overflow
|
||||
if (slugWidthForOverflowCalc + box.width > paperWidth) {
|
||||
if (slugWidthForOverflowCalc + box.width > truePaperWidth) {
|
||||
// if adding the box would cause overflow (justified)
|
||||
if (strategy == TypesettingStrategy.JUSTIFIED) {
|
||||
// text overflow occured; set the width to the max value
|
||||
|
||||
Reference in New Issue
Block a user