Expand description
Page rasterization for pdfboss: paths, fills, strokes, clipping, color spaces, images and glyph outlines, rendered to an RGBA8 pixmap and encodable as PNG.
Glyph painting is staged behind GlyphPainting tiers: embedded
TrueType only, then every embedded font program (TrueType, CFF, Type1,
Type3), and finally Full, which additionally substitutes a
replacement face for a non-embedded simple font (see crate::glyph and
crate::substitute for the loader and the request/provider plumbing).
A substitute face comes from either a caller-supplied directory
(SubstituteSource::Dir) or the compiled-in OFL Croscore set
(SubstituteSource::Builtin), the latter gated behind this crate’s
substitute-fonts Cargo feature and queryable at runtime via
builtin_fonts_available. Advance widths for a substituted
standard-14 font additionally consult Adobe Core-14 AFM tables
(pdfboss_encoding::standard_14_width) ahead of the substitute’s own
hmtx, behind only the PDF’s own /Widths.
v1 limitations: /Symbol and /ZapfDingbats have no license-clean
substitute, so they stay unpainted at every tier rather than borrowing
an unrelated face’s glyphs; a “bold” sans substitute request is not
visually distinct from regular weight (Arimo is a [wght] variable
font, rendered at its Regular instance – only italic varies, via a
separate static face); and advancing unpainted non-embedded text at
AllEmbedded via the AFM tables is deferred to a later plan.
Structs§
- Pixmap
- An RGBA8 raster image with straight (non-premultiplied) alpha, row-major from the top-left.
- Render
Options - Options controlling a single page render.
- Render
Report - What a page render could not reproduce faithfully: content dropped outright (an undecodable image, an unreadable form) and content painted as an approximation (a pattern fill as flat gray). Empty means every construct the render encountered was painted as the page describes it.
- Skipped
Content - One kind of content dropped for one reason, with how often it happened.
Enums§
- Glyph
Painting - How aggressively the rasterizer turns text into filled outlines. Each tier is a strict superset of the previous one; the difference is only observable once the corresponding glyph loaders exist.
- Skip
Reason - Why a piece of page content was dropped or approximated during rasterization.
- Skipped
Kind - Which piece of page content a render could not reproduce.
- Substitute
Source - Where non-embedded glyph substitution (the
FullGlyphPaintingtier) draws replacement faces from. The default,None, substitutes nothing –Fullbehaves exactly likeAllEmbeddeduntil a caller opts in.
Functions§
- builtin_
fonts_ available - Whether this binary was built with the
substitute-fontsfeature, i.e. whetherSubstituteSource::Builtinhas compiled-in faces to hand out. Callers (e.g. the CLI) use this to give an actionable message whenFullis requested with no--font-dirand no compiled-in set, rather than silently rendering as ifFullhad never been asked for. - render_
page - Renders a page at
scaleonto a white background. The pixel size isceil(crop_w * scale) x ceil(crop_h * scale)(after/Rotate), and the base transform maps the crop box to device space with a y-flip and the page rotation applied. - render_
page_ reporting - Renders a page like
render_page_with_options, additionally returning aRenderReportdescribing any content that had to be dropped or approximated. Use this when a silently blank page would be misleading. - render_
page_ reporting_ with - Renders a page like
render_page_reportingagainst any object source, awaiting whatever I/O the source needs — this is the asynchronous entry point, and the synchronous ones above are this implementation overpdfboss_core::Immediate, so the two APIs cannot render differently. - render_
page_ with_ options - Renders a page like
render_page, honoringopts(currently the glyph painting tier). Seerender_pagefor the geometry contract and for what leniency means for the pixels you get back.