pub struct ActualTextIndex {
pub mcid_to_actual_text: HashMap<(McidScope, u32), Arc<str>>,
pub covered_mcids: HashSet<(McidScope, u32)>,
pub suppress_only: HashSet<(McidScope, u32)>,
}Expand description
Pre-computed index of structure-element /ActualText replacements
resolved over the entire structure tree.
Per ISO 32000-1:2008 §14.9.4, a structure element may carry an
/ActualText entry that replaces the entire content of its
descendants for text-extraction purposes. The replacement scope is
the subtree rooted at the bearing element. Nested ActualText
declarations override their ancestors for the spans they cover.
§Data model: keyed by (McidScope, mcid)
Per ISO 32000-1:2008 §14.7.4.3, MCIDs are NOT globally unique — they
are unique only within a single content stream (page content stream,
Form XObject content stream, or Tiling Pattern content stream). Two
Form XObjects on the same page can both emit MCID 0 referring to
distinct structure elements. Keying by (McidScope, mcid) keeps
every namespace separate.
For page-scoped MCIDs, McidScope::Page(page_index) plays exactly
the role the previous (page, mcid) keying did; the cross-page
emit-once rule still applies via Self::suppress_only. Form- and
Pattern-scoped MCIDs are intrinsically per-stream — every covered
MCID emits at its anchor (the form/pattern’s content stream covers
a single namespace).
§Emission model: mcid-driven, consecutive-run dedup
Consumers iterate per-page MCIDs in structure-tree order and emit
mcid_to_actual_text[(page, mcid)] whenever the replacement
changes between consecutive covered MCIDs. A subtree covering
[5, 6, 7] with one replacement string therefore emits ONE
replacement; a subtree where a nested ActualText overrides MCID 6
gives THREE emissions (outer at 5, inner at 6, outer at 7), which
is the correct inner-wins shape. Run-end is detected at the next
non-covered MCID or at a covered MCID with a different replacement.
§Visibility (OCG filtering)
When a covered MCID has been filtered out by an excluded OCG layer, the consumer skips emission for that MCID but does NOT break the consecutive-run dedup — so partial OCG visibility still emits the replacement at the first visible covered MCID in the run.
Fields§
§mcid_to_actual_text: HashMap<(McidScope, u32), Arc<str>>Map from (McidScope, mcid) → its innermost replacement text.
The “innermost” resolution honours nesting: when a descendant
element redeclares /ActualText, the descendant’s text replaces
the ancestor’s for (scope, mcid) keys in the inner subtree.
covered_mcids: HashSet<(McidScope, u32)>(McidScope, mcid) pairs whose raw glyph spans must be
suppressed during assembly.
Every key in Self::mcid_to_actual_text is present here, and
keys in Self::suppress_only are present here too. Suppression
prevents duplicate output: the replacement is emitted via the
mcid-driven walk, and raw glyphs for the same (scope, mcid)
are dropped.
suppress_only: HashSet<(McidScope, u32)>(McidScope, mcid) pairs that are covered (raw glyphs
suppressed) but must NOT emit a replacement.
For page-scoped subtrees, this encodes “emit-once on the first
page” semantics: the bearing element’s first-page (Page(p), mcid)
entries land in Self::mcid_to_actual_text; every other page’s
(Page(p), mcid) entries land here so the raw glyphs are still
suppressed but no second emission fires. Form- and Pattern-
scoped subtrees do not populate this set: each
Form / Pattern covers a single namespace.
Implementations§
Trait Implementations§
Source§impl Clone for ActualTextIndex
impl Clone for ActualTextIndex
Source§fn clone(&self) -> ActualTextIndex
fn clone(&self) -> ActualTextIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ActualTextIndex
impl Debug for ActualTextIndex
Source§impl Default for ActualTextIndex
impl Default for ActualTextIndex
Source§fn default() -> ActualTextIndex
fn default() -> ActualTextIndex
Auto Trait Implementations§
impl Freeze for ActualTextIndex
impl RefUnwindSafe for ActualTextIndex
impl Send for ActualTextIndex
impl Sync for ActualTextIndex
impl Unpin for ActualTextIndex
impl UnsafeUnpin for ActualTextIndex
impl UnwindSafe for ActualTextIndex
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.