Reload letterspaced font metrics independently of generated packets
This commit is contained in:
1 parent
65204a7dae
commit
aa780a800b
6 files changed
+154
-3
No files matched your search
@@ -1888,6 +1888,98 @@ fn relocated_format_binds_packed_and_new_glyphs_to_the_current_tfm() {
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loaded_format_uses_current_letterspace_font_programs() {
|
||||
use texrra_tex_core::render::DisplayItem;
|
||||
|
||||
let root = directory("format-letterspace").canonicalize().unwrap();
|
||||
let fonts = root.join("fonts");
|
||||
fs::create_dir(&fonts).unwrap();
|
||||
let map = fonts.join("pdftex.map");
|
||||
let outline = fonts.join("cmr10.pfb");
|
||||
fs::write(&outline, include_bytes!("../assets/fonts/cmr10.pfb")).unwrap();
|
||||
let seed = br"\catcode123=1 \catcode125=2
|
||||
\pdfoutput=1 \font\face=cmr10
|
||||
\letterspacefont\spaced=\face 80
|
||||
\setbox0=\hbox{\spaced AV}
|
||||
\setbox1=\hbox{\spaced XYZ}
|
||||
\pdfxform 1
|
||||
\edef\pendingform{\the\pdflastxform}
|
||||
\dump
|
||||
";
|
||||
fs::write(root.join("seed.tex"), seed).unwrap();
|
||||
let mut job = request(&root);
|
||||
for kind in [
|
||||
ResourceKind::Map,
|
||||
ResourceKind::Type1,
|
||||
ResourceKind::Vf,
|
||||
ResourceKind::Pk,
|
||||
] {
|
||||
job.world
|
||||
.paths
|
||||
.insert(kind, vec![SearchPath::directory(&fonts, false)]);
|
||||
}
|
||||
let mut dump = job.clone();
|
||||
dump.input = "seed.tex".into();
|
||||
dump.output = "seed.tfx".into();
|
||||
dump_format(dump, Cancellation::default()).unwrap();
|
||||
job.entry = Entry::Format(root.join("seed.tfx"));
|
||||
fs::write(
|
||||
root.join("main.tex"),
|
||||
br"\setbox2=\hbox{\spaced AV}
|
||||
\ifdim\wd0=15.4889pt\else\errmessage{saved width changed}\fi
|
||||
\ifdim\wd2=\wd0\else\errmessage{new width differs}\fi
|
||||
\shipout\hbox{\copy0 \box2 \face ABC}
|
||||
\shipout\hbox{\pdfrefxform\pendingform}
|
||||
\end
|
||||
",
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(&map, b"cmr10 CMR10 <cmr10.pfb\ncmr10+80ls CMR10 <cmr10.pfb\n").unwrap();
|
||||
let compiler = NativeCompiler::default();
|
||||
let first = compiler.compile(job.clone()).unwrap();
|
||||
|
||||
let glyphs: Vec<_> = first.pages[0]
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|item| match item {
|
||||
DisplayItem::NativeGlyph { font, slot, .. } => {
|
||||
assert!(font.letter_spacing.is_none());
|
||||
Some((font.name.as_str(), *slot))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(
|
||||
glyphs,
|
||||
[
|
||||
("cmr10+80ls", b'A'),
|
||||
("cmr10+80ls", b'V'),
|
||||
("cmr10+80ls", b'A'),
|
||||
("cmr10+80ls", b'V'),
|
||||
("cmr10", b'A'),
|
||||
("cmr10", b'B'),
|
||||
("cmr10", b'C'),
|
||||
]
|
||||
);
|
||||
for path in [&map, &outline] {
|
||||
assert!(
|
||||
first.resources.trace.reads.contains(&file_version(path).unwrap().unwrap())
|
||||
);
|
||||
}
|
||||
|
||||
fs::write(&map, b"cmr10 CMR10 <cmr10.pfb\n").unwrap();
|
||||
let error = compiler
|
||||
.compile_detailed(job)
|
||||
.err()
|
||||
.unwrap()
|
||||
.error
|
||||
.to_string();
|
||||
assert!(error.contains("cmr10+80ls"), "{error}");
|
||||
assert!(Arc::ptr_eq(&first, &compiler.latest().unwrap()));
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shared_format_build_load_and_cancelled_build_preserve_real_output_policy() {
|
||||
let p = directory("format");
|
||||
|
||||
Reference in new issue
Block a user