mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-06-11 00:14:05 +09:00
fix: bad width calculation on raggedright
This commit is contained in:
@@ -179,17 +179,26 @@ class MovableType(
|
|||||||
|
|
||||||
if (box.isNotGlue()) {
|
if (box.isNotGlue()) {
|
||||||
// deal with the hangables
|
// deal with the hangables
|
||||||
val slugWidthForOverflowCalc = if (box.penultimateCharOrNull == null)
|
val slugWidthForOverflowCalc = when (strategy) {
|
||||||
slugWidth
|
TypesettingStrategy.JUSTIFIED -> if (box.penultimateCharOrNull == null)
|
||||||
else if (hangable.contains(box.penultimateCharOrNull))
|
slugWidth
|
||||||
slugWidth - hangWidth
|
else if (hangable.contains(box.penultimateCharOrNull))
|
||||||
else if (hangableFW.contains(box.penultimateCharOrNull))
|
slugWidth - hangWidth
|
||||||
slugWidth - hangWidthFW
|
else if (hangableFW.contains(box.penultimateCharOrNull))
|
||||||
else
|
slugWidth - hangWidthFW
|
||||||
slugWidth
|
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 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 adding the box would cause overflow (justified)
|
||||||
if (strategy == TypesettingStrategy.JUSTIFIED) {
|
if (strategy == TypesettingStrategy.JUSTIFIED) {
|
||||||
// text overflow occured; set the width to the max value
|
// text overflow occured; set the width to the max value
|
||||||
|
|||||||
Reference in New Issue
Block a user