Select named XeTeX faces by optical size

This commit is contained in:
gloamxun committed 2026-11-28 13:01:52 +08:00
1 parent 115e1f0fe0
commit d4e78bc29a
9 files changed
+290 -31

No files matched your search

@@ -84,6 +84,52 @@ fn opentype_design_and_scaled_requests_share_actual_sized_instances() {
assert_eq!(messages(&result), ["657818/484811/655360", "SAME/SAME/DIFFERENT"]);
}
#[test]
fn named_optical_lookup_reconsiders_new_faces_and_tracks_compared_resources() {
use std::{fs, process::Command, sync::Arc};
use texrra_tex_core::resources::{
FileWorld, FontStyle, ProjectDefinition, ProjectSnapshot, ResourceKind, SearchPath,
WorldConfig,
};
let root = std::env::temp_dir().canonicalize().unwrap().join("texrra-optical-catalogue");
let load = |name: &str| {
let found = Command::new("kpsewhich").arg(name).output().unwrap();
assert!(found.status.success(), "missing reference font {name}");
Arc::<[u8]>::from(fs::read(String::from_utf8(found.stdout).unwrap().trim()).unwrap())
};
let base = root.join("lmroman10-regular.otf");
let distant = root.join("lmroman17-regular.otf");
let covering = root.join("lmroman12-regular.otf");
let mut configuration = WorldConfig::new(&root);
configuration.paths.insert(ResourceKind::OpenType, vec![SearchPath::directory(&root, false)]);
let project = ProjectSnapshot::new(ProjectDefinition {
configuration, revision: 1, roots: [root.clone()].into(),
files: [
(base.clone(), load("lmroman10-regular.otf")),
(distant.clone(), load("lmroman17-regular.otf")),
].into(),
directories: Default::default(), aliases: Default::default(),
generated_roots: Default::default(), generated: Default::default(),
}).unwrap();
let with_covering = project.with_file_changes(
2, [(covering.clone(), Some(load("lmroman12-regular.otf")))].into(),
).unwrap();
for (snapshot, expected, compared) in [
(project, &base, &distant), (with_covering, &covering, &covering),
] {
let mut world = FileWorld::from_project(snapshot.clone()).unwrap();
let font = world.read_named_font_with_size(
"LMRoman10-Regular", FontStyle::default(), Some(12.5), &root.join("main.tex"),
).unwrap().unwrap();
assert_eq!(&font.resource.version.path, expected);
assert_eq!(world.trace().reads, [
snapshot.file(&base).unwrap().version.clone(),
snapshot.file(compared).unwrap().version.clone(),
]);
}
}
#[test]
fn xetex_primitives_follow_each_profiles_language_and_device() {
let tex = r"\catcode123=1 \catcode125=2