Fix raw bidi text (#3885)

This commit is contained in:
A-Walrus 2024-04-09 14:49:38 +03:00 committed by Laurenz
parent fcd7705fb6
commit 8e025c9cdf
4 changed files with 16 additions and 5 deletions

View File

@ -450,10 +450,10 @@ fn collect<'a>(
let prev = full.len();
let dir = TextElem::dir_in(styles);
if dir != outer_dir {
// Insert "Explicit Directional Isolate".
// Insert "Explicit Directional Embedding".
match dir {
Dir::LTR => full.push('\u{2066}'),
Dir::RTL => full.push('\u{2067}'),
Dir::LTR => full.push('\u{202A}'),
Dir::RTL => full.push('\u{202B}'),
_ => {}
}
}
@ -465,8 +465,8 @@ fn collect<'a>(
}
if dir != outer_dir {
// Insert "Pop Directional Isolate".
full.push('\u{2069}');
// Insert "Pop Directional Formatting".
full.push('\u{202C}');
}
Segment::Text(full.len() - prev)
} else if let Some(elem) = child.to_packed::<HElem>() {

View File

@ -443,6 +443,7 @@ impl ShowSet for Packed<RawElem> {
fn show_set(&self, styles: StyleChain) -> Styles {
let mut out = Styles::new();
out.set(TextElem::set_overhang(false));
out.set(TextElem::set_lang(Lang::ENGLISH));
out.set(TextElem::set_hyphenate(Hyphenate(Smart::Custom(false))));
out.set(TextElem::set_size(TextSize(Em::new(0.8).into())));
out.set(TextElem::set_font(FontList(vec![FontFamily::new("DejaVu Sans Mono")])));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -54,6 +54,16 @@ Lריווח #h(1cm) R
#linebreak()
ב #text("12:00 - 13:00",dir:ltr) בצהריים
---
// Mixing raw
#set text(lang: "he")
לדוג. `if a == b:` זה תנאי
#set raw(lang:"python")
לדוג. `if a == b:` זה תנאי
#show raw: set text(dir:rtl)
לתכנת בעברית `אם א == ב:`
---
// Test setting a vertical direction.
// Ref: false