Execute and render TeX--XeT direction spans in native layouts

This commit is contained in:
gloamxun committed 2026-11-21 16:46:17 +08:00
1 parent a93d1bb902
commit 22e3ba993d
17 files changed
+460 -54

No files matched your search

@@ -3188,6 +3188,10 @@ impl Executor {
Primitive::XeTeXrevision => "XeTeXrevision".into(),
Primitive::XeTeXpdffile => "XeTeXpdffile".into(),
Primitive::XeTeXpicfile => "XeTeXpicfile".into(),
Primitive::BeginL => "beginL".into(),
Primitive::EndL => "endL".into(),
Primitive::BeginR => "beginR".into(),
Primitive::EndR => "endR".into(),
Primitive::XeTeXpdfpagecount => "XeTeXpdfpagecount".into(),
p if p.xetex_font_query_name().is_some() => {
p.xetex_font_query_name().unwrap().into()
@@ -3755,6 +3759,10 @@ impl Executor {
| Primitive::Unhbox
| Primitive::Unhcopy
| Primitive::Valign
| Primitive::BeginL
| Primitive::EndL
| Primitive::BeginR
| Primitive::EndR
)
)
{
@@ -3864,6 +3872,23 @@ impl Executor {
self.request_page();
self.events.push(Event::Paragraph(token.span));
}
BeginL | EndL | BeginR | EndR => {
let boundary = match primitive {
BeginL => DirectionBoundary::BeginL,
EndL => DirectionBoundary::EndL,
BeginR => DirectionBoundary::BeginR,
EndR => DirectionBoundary::EndR,
_ => unreachable!(),
};
if !self.math.is_empty() {
return self.fail("Missing $ inserted");
}
if self.read_parameter(Parameter::TeXXeTstate).width() <= 0 {
return self.fail(format!("Improper \\{}.", boundary.name()));
}
self.finish_text(true)?;
self.paragraph.as_mut().unwrap().nodes.push(TextNode::Direction(boundary));
}
BeginGroup => self.begin_group(GroupKind::SemiSimple, files)?,
EndGroup => self.finish_group(GroupKind::SemiSimple, token.span, files)?,
End | Dump => {