Resolve named XeTeX fonts through captured resource catalogues

This commit is contained in:
gloamxun committed 2026-11-21 15:54:06 +08:00
1 parent a31de14eb2
commit 767c8ffced
10 files changed
+513 -12

No files matched your search

+22
View File
@@ -1,5 +1,7 @@
//! Native filesystem resource lookup. No external TeX/kpathsea subprocess.
mod deferred;
mod named_fonts;
pub use named_fonts::{FontStyle, NamedFont};
mod project;
pub use deferred::{
DeferredProbe, DirectoryAbsence, GeneratedLookup, GeneratedLookupOrigin, GeneratedLookupRole,
@@ -359,6 +361,8 @@ pub struct InputSnapshot {
// Older captures only probed the supplied name when it had a suffix.
#[serde(default)]
tex_suffix_fallback: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
system_fonts: Option<Result<Vec<named_fonts::NamedFace>, String>>,
}
/// A failed enumeration is not a complete namespace. Retain the usable prefix
/// only as evidence and replay its actual error, never as a successful index.
@@ -429,6 +433,15 @@ impl InputSnapshot {
if self.schema != 1 || !self.config.cwd.is_absolute() {
return Err("incompatible native input snapshot".into());
}
if self.project.is_some() && self.system_fonts.is_some() {
return Err("atomic project cannot import a live system font catalogue".into());
}
if let Some(Ok(faces)) = &self.system_fonts
&& (faces.len() > self.config.max_index_entries
|| faces.iter().any(|face| !face.valid_capture()))
{
return Err("invalid captured font catalogue".into());
}
if let Some(project) = &self.project {
project.validate()?;
if project.configuration() != self.config {
@@ -534,6 +547,8 @@ pub struct FileWorld {
protected_paths: BTreeSet<PathBuf>,
replay_gaps: Vec<String>,
project: Option<Arc<ProjectSnapshot>>,
system_fonts: Option<Result<Vec<named_fonts::NamedFace>, String>>,
project_named_fonts: Option<Vec<named_fonts::NamedFace>>,
}
impl FileWorld {
pub fn default_pk_resolution(&self) -> i32 {
@@ -669,6 +684,8 @@ impl FileWorld {
protected_paths: BTreeSet::new(),
replay_gaps: Vec::new(),
project: None,
system_fonts: None,
project_named_fonts: None,
})
}
pub fn capture_inputs(&mut self) {
@@ -710,6 +727,8 @@ impl FileWorld {
protected_paths: BTreeSet::new(),
replay_gaps: Vec::new(),
project: Some(project),
system_fonts: None,
project_named_fonts: None,
})
}
pub fn project(&self) -> Option<&Arc<ProjectSnapshot>> {
@@ -796,6 +815,8 @@ impl FileWorld {
protected_paths: BTreeSet::new(),
replay_gaps: Vec::new(),
project: snapshot.project.clone(),
system_fonts: snapshot.system_fonts.clone(),
project_named_fonts: None,
})
}
pub fn input_snapshot(&self) -> Arc<InputSnapshot> {
@@ -816,6 +837,7 @@ impl FileWorld {
lookups: self.trace.lookups.clone(),
replay_gaps: gaps,
project: self.project.clone(),
system_fonts: self.system_fonts.clone(),
})
}
/// Only the authorized host may mark its generated-file paths live. These