Skip to main content

RenderOptions

Struct RenderOptions 

Source
pub struct RenderOptions {
    pub transform: Affine,
    pub color_mode: ColorMode,
    pub text_aa: TextAa,
    pub text_aa_override: Option<TextAa>,
    pub no_path_smooth: bool,
    pub no_image_smooth: bool,
    pub force_halftone: bool,
    pub rect_aa: bool,
    pub convert_fill_to_stroke: bool,
    pub subpixel_text_positioning: bool,
    pub background: Option<Color>,
}
Expand description

Everything a render is parameterised by.

Constructed with ..RenderOptions::default() struct update. The defaults are the oracle’s: reproducing a golden needs no configuration beyond the target size.

Fields§

§transform: Affine

Page space to device space. render_page composes this with the page’s own display matrix.

§color_mode: ColorMode

The colour mode, normally ColorMode::Normal.

§text_aa: TextAa

Glyph antialiasing, for the whole render.

§text_aa_override: Option<TextAa>

Glyph antialiasing for this draw only, overriding Self::text_aa.

Text antialiasing is per-draw, not per-render: on a page whose every other run is grayscale, a live edit’s text is drawn with ClearType.

None — the default — means Self::text_aa decides. A caller drawing one run differently sets this on a clone of its options for that run, so the page’s own setting stays readable.

§no_path_smooth: bool

bNoPathSmooth: hard-edge every path fill and stroke.

§no_image_smooth: bool

bNoImageSmooth: never interpolate an image, whatever /Interpolate or the size heuristic say. Wins over both.

§force_halftone: bool

bForceHalftone. Forced on inside type-3 char procs and uncoloured tile cells, so it reaches a render even with the oracle’s bare flags.

§rect_aa: bool

bRectAA: antialias axis-aligned rectangle fills instead of integer-snapping them. Forced on inside type-3 char procs.

§convert_fill_to_stroke: bool

bConvertFillToStroke, read only under a forced colour scheme.

§subpixel_text_positioning: bool

Place each glyph at its true fractional device origin instead of snapping it to a whole pixel.

Default false, which is the oracle: small text is placed on a grid of whole pixels in y and thirds of a pixel in x. Set this to true when a caller wants text where the PDF actually puts it — smooth animation, a non-integer device scale, any use where oracle parity is not the goal — at the cost of matching a golden.

No effect on large text: above the size threshold glyphs are placed fractionally either way.

§background: Option<Color>

The page background. None follows the oracle: opaque white for a page without transparency, fully transparent for one with it.

This is load-bearing rather than cosmetic — a white-backed page composites differently at the edges from a transparent-backed one, and the engine’s single compositing path relies on the white being real pixels where the oracle would have replayed a white backdrop.

Implementations§

Source§

impl RenderOptions

Source

pub fn background_for(&self, has_transparency: bool) -> Color

The background a page with the given transparency renders onto: opaque white when the page is opaque, fully transparent when it is not, unless RenderOptions::background overrides it.

Source

pub fn path_aa(&self) -> AntiAlias

Whether path geometry is antialiased under these options.

Source

pub fn effective_text_aa(&self) -> TextAa

The text antialiasing in force for the draw being made: the per-draw Self::text_aa_override when a caller set one, else Self::text_aa.

Source

pub fn for_text_run(&self, aa: TextAa) -> Self

The options one text run draws under with aa forced, leaving the page’s own options untouched.

This is what a live edit’s text draws through.

Source

pub fn text_antialias(&self) -> AntiAlias

Whether glyph outlines are antialiased under these options.

The outline path has no subpixel spelling, so TextAa::LcdSubpixel antialiases here exactly like TextAa::Grayscale. The subpixel choice is expressed on the bitmap path, the only place the oracle expresses it either.

Source

pub fn for_type3_char_proc(&self) -> Self

The options a type-3 char proc renders under: forced halftone and rectangle antialiasing, which means a rectangle inside a type-3 glyph is antialiased where the same rectangle on the page would not be.

Source

pub fn for_uncolored_tile(&self) -> Self

The options an uncoloured tiling pattern’s cell renders under: alpha colour mode plus forced halftone.

Trait Implementations§

Source§

impl Clone for RenderOptions

Source§

fn clone(&self) -> Self

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 RenderOptions

Source§

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

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

impl Default for RenderOptions

Source§

fn default() -> Self

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

impl PartialEq for RenderOptions

Source§

fn eq(&self, other: &RenderOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RenderOptions

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<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<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> 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<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.