Skip to main content

ActualTextIndex

Struct ActualTextIndex 

Source
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§

Source§

impl ActualTextIndex

Source

pub fn new() -> Self

Construct an empty index.

Source

pub fn is_empty(&self) -> bool

Returns true when no ActualText scopes were discovered.

Trait Implementations§

Source§

impl Clone for ActualTextIndex

Source§

fn clone(&self) -> ActualTextIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActualTextIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActualTextIndex

Source§

fn default() -> ActualTextIndex

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Ungil for T
where T: Send,