Decode XeTeX input files and streams with original byte spans

This commit is contained in:
gloamxun committed 2026-11-21 17:10:46 +08:00
1 parent 22e3ba993d
commit d11ac0cba1
18 files changed
+1040 -109

No files matched your search

@@ -18,6 +18,8 @@ pub use format_image::FormatImage;
mod hooks;
mod hyphenation;
mod input_profile;
mod xe_encoding;
pub use xe_encoding::XeLineFraming;
mod insertions;
mod job;
mod ligature;
@@ -368,6 +370,20 @@ pub trait SourceProvider {
fn read_line(&mut self, _stream: u8) -> Result<Option<Vec<u8>>, String> {
Err("host input streams unavailable".into())
}
/// Return original bytes through one delimiter of the requested framing.
/// Hosts with byte-framed streams can retain the existing UTF-8 path.
fn read_xe_line(&mut self, stream: u8, framing: XeLineFraming) -> Result<Option<Vec<u8>>, String> {
if matches!(framing, XeLineFraming::Utf16Le | XeLineFraming::Utf16Be) {
return Err("host UTF-16 input streams unavailable".into());
}
let bytes = self.read_line(stream)?;
if framing == XeLineFraming::Auto
&& bytes.as_deref().is_some_and(|data| XeLineFraming::detect(data).0.unit_width() == 2)
{
return Err("host UTF-16 input streams unavailable".into());
}
Ok(bytes)
}
fn close_in(&mut self, _stream: u8) -> Result<(), String> {
Err("host input streams unavailable".into())
}
@@ -459,6 +475,7 @@ pub enum Dependency {
value: Option<String>,
},
InputStream(u8),
XeDefaultInputEncoding,
InputPosition(usize),
OutputStream(u8),
ParagraphToken,