Skip to main content

Module renderer

Module renderer 

Source

Re-exports§

pub use audio_analysis::*;

Modules§

audio_analysis
google_fonts
Google Fonts download and disk-cache helpers.

Structs§

VideoProbe
Duration, dimensions and frame rate of a local video file, read from its container/stream metadata via ffprobe — never by decoding a frame (that is extract_video_frame’s job, and it decodes exactly one, not the metadata).

Constants§

ICON_OVERSAMPLE
How much larger than the target (layout) size icons are rasterized, so Skia’s downscale keeps edges crisp under sub-pixel positioning and minor scale animations.
UNRESOLVED_COLOR
Sentinel colour returned by parse_hex_color (and used by callers of parse_css_color that choose to mirror this convention) when the input string cannot be resolved as any known CSS colour form. Deliberately jarring so a bad colour string is obvious on screen rather than disappearing into a dark background.

Functions§

asset_cache
build_shape_path
Build a Path for the given shape type without drawing it.
clear_asset_cache
Clear the asset cache (call between renders if needed)
color4f_from_hex
draw_shape_path
draw_text_with_fallback
Draw a text line with emoji-font and glyph-coverage fallback (#3, #8). If emoji_font is None, falls back to drawing everything with the primary font (plus any #3 system fallback the primary font’s coverage gap needs).
emoji_typeface
Resolve the system emoji typeface. Cached per thread.
extract_video_frame
fallback_typeface_for_char
Resolve a system fallback typeface that actually contains a glyph for c, for when primary_family’s own face doesn’t cover it (audit #3: CJK/Arabic/Devanagari/other scripts rendered as .notdef tofu when only a Latin font-family was requested, because neither measurement nor painting ever looked past the single requested typeface). This is Skia’s font-fallback-by-character API — the same mechanism a browser uses to substitute, say, a CJK font for Chinese text embedded in an otherwise-Latin paragraph, instead of leaving .notdef tofu. Memoized per thread (keyed on the inputs that actually affect the OS’s fallback decision) since callers may probe this once per uncovered code point during run segmentation. Returns None if no installed font covers c either — the caller falls back to the originally requested (tofu- producing) font, exactly the pre-fix behaviour, not worse.
fetch_icon_svg
Fetch an icon’s SVG bytes, checking the on-disk cache first and falling back to the Iconify API on a miss. Same public signature as before this fix — every existing caller (icon.rs, preload.rs, badge.rs, notification.rs, list.rs, stat.rs) gets the disk cache for free.
fetch_icon_svg_in
Core of fetch_icon_svg, with the cache directory injectable so tests can exercise the cache-hit path without touching $HOME or the network — mirrors google_fonts::resolve_google_font’s cache_dir parameter.
ffmpeg_available
Returns true if ffmpeg is on PATH.
ffprobe_available
Returns true if ffprobe is on PATH. Mirrors ffmpeg_available above — ffprobe ships alongside ffmpeg in every common distribution but is its own binary, so its own check.
find_closest_frame
font_mgr
format_counter_value
gif_cache
has_emoji
True if text contains any character that wants emoji presentation (#8-aware: honours the VS16 opt-in for text-presentation-default code points, so plain “©”/“✓” no longer count as emoji here).
icon_cache_dir
Returns the icon disk-cache directory: ~/.cache/rustmotion/icons.
icon_cache_key
Single source of truth for both the oversampled rasterization size and the asset_cache key used for a given icon at a given target (layout) size. Returns (render_width, render_height, cache_key).
load_custom_fonts
Load custom fonts from FontEntry definitions. Emits a single warning per missing or unreadable file so the user notices broken paths up-front.
make_text_blob_with_spacing
measure_text_with_fallback
Measure the width of a text line with emoji-font and glyph-coverage fallback (#3, #8) — mirrors draw_text_with_fallback run-for-run so the width this returns always matches what actually gets painted.
paint_from_hex
parse_css_color
Parse any CSS colour string into (r, g, b, a) bytes.
parse_hex_color
Parse a hex colour string (any CSS colour form, historically hex-only — see module docs) into RGBA components. Infallible: unresolvable input is reported to stderr and mapped to UNRESOLVED_COLOR rather than black.
probe_image_dimensions
Cheap (header-only) dimensions of a local raster image file. The image crate’s ImageReader::into_dimensions builds just enough of the decoder to read its declared dimensions, without decoding any pixel data — unlike every existing paint-time image load in this codebase (image.rs, avatar.rs, mockup.rs, …), which all go through skia_safe::Image::from_encoded and pay for a full raster decode because they need the pixels themselves. A metadata-only query has no such need, so it takes the cheaper of the two paths instead of reusing theirs.
probe_video_metadata
Probes a local video file’s metadata via ffprobe -show_streams -show_format -of json, a single subprocess call (no frame decode, no download): the first video stream’s width/height/frame rate, and a duration that prefers the stream’s own duration field but falls back to the container’s format.duration (some containers — notably ones produced by streaming muxers — only populate the latter).
register_custom_font_variant
Register a custom font’s bytes under family, tagged with the (weight, italic) style Skia reports for the parsed file. A no-op if that exact (family, weight, italic) combination is already registered.
resolve_custom_typeface
Look up only the custom/Google-font registry for family at the requested style, without falling through to any system font. Exposed for callers (e.g. codeblock/terminal’s monospace font resolver) that need to check “did the scenario declare a custom font for this family” before trying their own family-specific system fallback chain — unlike typeface_with_fallback, which interleaves a single system-family lookup between the custom check and its own generic Helvetica/Arial catch-all, an order that doesn’t suit every caller (see issue: codeblock/ terminal’s hardcoded monospace fallback list was never reached because typeface_with_fallback’s own system lookup already matched a decoy system family, e.g. “JetBrains Mono”).
resolve_font_entry
Validate a FontEntry and resolve it to a list of TTF file paths.
rgba_to_yuv420
Convert RGBA pixels to YUV420 (I420) for H.264 encoding. Uses integer BT.601 arithmetic and rayon parallelization for performance.
typeface_with_fallback
Resolve a typeface for family falling back through Helvetica → Arial → the OS default. Returns RustmotionError::FontNotFound only if the host system has no usable font at all (essentially unreachable on every supported platform). Use this instead of .expect("FontNotFound") so we never panic from a paint callback.
video_frame_cache
wrap_text
wrap_text_with_fallback
Wrap text respecting emoji font fallback for accurate measurement.
wrap_text_with_tracking
Wrap text respecting emoji font fallback for accurate measurement, honouring letter_spacing in the fit test itself (issue #125).