Select a native XeTeX compatibility profile and wide spacing codes

This commit is contained in:
gloamxun committed 2026-11-21 12:17:53 +08:00
1 parent 651fab42f1
commit 752af43f32
19 files changed
+471 -115

No files matched your search

@@ -1,4 +1,4 @@
//! Input decoding is a job profile, independent of e-TeX primitive availability.
//! Job input decoding and the explicit XeTeX compatibility profile.
//! Both paths retain original byte offsets; the byte path never recodes a file.
#[derive(
Clone, Copy, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize,
@@ -7,18 +7,22 @@ pub enum InputProfile {
TeX8Bit,
#[default]
UnicodeScalar,
/// UTF-8 input, XeTeX primitives and XDV-device semantics.
XeTeX,
}
impl InputProfile {
pub(super) fn characters(self, data: &[u8]) -> Result<Characters<'_>, std::str::Utf8Error> {
Ok(match self {
Self::TeX8Bit => Characters::Bytes(data.iter().enumerate()),
Self::UnicodeScalar => Characters::Unicode(std::str::from_utf8(data)?.char_indices()),
Self::UnicodeScalar | Self::XeTeX => {
Characters::Unicode(std::str::from_utf8(data)?.char_indices())
}
})
}
pub(super) fn width(self, c: char) -> usize {
match self {
Self::TeX8Bit => 1,
Self::UnicodeScalar => c.len_utf8(),
Self::UnicodeScalar | Self::XeTeX => c.len_utf8(),
}
}
}