M2: format the UCS2 lines of hayro-interpret patch 84 as default rustfmt does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA
This commit is contained in:
mtlcl410andClaude Opus 5.5 committed 2026-11-08 00:25:38 +08:00
1 parent 7bbed34d01
commit ec9736001b
2 files changed
+29 -11

No files matched your search

+13 -6
View File
@@ -146,9 +146,9 @@ dependencies = [
[[package]]
name = "font-types"
version = "0.11.3"
version = "0.12.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b38ad915f6dadd993ced50848a8291a543bd41ca62bc10740d5e64e2ab4cfd7"
checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d"
dependencies = [
"bytemuck",
]
@@ -297,6 +297,12 @@ dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "phf"
version = "0.13.1"
@@ -387,12 +393,13 @@ dependencies = [
[[package]]
name = "read-fonts"
version = "0.39.2"
version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4ed38b89c2c77ff968c524145ad65fb010f38af5c7a224b53b81d47ac2daa81"
checksum = "d5a0cf4bb6cbce4c29756270d189a5e400ac05e91192161d83a0bcb6e68492e8"
dependencies = [
"bytemuck",
"font-types",
"once_cell",
]
[[package]]
@@ -415,9 +422,9 @@ checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e"
[[package]]
name = "skrifa"
version = "0.42.1"
version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c34617370ae968efb7161bb2beb517d9084659aae19e24b89e3db25b46e4564"
checksum = "526e654b303ff4ad73a5a40b25de2b3ce3d039c5e3b6da5f89ae6e57004cb40f"
dependencies = [
"bytemuck",
"read-fonts",
+16 -5
View File
@@ -6,7 +6,6 @@ use crate::font::{
};
use crate::{CMapResolverFn, CacheKey, FontResolverFn};
use hayro_cmap::{BfString, CMap, CharacterCollection, CidFamily, WritingMode};
use std::sync::OnceLock;
use hayro_syntax::object;
use hayro_syntax::object::Dict;
use hayro_syntax::object::Name;
@@ -21,6 +20,7 @@ use skrifa::{FontRef, GlyphId, MetadataProvider};
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::Arc;
use std::sync::OnceLock;
#[derive(Debug)]
pub(crate) struct Type0Font {
@@ -141,9 +141,16 @@ impl Type0Font {
.as_ref()
.and_then(|cc| cc.family.ucs2_cmap())
.and_then(|name| (cmap_resolver)(name))
.map(|data| Ucs2 { data, resolver: cmap_resolver.clone(), map: OnceLock::new() });
.map(|data| Ucs2 {
data,
resolver: cmap_resolver.clone(),
map: OnceLock::new(),
});
// If there is no ToUnicode map, try to get the UCS2 CMap.
if fallback && to_unicode.is_none() && let Some(ucs2_cmap) = ucs2.take().and_then(|u| u.parse()) {
if fallback
&& to_unicode.is_none()
&& let Some(ucs2_cmap) = ucs2.take().and_then(|u| u.parse())
{
to_unicode = Some(ucs2_cmap);
to_unicode_is_cid_indexed = true;
}
@@ -476,7 +483,9 @@ impl Type0Font {
}
// PdfCraft patch (84): then the collection's UCS2 CMap, by the code's CID.
if let Some(ucs2) = self.ucs2.as_ref().and_then(Ucs2::cmap)
&& let Some(s) = self.code_to_cid(code).and_then(|cid| ucs2.lookup_bf_string(cid))
&& let Some(s) = self
.code_to_cid(code)
.and_then(|cid| ucs2.lookup_bf_string(cid))
{
return Some(s);
}
@@ -506,7 +515,9 @@ impl Ucs2 {
impl std::fmt::Debug for Ucs2 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Ucs2").field("bytes", &self.data.len()).finish_non_exhaustive()
f.debug_struct("Ucs2")
.field("bytes", &self.data.len())
.finish_non_exhaustive()
}
}