Execute XeTeX character classes and inter-character token lists
This commit is contained in:
1 parent
d11ac0cba1
commit
5df90f113c
15 files changed
+462
-14
No files matched your search
@@ -311,3 +311,88 @@ fn xetex_default_encoding_survives_dump_and_current_line_is_already_decoded() {
|
||||
};
|
||||
assert_eq!(&data[token.span.start..token.span.end], [0xd8, 0x3d, 0xde, 0x00]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xetex_inter_character_lists_follow_text_runs_and_shared_grouping() {
|
||||
use sha2::{Digest, Sha256};
|
||||
use texrra_tex_core::resources::{LoadedResource, ResourceKind, ResourceVersion};
|
||||
|
||||
struct TfmSource;
|
||||
impl SourceProvider for TfmSource {
|
||||
fn read(&mut self, name: &str, from: &str) -> Result<SourceFile, String> {
|
||||
NoFiles.read(name, from)
|
||||
}
|
||||
|
||||
fn resource(
|
||||
&mut self,
|
||||
kind: ResourceKind,
|
||||
name: &str,
|
||||
_: &str,
|
||||
) -> Result<LoadedResource, String> {
|
||||
assert_eq!((kind, name), (ResourceKind::Tfm, "cmr10.tfm"));
|
||||
let data = include_bytes!("../assets/cmr10.tfm").to_vec();
|
||||
let version = ResourceVersion {
|
||||
path: name.into(),
|
||||
sha256: format!("{:x}", Sha256::digest(&data)),
|
||||
bytes: data.len() as u64,
|
||||
};
|
||||
Ok(LoadedResource { version, data })
|
||||
}
|
||||
}
|
||||
|
||||
let seed = r"\catcode123=1 \catcode125=2
|
||||
\XeTeXcharclass65=1 \XeTeXcharclass66=2 \XeTeXcharclass67=4096
|
||||
\XeTeXinterchartoks1 2={\kern2pt\relax}
|
||||
\dump";
|
||||
let state = State::initex()
|
||||
.with_etex()
|
||||
.with_input_profile(InputProfile::XeTeX);
|
||||
let image = FormatImage::from_dump(run(state.clone(), seed), Vec::new(), Vec::new())
|
||||
.unwrap()
|
||||
.encode()
|
||||
.unwrap();
|
||||
let result = FormatImage::decode(&image)
|
||||
.unwrap()
|
||||
.new_job(
|
||||
state.profile(),
|
||||
InputProfile::XeTeX,
|
||||
JobTime::new(2025, 10, 9, 0).unwrap(),
|
||||
Limits::default(),
|
||||
|_| Ok(seed.as_bytes().to_vec()),
|
||||
)
|
||||
.unwrap()
|
||||
.run(
|
||||
source(
|
||||
r"\font\t=cmr10 \t
|
||||
\XeTeXinterchartoks4095 1={\kern1pt\relax}
|
||||
\XeTeXinterchartoks2 4095={\kern4pt\relax}
|
||||
\setbox0=\hbox{AB}
|
||||
\XeTeXinterchartokenstate=1
|
||||
\setbox1=\hbox{AB}
|
||||
\setbox2=\hbox{\char65 \char66 C}
|
||||
\message{[\the\wd0,\the\wd1,\the\wd2]}
|
||||
\begingroup \sfcode65=1234 \global\XeTeXcharclass65=1 \endgroup
|
||||
\message{[\the\sfcode65,\the\XeTeXcharclass65]}
|
||||
\begingroup \XeTeXcharclass65=3 \global\sfcode65=1234 \endgroup
|
||||
\message{[\the\sfcode65,\the\XeTeXcharclass65]}
|
||||
\toks2=\XeTeXinterchartoks1 2
|
||||
\begingroup \XeTeXinterchartokenstate=-1 \XeTeXinterchartoks1 2={} \endgroup
|
||||
\XeTeXinterchartoks3 2=\toks2
|
||||
\message{[\the\XeTeXinterchartokenstate,\the\XeTeXinterchartoks3 2]}
|
||||
\end",
|
||||
),
|
||||
&mut TfmSource,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
messages(&result),
|
||||
[
|
||||
"[14.58337pt,21.58337pt,24.8056pt]",
|
||||
"[1234,1]",
|
||||
"[1234,3]",
|
||||
r"[1,\kern 2pt\relax ]",
|
||||
]
|
||||
);
|
||||
assert!(result.reads.contains(&Dependency::XeCharClass(67)));
|
||||
assert!(result.reads.contains(&Dependency::XeInterCharTokens(4098)));
|
||||
}
|
||||
Reference in new issue
Block a user