Continue XeTeX text layout on missing legacy glyphs
This commit is contained in:
1 parent
cb6525ffca
commit
90f174283e
5 files changed
+114
-15
No files matched your search
@@ -35,6 +35,60 @@ fn messages(result: &Execution) -> Vec<&str> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xetex_legacy_font_reports_unicode_outside_its_slots() {
|
||||
use sha2::{Digest, Sha256};
|
||||
use texrra_tex_core::resources::{LoadedResource, ResourceKind, ResourceVersion};
|
||||
|
||||
struct LegacyFont;
|
||||
impl SourceProvider for LegacyFont {
|
||||
fn read(&mut self, name: &str, _: &str) -> Result<SourceFile, String> {
|
||||
Err(format!("unexpected input {name}"))
|
||||
}
|
||||
|
||||
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();
|
||||
Ok(LoadedResource {
|
||||
version: ResourceVersion {
|
||||
path: "cmr10.tfm".into(),
|
||||
sha256: format!("{:x}", Sha256::digest(&data)),
|
||||
bytes: data.len() as u64,
|
||||
},
|
||||
data,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let state = State::initex().with_etex().with_input_profile(InputProfile::XeTeX);
|
||||
let result = Executor::new(state, Limits::default())
|
||||
.run(source(r#"\catcode123=1 \catcode125=2
|
||||
\font\probe=cmr10 \probe \tracinglostchars=2
|
||||
\setbox0=\hbox{f–i}
|
||||
\setbox1=\hbox{f\char"2013 i}
|
||||
\chardef\absent="2013
|
||||
\setbox2=\hbox{f\absent i}
|
||||
\sfcode"2013=1732
|
||||
\setbox3=\hbox{x–\message{\the\spacefactor}}
|
||||
\setbox4=\hbox{\char200\char"1F312}
|
||||
\message{\number\wd0,\number\wd1,\number\wd2}
|
||||
\end"#), &mut LegacyFont)
|
||||
.unwrap();
|
||||
assert_eq!(messages(&result), ["1732", "382295,382295,382295"]);
|
||||
let warnings: Vec<_> = result.events.iter().filter_map(|event| match event {
|
||||
Event::MissingGlyph(glyph) => Some((glyph.slot, glyph.message.as_deref().unwrap())),
|
||||
_ => None,
|
||||
}).collect();
|
||||
assert_eq!(warnings, [
|
||||
(0x2013, "Missing character: There is no – (\"2013) in font cmr10!"),
|
||||
(0x2013, "Missing character: There is no – (\"2013) in font cmr10!"),
|
||||
(0x2013, "Missing character: There is no – (\"2013) in font cmr10!"),
|
||||
(0x2013, "Missing character: There is no – (\"2013) in font cmr10!"),
|
||||
(0xC8, "Missing character: There is no È (\"C8) in font cmr10!"),
|
||||
(0x1F312, "Missing character: There is no 🌒 (\"1F312) in font cmr10!"),
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opentype_design_and_scaled_requests_share_actual_sized_instances() {
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
Reference in new issue
Block a user