| 177 | } |
| 178 | |
| 179 | int computeJustifyExtra(const int spareSpace, const size_t gapCount) { |
| 180 | if (gapCount < MIN_JUSTIFY_GAPS || spareSpace <= 0) return 0; |
| 181 | // Distribute the spare space evenly across gaps. Do NOT bail out to 0 when the |
| 182 | // per-gap stretch is large: a sparse line (few words on a wide page) legitimately |
| 183 | // needs big gaps to reach the margin. Returning 0 there disables justification for |
| 184 | // that line, leaving it right-aligned (RTL) / left-aligned (LTR) — the mismatched |
| 185 | // alignment bug. Match the un-capped behavior of the old code. |
| 186 | return spareSpace / static_cast<int>(gapCount); |
| 187 | } |
| 188 | |
| 189 | // Removes every soft hyphen in-place so rendered glyphs match measured widths. |
| 190 | void stripSoftHyphensInPlace(std::string& word) { |