pub struct TextLayer {
pub text: String,
pub zones: Vec<TextZone>,
}Expand description
The complete text layer of a DjVu page.
Fields§
§text: StringFull plain-text content of the page, UTF-8.
zones: Vec<TextZone>Top-level zone nodes (usually a single Page zone).
Implementations§
Source§impl TextLayer
impl TextLayer
Sourcepub fn transform(
&self,
page_w: u32,
page_h: u32,
rotation: Rotation,
render_w: u32,
render_h: u32,
) -> Self
pub fn transform( &self, page_w: u32, page_h: u32, rotation: Rotation, render_w: u32, render_h: u32, ) -> Self
Return a copy of this text layer with all zone rectangles transformed to
match a rendered page of size render_w × render_h.
page_w,page_h— native page dimensions from the INFO chunk.rotation— page rotation from the INFO chunk.render_w,render_h— the pixel size of the rendered output.
Applies rotation first (in native pixel space), then scales the result proportionally to the requested render size. The text content is preserved unchanged.
Sourcepub fn reflowable_text(&self) -> Vec<Paragraph>
pub fn reflowable_text(&self) -> Vec<Paragraph>
Group the page text into reading-order paragraphs (#228).
Uses the DjVu zone separator characters carried in self.text:
\x00(NUL),\x0b(VT),\x1d(GS),\x1f(US) — paragraph / region / column / page boundary. Each starts a newParagraph.\x0a(LF) — line break within a paragraph.
Line joining: trailing whitespace is dropped from each line. If a line
ends with - and the next line starts with an ASCII lowercase letter,
the hyphen is dropped and the lines are joined with no separator
(soft-hyphen at line end). Otherwise lines are joined with a single
ASCII space.
Empty paragraphs (only whitespace) are skipped. The returned vector preserves zone-stream order — for the typical OCR’d single-column page this is reading order.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TextLayer
impl<'de> Deserialize<'de> for TextLayer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for TextLayer
impl RefUnwindSafe for TextLayer
impl Send for TextLayer
impl Sync for TextLayer
impl Unpin for TextLayer
impl UnsafeUnpin for TextLayer
impl UnwindSafe for TextLayer
Blanket Implementations§
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
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 more