pub struct TextSection<'f, 'p> {
font_cache: &'f FontCache,
area: Area<'p>,
is_first: bool,
cursor_y_positioned: bool,
metrics: Metrics,
font: Option<(IndirectFontRef, u8)>,
current_x_offset: Mm,
cumulative_kerning: Mm,
first_char_offset: Mm,
}Expand description
A text section that is drawn on an area of a PDF layer.
Fields§
§font_cache: &'f FontCache§area: Area<'p>§is_first: bool§cursor_y_positioned: bool§metrics: Metrics§font: Option<(IndirectFontRef, u8)>§current_x_offset: Mm§cumulative_kerning: Mm§first_char_offset: MmImplementations§
Source§impl<'f, 'p> TextSection<'f, 'p>
impl<'f, 'p> TextSection<'f, 'p>
fn new( font_cache: &'f FontCache, area: Area<'p>, metrics: Metrics, ) -> Option<TextSection<'f, 'p>>
fn set_text_cursor(&mut self, x_offset: Mm)
fn set_font(&mut self, font: &IndirectFontRef, font_size: u8)
Sourcepub fn add_newline(&mut self) -> bool
pub fn add_newline(&mut self) -> bool
Tries to add a new line and returns true if the area was large enough to fit the new
line.
Sourcepub fn print_str(
&mut self,
s: impl AsRef<str>,
style: Style,
) -> Result<(), Error>
pub fn print_str( &mut self, s: impl AsRef<str>, style: Style, ) -> Result<(), Error>
Prints the given string with the given style.
The font cache for this text section must contain the PDF font for the given style.
Prints a string using the provided Style and font cache.
For built-in PDF fonts, the string is emitted as a single item and the PDF viewer’s native kerning and glyph selection is relied upon. For embedded (external) fonts we also emit the whole string as a single write op so that glyph selection and any ToUnicode mapping is handled by the PDF serializer/renderer. This avoids brittle glyph-id → byte encodings that can become invalid when fonts are subsetted/remapped during PDF serialization. (If finer-grained positioning is needed in the future we may add a TJ-based emission that preserves a single text object.)
Trait Implementations§
Auto Trait Implementations§
impl<'f, 'p> Freeze for TextSection<'f, 'p>
impl<'f, 'p> !RefUnwindSafe for TextSection<'f, 'p>
impl<'f, 'p> !Send for TextSection<'f, 'p>
impl<'f, 'p> !Sync for TextSection<'f, 'p>
impl<'f, 'p> Unpin for TextSection<'f, 'p>
impl<'f, 'p> !UnwindSafe for TextSection<'f, 'p>
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
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§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.