mirror of
https://github.com/typst/typst
synced 2025-05-18 11:05:28 +08:00
Fix BiDi bug with mixed explicit dir in paragraph (#3532)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
parent
879bd1a1ce
commit
b005dc37e5
@ -432,6 +432,8 @@ fn collect<'a>(
|
|||||||
segments.push((Segment::Spacing((-hang).into()), *styles));
|
segments.push((Segment::Spacing((-hang).into()), *styles));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let outer_dir = TextElem::dir_in(*styles);
|
||||||
|
|
||||||
while let Some(mut child) = iter.next() {
|
while let Some(mut child) = iter.next() {
|
||||||
let outer = styles;
|
let outer = styles;
|
||||||
let mut styles = *styles;
|
let mut styles = *styles;
|
||||||
@ -445,11 +447,26 @@ fn collect<'a>(
|
|||||||
Segment::Text(1)
|
Segment::Text(1)
|
||||||
} else if let Some(elem) = child.to_packed::<TextElem>() {
|
} else if let Some(elem) = child.to_packed::<TextElem>() {
|
||||||
let prev = full.len();
|
let prev = full.len();
|
||||||
|
let dir = TextElem::dir_in(styles);
|
||||||
|
if dir != outer_dir {
|
||||||
|
// Insert "Explicit Directional Isolate".
|
||||||
|
match dir {
|
||||||
|
Dir::LTR => full.push('\u{2066}'),
|
||||||
|
Dir::RTL => full.push('\u{2067}'),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(case) = TextElem::case_in(styles) {
|
if let Some(case) = TextElem::case_in(styles) {
|
||||||
full.push_str(&case.apply(elem.text()));
|
full.push_str(&case.apply(elem.text()));
|
||||||
} else {
|
} else {
|
||||||
full.push_str(elem.text());
|
full.push_str(elem.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dir != outer_dir {
|
||||||
|
// Insert "Pop Directional Isolate".
|
||||||
|
full.push('\u{2069}');
|
||||||
|
}
|
||||||
Segment::Text(full.len() - prev)
|
Segment::Text(full.len() - prev)
|
||||||
} else if let Some(elem) = child.to_packed::<HElem>() {
|
} else if let Some(elem) = child.to_packed::<HElem>() {
|
||||||
if elem.amount().is_zero() {
|
if elem.amount().is_zero() {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@ -47,6 +47,13 @@ Lריווח #h(1cm) R
|
|||||||
// Test whether L1 whitespace resetting destroys stuff.
|
// Test whether L1 whitespace resetting destroys stuff.
|
||||||
الغالب #h(70pt) ن#" "ة
|
الغالب #h(70pt) ن#" "ة
|
||||||
|
|
||||||
|
---
|
||||||
|
// Test explicit dir
|
||||||
|
#set text(dir: rtl)
|
||||||
|
#text("8:00 - 9:00",dir:ltr) בבוקר
|
||||||
|
#linebreak()
|
||||||
|
ב #text("12:00 - 13:00",dir:ltr) בצהריים
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test setting a vertical direction.
|
// Test setting a vertical direction.
|
||||||
// Ref: false
|
// Ref: false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user