mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Prohibit some line break opportunities between LTR-ISOLATE and OBJECT-REPLACEMENT-CHARACTER (#6251)
Co-authored-by: Max <max@mkor.je> Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
parent
26c19a49c8
commit
22a117a091
@ -690,13 +690,34 @@ fn breakpoints(p: &Preparation, mut f: impl FnMut(usize, Breakpoint)) {
|
|||||||
let breakpoint = if point == text.len() {
|
let breakpoint = if point == text.len() {
|
||||||
Breakpoint::Mandatory
|
Breakpoint::Mandatory
|
||||||
} else {
|
} else {
|
||||||
|
const OBJ_REPLACE: char = '\u{FFFC}';
|
||||||
match lb.get(c) {
|
match lb.get(c) {
|
||||||
// Fix for: https://github.com/unicode-org/icu4x/issues/4146
|
|
||||||
LineBreak::Glue | LineBreak::WordJoiner | LineBreak::ZWJ => continue,
|
|
||||||
LineBreak::MandatoryBreak
|
LineBreak::MandatoryBreak
|
||||||
| LineBreak::CarriageReturn
|
| LineBreak::CarriageReturn
|
||||||
| LineBreak::LineFeed
|
| LineBreak::LineFeed
|
||||||
| LineBreak::NextLine => Breakpoint::Mandatory,
|
| LineBreak::NextLine => Breakpoint::Mandatory,
|
||||||
|
|
||||||
|
// https://github.com/typst/typst/issues/5489
|
||||||
|
//
|
||||||
|
// OBJECT-REPLACEMENT-CHARACTERs provide Contingent Break
|
||||||
|
// opportunities before and after by default. This behaviour
|
||||||
|
// is however tailorable, see:
|
||||||
|
// https://www.unicode.org/reports/tr14/#CB
|
||||||
|
// https://www.unicode.org/reports/tr14/#TailorableBreakingRules
|
||||||
|
// https://www.unicode.org/reports/tr14/#LB20
|
||||||
|
//
|
||||||
|
// Don't provide a line breaking opportunity between a LTR-
|
||||||
|
// ISOLATE (or any other Combining Mark) and an OBJECT-
|
||||||
|
// REPLACEMENT-CHARACTER representing an inline item, if the
|
||||||
|
// LTR-ISOLATE could end up as the only character on the
|
||||||
|
// previous line.
|
||||||
|
LineBreak::CombiningMark
|
||||||
|
if text[point..].starts_with(OBJ_REPLACE)
|
||||||
|
&& last + c.len_utf8() == point =>
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
_ => Breakpoint::Normal,
|
_ => Breakpoint::Normal,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
BIN
tests/ref/issue-5489-matrix-stray-linebreak.png
Normal file
BIN
tests/ref/issue-5489-matrix-stray-linebreak.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 644 B |
@ -139,3 +139,11 @@ Some texts feature many longer
|
|||||||
words. Those are often exceedingly
|
words. Those are often exceedingly
|
||||||
challenging to break in a visually
|
challenging to break in a visually
|
||||||
pleasing way.
|
pleasing way.
|
||||||
|
|
||||||
|
--- issue-5489-matrix-stray-linebreak ---
|
||||||
|
#table(
|
||||||
|
columns: (70pt,) * 1,
|
||||||
|
align: horizon + center,
|
||||||
|
stroke: 0.6pt,
|
||||||
|
[$mat(2241/2210,-71/1105;-71/1105,147/1105)$],
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user