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: AffinePage space to device space. render_page composes this with the
page’s own display matrix.
color_mode: ColorModeThe colour mode, normally ColorMode::Normal.
text_aa: TextAaGlyph 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: boolbNoPathSmooth: hard-edge every path fill and stroke.
no_image_smooth: boolbNoImageSmooth: never interpolate an image, whatever /Interpolate
or the size heuristic say. Wins over both.
force_halftone: boolbForceHalftone. 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: boolbRectAA: antialias axis-aligned rectangle fills instead of
integer-snapping them. Forced on inside type-3 char procs.
convert_fill_to_stroke: boolbConvertFillToStroke, read only under a forced colour scheme.
subpixel_text_positioning: boolPlace 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
impl RenderOptions
Sourcepub fn background_for(&self, has_transparency: bool) -> Color
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.
Sourcepub fn effective_text_aa(&self) -> TextAa
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.
Sourcepub fn for_text_run(&self, aa: TextAa) -> Self
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.
Sourcepub fn text_antialias(&self) -> AntiAlias
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.
Sourcepub fn for_type3_char_proc(&self) -> Self
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.
Sourcepub fn for_uncolored_tile(&self) -> Self
pub fn for_uncolored_tile(&self) -> Self
The options an uncoloured tiling pattern’s cell renders under: alpha colour mode plus forced halftone.