Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ app's JSON control channel (`deckcraft --control PORT`).
| 2026-10-14 | Draw: pen pressure scales ink width when the pointer reports it (a mouse or a missing reading stays at the pen width; a stroke saved as a flat 0.5 still draws at the pen width). Tilt is not read |
| 2026-10-13 | Saving a presentation keeps the embedded workbook behind an unchanged chart, and the chart part's relationships (#335). Editing the chart drops that workbook instead of writing numbers that no longer match it |
| 2026-10-13 | A presentation whose object ids are used up refuses to grow instead of handing out duplicate ids (#407) |
| 2026-10-14 | Emoji fall back to the installed colour font and draw in colour (Apple Color Emoji on macOS, from its `sbix` PNG strikes) |
| 2026-10-13 | Slide transitions like PowerPoint: every transition and option measured frame by frame against PowerPoint's video export and retuned (curves, directions, soft edges, 3-D perspective, contents moving over backgrounds); PowerPoint's own XML elements and defaults read and written (diagonal Wipe, Zoom, Shape In/Out, Glitter Hexagons, Shred In/Out, Page Curl Single); `deckcraft-cli render-transition` renders frames headless |
| 2026-10-13 | Wild text cases measured against PowerPoint (102 synthetic slides): bidi by run language, East Asian vertical text upright, mongolianVert/wordArtVert/wordArtVertRtl, underline styles and strikethrough at the font's metrics, centre/right/decimal tabs, East Asian, Thai, Hindi, Arabic and Hebrew numbering, small caps, all-caps "ß", transparent text, soft hyphens, kinsoku, rtlCol and just/dist anchoring, emoji presentation, fallback faces that no longer move the baseline |
| 2026-10-13 | Render matches PowerPoint more closely on wild shape, picture and table cases: even-odd custom paths, dashes and caps, arrowheads, radial and path gradients, tile rects, rotWithShape, gradient lines, shadows cast by what is drawn (group and perspective too), group fill, picture borders, tiles, reflection, recolour (biLevel, alphaInv, brightness/contrast), table borders and grid default, 20+ preset shapes by their ECMA formulas, default miter joins, and approximate 3-D bevels, cameras and face lighting |
Expand Down
42 changes: 42 additions & 0 deletions crates/fonts/src/fontdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,11 @@ impl FontDb {
if MISSES.lock().unwrap_or_else(|e| e.into_inner()).get_or_insert_with(Default::default).contains(&c) {
return false;
}
// Named colour-emoji families first. Apple Color Emoji is one file of about 180 MB, over
// the general scan's cap, so a size-ordered walk never reaches it.
if self.load_named_emoji_font(c) {
return true;
}
let mut paths: Vec<std::path::PathBuf> = self.read_catalog().iter().map(|e| e.path.clone()).collect();
paths.sort();
paths.dedup();
Expand All @@ -1386,6 +1391,43 @@ impl FontDb {
false
}

/// Load a cataloged colour-emoji family that covers `c`. True when one was already loaded or
/// this call loaded it. Files larger than 256 MB are left unread.
#[cfg(not(target_arch = "wasm32"))]
fn load_named_emoji_font(&self, c: char) -> bool {
const MAX: u64 = 256 << 20;
let families: Vec<&str> = SYSTEM_FALLBACKS.iter().copied().filter(|f| f.to_ascii_lowercase().contains("emoji")).collect();
for fam in families {
let paths: Vec<std::path::PathBuf> = {
let cat = self.read_catalog();
let mut p: Vec<_> = cat.iter().filter(|e| e.family.eq_ignore_ascii_case(fam)).map(|e| e.path.clone()).collect();
p.sort();
p.dedup();
p
};
if paths.is_empty() {
continue;
}
if !self.is_loaded(fam) {
for p in &paths {
let len = std::fs::metadata(p).map(|m| m.len()).unwrap_or(u64::MAX);
if len > MAX {
continue;
}
if let Ok(data) = std::fs::read(p) {
self.add_font(data);
}
}
self.loaded_families.lock().unwrap_or_else(|e| e.into_inner()).insert(fam.to_lowercase());
}
let hit = self.read_faces().iter().any(|f| f.family.eq_ignore_ascii_case(fam) && f.is_color() && f.covers(c));
if hit {
return true;
}
}
false
}

/// Glyph outline in font units, y-down (flipped), cached per (face, glyph).
pub fn outline(&self, face: &FontFace, gid: u32) -> Arc<BezPath> {
let key = (face.id, gid);
Expand Down
13 changes: 13 additions & 0 deletions crates/fonts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,19 @@ mod tests {
}
}

#[test]
fn emoji_fall_back_to_apple_color_emoji_on_macos() {
// Apple Color Emoji is about 180 MB, over the general colour-font scan's cap. On macOS it
// is still the face a grinning face resolves to. Other platforms have no such file.
if !cfg!(target_os = "macos") || !std::path::Path::new("/System/Library/Fonts/Apple Color Emoji.ttc").is_file() {
return;
}
let face = FontDb::global().cascade(&['😀'], &[], "Regular");
assert!(face.is_color(), "emoji resolved to {}", face.family);
assert!(face.family.to_ascii_lowercase().contains("emoji"), "{}", face.family);
assert!(face.covers('😀'));
}

#[test]
fn colour_fonts_are_recognised() {
let db = FontDb::with_font_dirs(Vec::new());
Expand Down
111 changes: 111 additions & 0 deletions crates/render/src/bitmap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//! Embedded bitmap glyphs (`sbix` and `CBDT` PNG strikes).
//!
//! Apple Color Emoji stores each emoji as a PNG in an `sbix` strike. `COLR` painting does not
//! see those, so a colour face would otherwise fall through to its outline (often empty).

use std::collections::HashMap;
use std::sync::{Arc, Mutex};

use deckcraft_fonts::FontFace;
use kurbo::{Affine, Rect};
use skrifa::bitmap::{BitmapData, Origin};
use skrifa::instance::Size;
use skrifa::{GlyphId, MetadataProvider};
use vello_cpu::{RenderContext, peniko};

/// A decoded strike is reused: a slide show paints the same emoji every frame.
const CACHE_MAX: usize = 128;
/// One PNG larger than this is left undrawn (a hostile or corrupt strike).
const MAX_PNG: usize = 4 << 20;
const MAX_SIDE: u32 = 2048;

struct StrikePx {
pm: Arc<vello_cpu::Pixmap>,
/// Where the bitmap sits, in y-down font units, origin on the baseline.
dest: Rect,
}

static CACHE: Mutex<Option<HashMap<(u32, u32, u32, u32), StrikePx>>> = Mutex::new(None);

/// Paint `gid` of `face` from an embedded PNG strike. `at` maps the glyph origin (y down, points)
/// and `scale` is points per font unit. False when the glyph has no PNG strike, so the caller
/// draws the outline. Mask and raw BGRA strikes are not drawn.
pub(crate) fn paint(ctx: &mut RenderContext, face: &FontFace, gid: u32, at: Affine, scale: f64, alpha: f64) -> bool {
let ppem = scale * face.upem;
if !(ppem.is_finite() && ppem > 0.0 && ppem < 10_000.0) {
return false;
}
let Some(font) = face.skrifa() else { return false };
let Some(glyph) = font.bitmap_strikes().glyph_for_size(Size::new(ppem as f32), GlyphId::new(gid)) else {
return false;
};
let key = (face.id(), gid, glyph.ppem_x.to_bits(), glyph.ppem_y.to_bits());
let cached = CACHE.lock().unwrap_or_else(|e| e.into_inner()).as_ref().and_then(|c| c.get(&key).map(clone_strike));
let Some(strike) = cached.or_else(|| decode_strike(face, &glyph)) else { return false };
remember(key, &strike);
blit(ctx, &strike, at, scale, alpha);
true
}

fn clone_strike(s: &StrikePx) -> StrikePx {
StrikePx { pm: s.pm.clone(), dest: s.dest }
}

fn remember(key: (u32, u32, u32, u32), strike: &StrikePx) {
let mut guard = CACHE.lock().unwrap_or_else(|e| e.into_inner());
let cache = guard.get_or_insert_with(HashMap::new);
if cache.len() >= CACHE_MAX && !cache.contains_key(&key) {
cache.clear();
}
cache.entry(key).or_insert_with(|| clone_strike(strike));
}

fn decode_strike(face: &FontFace, glyph: &skrifa::bitmap::BitmapGlyph<'_>) -> Option<StrikePx> {
let BitmapData::Png(png) = &glyph.data else { return None };
if png.is_empty() || png.len() > MAX_PNG {
return None;
}
let rgba = image::load_from_memory(png).ok()?.into_rgba8();
let (w, h) = rgba.dimensions();
if w == 0 || h == 0 || w > MAX_SIDE || h > MAX_SIDE {
return None;
}
let pm = crate::images::premul_pixmap(&rgba)?;
let (ux, uy) = (face.upem / glyph.ppem_x as f64, face.upem / glyph.ppem_y as f64);
if !(ux.is_finite() && uy.is_finite() && ux > 0.0 && uy > 0.0) {
return None;
}
let (bw, bh) = (w as f64 * ux, h as f64 * uy);
// Same placement as Skia's fontations scaler (checked against CoreText): outer bearings are
// font units, inner bearings are pixels, and an `sbix` strike's origin is the PNG's bottom left.
let x0 = glyph.bearing_x as f64 + glyph.inner_bearing_x as f64 * ux;
let mut y0 = -(glyph.bearing_y as f64) - glyph.inner_bearing_y as f64 * uy;
if glyph.placement_origin == Origin::BottomLeft {
y0 -= bh;
}
let dest = Rect::new(x0, y0, x0 + bw, y0 + bh);
if !(dest.width().is_finite() && dest.height().is_finite() && dest.width() > 0.0 && dest.height() > 0.0) {
return None;
}
Some(StrikePx { pm, dest })
}

fn blit(ctx: &mut RenderContext, strike: &StrikePx, at: Affine, scale: f64, alpha: f64) {
let (iw, ih) = (strike.pm.width() as f64, strike.pm.height() as f64);
let image = vello_cpu::Image {
image: vello_cpu::ImageSource::Pixmap(strike.pm.clone()),
sampler: peniko::ImageSampler { quality: peniko::ImageQuality::High, ..Default::default() },
};
let m = at * Affine::scale(scale);
let t = m * Affine::translate(strike.dest.origin().to_vec2()) * Affine::scale_non_uniform(strike.dest.width() / iw, strike.dest.height() / ih);
ctx.set_transform(t);
let a = alpha.clamp(0.0, 1.0);
if a < 0.999 {
ctx.push_layer(None, None, Some(a as f32), None, None);
}
ctx.set_paint(image);
ctx.fill_rect(&Rect::new(0.0, 0.0, iw, ih));
if a < 0.999 {
ctx.pop_layer();
}
}
6 changes: 3 additions & 3 deletions crates/render/src/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ pub fn decode_for(bytes: &Arc<Vec<u8>>, want: f64, adj: &PictureAdjust) -> Optio
}
apply_adjust(&mut img, adj);
let (w, h) = img.dimensions();
let pm = pixmap(&img)?;
let pm = premul_pixmap(&img)?;
with(|c| {
c.clock += 1;
let n = w as usize * h as usize * 4;
Expand All @@ -366,7 +366,7 @@ pub fn decode_for(bytes: &Arc<Vec<u8>>, want: f64, adj: &PictureAdjust) -> Optio
}

/// Straight RGBA to a premultiplied pixmap.
fn pixmap(img: &image::RgbaImage) -> Option<Arc<Pixmap>> {
pub(crate) fn premul_pixmap(img: &image::RgbaImage) -> Option<Arc<Pixmap>> {
let (w, h) = img.dimensions();
if w > u16::MAX as u32 || h > u16::MAX as u32 {
return None;
Expand Down Expand Up @@ -410,7 +410,7 @@ fn decode_anim(bytes: &[u8], adj: &PictureAdjust) -> Option<Anim> {
img = image::imageops::resize(&img, nw, nh, image::imageops::FilterType::Triangle);
}
apply_adjust(&mut img, adj);
frames.push(pixmap(&img)?);
frames.push(premul_pixmap(&img)?);
ends.push(t);
}
(frames.len() > 1).then_some(Anim { frames, ends })
Expand Down
8 changes: 6 additions & 2 deletions crates/render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![forbid(unsafe_code)]

mod bevel;
mod bitmap;
mod camera;
mod chart;
mod chartex;
Expand Down Expand Up @@ -2264,8 +2265,11 @@ fn draw_glyph_with(
let k = run.size / run.face.upem.max(1.0);
// Colour glyphs (emoji) paint their own colours; an outline (text outline effect) still
// strokes the plain glyph below.
if alpha > 0.0 && run.outline.is_none() && run.face.is_color() && colr::paint(ctx, &run.face, gid, at, k, run.color, alpha) {
return;
if alpha > 0.0 && run.outline.is_none() && run.face.is_color() {
// COLR layers, then an embedded bitmap (Apple Color Emoji is `sbix` PNGs, not COLR).
if colr::paint(ctx, &run.face, gid, at, k, run.color, alpha) || bitmap::paint(ctx, &run.face, gid, at, k, alpha) {
return;
}
}
let path = glyph(&run.face, gid);
if path.elements().is_empty() {
Expand Down
34 changes: 34 additions & 0 deletions crates/render/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,40 @@ fn colour_glyphs_paint_their_layers() {
assert!((green as f64 / (red + blue) as f64 - 1.0).abs() < 0.1, "green {green} vs {}", red + blue);
}

#[test]
fn emoji_draw_their_colour_bitmap() {
// A grinning face is yellow. Without the `sbix` PNG strike it would be an empty outline
// (Apple Color Emoji has almost no contours). Skipped where that font is not installed.
if !cfg!(target_os = "macos") || !std::path::Path::new("/System/Library/Fonts/Apple Color Emoji.ttc").is_file() {
return;
}
let mut sh = Shape { id: ShapeId(721), xfrm: Some(Xfrm::new(0.0, 0.0, 400.0, 200.0)), text_box: true, ..Default::default() };
let mut t = TextBody::from_text("😀");
t.paragraphs[0].runs[0].props.size = Some(72.0);
sh.text = Some(t);
let p = deck_with(vec![sh]);
let img = render_slide(&p, 0, &RenderOpts { scale: 2.0, ..Default::default() });
let yellow = |px: &[u8; 4]| px[0] > 200 && px[1] > 160 && px[2] < 120 && px[0] > px[2] + 60 && px[1] > px[2] + 40;
let mut n = 0u32;
let mut bbox: Option<(u32, u32, u32, u32)> = None;
for y in 0..img.height {
for x in 0..img.width {
if yellow(&img.pixel(x, y)) {
n += 1;
bbox = Some(match bbox {
Some((x0, y0, x1, y1)) => (x0.min(x), y0.min(y), x1.max(x), y1.max(y)),
None => (x, y, x, y),
});
}
}
}
let (x0, y0, x1, y1) = bbox.unwrap_or((0, 0, 0, 0));
// 72 pt at 2× is about 144 px. The face sits in the text box, not under the baseline.
assert!(n > 2000, "yellow pixels {n} bbox {x0},{y0}-{x1},{y1}");
assert!(x1 - x0 > 80 && y1 - y0 > 80, "bbox {x0},{y0}-{x1},{y1}");
assert!(y0 < 80 && y1 < 400 && x0 < 80, "emoji placed at {x0},{y0}-{x1},{y1}");
}

#[test]
fn a_text_gradient_starts_over_on_every_line() {
// PowerPoint fills each line of gradient text with the whole gradient, spanning that line
Expand Down
2 changes: 2 additions & 0 deletions docs/hardware-parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ because it mostly follows from hardware use.
| Transitions and Morph frames | GPU | CPU-rendered slide images composited as textured quads on the GPU | same | same | same |
| Picture export resolution | 2 px per point, tagged so the file is the slide's size | PNG `pHYs` and JPEG density, 144 dpi at the default 2 px per point | same | same | same |
| High-DPI / Retina | yes | yes; editor slide rasters sit on the physical pixel grid (#184) | yes | yes | yes |
| Colour emoji | the system colour-emoji font | Apple Color Emoji (`sbix` PNGs) when that font is installed | a catalogued colour-emoji family when installed | same | only a colour font the page loaded |
| Wide gamut / HDR display | partly (P3 images) | no (sRGB) | no | no | no |
| Startup on all GPUs | yes | yes | **no**: crashes in some Intel/AMD drivers (#40, #59) | not reported | n/a |
| Software fallback when no GPU | yes (WARP on Windows) | no | no | no | no |
Expand Down Expand Up @@ -79,5 +80,6 @@ outlines every frame (#67, fix open), and the decoders run in software.
| 2026-10-14 | minor | A two-finger twist on the trackpad rotates the selected shapes, as one undo step. Pinch-zoom is unchanged |
| 2026-10-14 | minor | A sideways trackpad swipe turns the page in Normal view (when the slide fits) and in the show. Pinch-zoom is unchanged |
| 2026-10-14 | minor | Pen pressure scales ink width; tilt, pinch zoom and trackpad gestures remain (estimate 3–6 h → 2–5 h) |
| 2026-10-14 | minor | Colour emoji draw from the installed colour font (Apple Color Emoji on macOS) |
| 2026-10-12 | minor | IME input methods (#101) |
| 2026-10-10 | major | Created: rendering, media, displays, input and performance against PowerPoint 16.113 |
Loading