Render imported PDF TrueType device fonts from exact SFNT faces
This commit is contained in:
1 parent
b640b26eff
commit
84d6f3ae51
14 files changed
+504
-76
No files matched your search
@@ -2,6 +2,7 @@
|
||||
mod deferred;
|
||||
mod named_fonts;
|
||||
pub use named_fonts::{FontStyle, NamedFont};
|
||||
pub(crate) use named_fonts::exact_truetype_name;
|
||||
mod project;
|
||||
pub use deferred::{
|
||||
DeferredProbe, DirectoryAbsence, GeneratedLookup, GeneratedLookupOrigin, GeneratedLookupRole,
|
||||
@@ -316,12 +317,21 @@ pub struct WorldFailure {
|
||||
}
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
struct DirectoryIndex {
|
||||
#[serde(default = "recursive_index", skip_serializing_if = "recursive_index_value")]
|
||||
recursive: bool,
|
||||
directories: Vec<(PathBuf, SystemTime)>,
|
||||
#[serde(default)]
|
||||
directory_aliases: BTreeMap<PathBuf, PathBuf>,
|
||||
#[serde(with = "index_names")]
|
||||
names: BTreeMap<std::ffi::OsString, Vec<PathBuf>>,
|
||||
}
|
||||
fn recursive_index() -> bool {
|
||||
true
|
||||
}
|
||||
fn recursive_index_value(recursive: &bool) -> bool {
|
||||
*recursive
|
||||
}
|
||||
|
||||
// OsString has a platform-tagged serde representation, so it cannot be a JSON
|
||||
// object key. Preserve exact filename values as entries rather than lossy text.
|
||||
mod index_names {
|
||||
@@ -1349,32 +1359,40 @@ impl FileWorld {
|
||||
}
|
||||
}
|
||||
fn index(&mut self, root: &Path) -> Result<&DirectoryIndex, String> {
|
||||
self.index_at(root, true)
|
||||
}
|
||||
|
||||
fn index_at(&mut self, root: &Path, recursive: bool) -> Result<&DirectoryIndex, String> {
|
||||
if let Some(project) = &self.project {
|
||||
// The index tracks the logical namespace. Each candidate's live
|
||||
// existence and staged bytes are still checked by probe().
|
||||
if !self.current_project_indexes.contains(root) {
|
||||
if !self.current_project_indexes.contains(root)
|
||||
|| (recursive && !self.indexes[root].recursive)
|
||||
{
|
||||
let index =
|
||||
project.index(root, &self.project_paths(), self.config.max_index_entries)?;
|
||||
project.index(root, &self.project_paths(), self.config.max_index_entries, recursive)?;
|
||||
self.indexes.insert(root.into(), Arc::new(index));
|
||||
self.current_project_indexes.insert(root.into());
|
||||
}
|
||||
return Ok(&self.indexes[root]);
|
||||
}
|
||||
if self.pinned {
|
||||
if let Some(failure) = self.index_failures.get(root) {
|
||||
return Err(failure.error.clone());
|
||||
}
|
||||
if self.pinned
|
||||
&& let Some(failure) = self.index_failures.get(root)
|
||||
&& (recursive || !failure.partial.recursive)
|
||||
{
|
||||
return Err(failure.error.clone());
|
||||
}
|
||||
// Live worlds revalidate directory timestamps; captured worlds freeze
|
||||
// observed enumeration. Neither mode authorizes execution/layout reuse.
|
||||
let fresh = self.indexes.get(root).is_some_and(|index| {
|
||||
self.pinned
|
||||
|| (!index.directories.is_empty()
|
||||
&& index.directories.iter().all(|(p, t)| {
|
||||
p.metadata()
|
||||
.and_then(|m| m.modified())
|
||||
.is_ok_and(|v| v == *t)
|
||||
}))
|
||||
(!recursive || index.recursive)
|
||||
&& (self.pinned
|
||||
|| (!index.directories.is_empty()
|
||||
&& index.directories.iter().all(|(p, t)| {
|
||||
p.metadata()
|
||||
.and_then(|m| m.modified())
|
||||
.is_ok_and(|v| v == *t)
|
||||
})))
|
||||
});
|
||||
if !fresh {
|
||||
if self.replay {
|
||||
@@ -1384,6 +1402,7 @@ impl FileWorld {
|
||||
));
|
||||
}
|
||||
let mut index = DirectoryIndex {
|
||||
recursive,
|
||||
directories: Vec::new(),
|
||||
directory_aliases: BTreeMap::new(),
|
||||
names: BTreeMap::new(),
|
||||
@@ -1427,7 +1446,11 @@ impl FileWorld {
|
||||
}
|
||||
let path = child.path();
|
||||
match path.metadata() {
|
||||
Ok(m) if m.is_dir() => queue.push((path, ancestors.clone())),
|
||||
Ok(m) if m.is_dir() => {
|
||||
if recursive {
|
||||
queue.push((path, ancestors.clone()));
|
||||
}
|
||||
}
|
||||
Ok(_) => index.names.entry(child.file_name()).or_default().push(path),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
|
||||
if path
|
||||
|
||||
Reference in new issue
Block a user