Compare commits

...
Author SHA1 Message Date
Brandon ThomasandClaude Opus 5.5 670befa919 Text: symbol-font characters draw in the run's a:sym font
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 23:50:15 -04:00
Brandon ThomasandClaude Opus 5.5 a68da9f51d Effects: fill overlays (a:fillOverlay) blend over the shape's fill, and round-trip (#342)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 23:50:02 -04:00
Brandon ThomasandClaude Opus 5.5 cdfaaf4a38 Docs: text in scaled groups is drawn (#340) (#341)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 23:28:37 -04:00
Brandon ThomasandClaude Opus 5.5 10d3333344 Render: text in a scaled group keeps its point size, as in PowerPoint (#340)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 23:27:47 -04:00
Brandon ThomasandClaude Opus 5.5 bb6f0dc88a Render: pictures cast their shadow from their pixels, as in PowerPoint (#338)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 22:46:32 -04:00
NetterSilver c4f355773d Docs: update the progress docs for this change 2026-10-12 22:44:18 -04:00
NetterSilver d4bc8812a3 Credit Silvertree2010 in the About window 2026-10-12 22:44:18 -04:00
NetterSilver dc8a884389 Render: a group's child-coordinate scale no longer scales line widths (#233)
Outlines, dashes, arrowheads and ink strokes were drawn under the full
transform, including the mapping of the group's child coordinate space onto its
box. A group whose children use small legacy child coordinates (scale ~1600)
therefore stroked 0.75 pt lines about 1200 pt wide and covered the slide. Inside
a group the outline is now carried through that mapping and stroked under the
slide-level view, so the line width, dash lengths and arrowhead sizes stay in
points, also for groups scaled unevenly.
2026-10-12 22:44:18 -04:00
12 changed files with 442 additions and 51 deletions
+2
View File
@@ -134,6 +134,7 @@ app's JSON control channel (`deckcraft --control PORT`).
| 2026-10-12 | Text keys like PowerPoint for Windows (#268): Ctrl+arrows and Ctrl+Shift+arrows by word (punctuation, CJK, emoji, RTL), Ctrl+Backspace/Delete with smart spacing, Ctrl+Up/Down by paragraph, Ctrl+Home/End, End on wrapped lines, Ctrl+]/[ and Ctrl+Shift+>/< font size, Shift+F3 case cycle, word and paragraph selection |
| 2026-10-12 | EMF/WMF pictures draw their text (fonts, alignment, dx advances, escapement, symbol fonts), pattern and hatch brushes, PATBLT and the XOR/AND see-through shadow; legacy OLE objects show their VML preview and ActiveX controls their pictures |
| 2026-10-12 | WordArt text warps (`prstTxWarp`): all 40 presets drawn, curves fitted to PowerPoint by observation; warp adjusts round-trip |
| 2026-10-12 | Render: line widths, dashes and arrowheads inside a group no longer scale with the group's child-coordinate mapping, so a group in a small legacy child space (scale about 1600) draws thin lines instead of covering the slide (#233) |
| 2026-10-10 | Progress docs restructured to the craftrules standard; full re-measure (breadth 79%, ready ~55%, mainstream ~53%, essentials ~62%, alpha). Landed: Animation Painter (#54), Morph geometry outlines (#27), animated GIF playback (#39), hyperlink colour and following links in the show (#37, #45), date fields in their own format (#36), flipped shapes keep readable text (#35), show transition fix (#46), start screen from the Home button (#49), MCP export lists PDF (#65), OmaStore manifest (#57) |
| 2026-10-09 | v0.4.0 released. UAX #9 bidi and Arabic shaping (#4), Morph with Words and Characters (#5), tables grow to fit and PDF cell text (#14), rotating log file (#7), DX12 default on Windows (#16), H.264/HEVC overflow hardening (#2), PPTX sniffing anywhere in the zip (#19) |
| 2026-10-08 | v0.2.0 and v0.3.0 released: Windows arm64, Flatpak aarch64, AppImage zsync updates, branded DMG |
@@ -145,6 +146,7 @@ app's JSON control channel (`deckcraft --control PORT`).
| Date | Change | Summary |
|---|---|---|
| 2026-10-12 | trivial | Progress log: lines in scaled groups (#233) |
| 2026-10-10 | minor | Readiness-by-audience table with hours to ~95% for full, mainstream and essentials |
| 2026-10-10 | minor | Added mainstream practitioner (~53%) and essentials user (~62%); features recomputed from written area weights, ready ~56% → ~55% |
| 2026-10-10 | minor | Stage checked against the new core-workflow gate: passes, stays alpha |
+4
View File
@@ -37,3 +37,7 @@ sync_github_name = false
[people.Johannesgauss]
sync_github_name = true
[people.Silvertree2010]
display_name = "Netter"
sync_github_name = false
+11
View File
@@ -387,6 +387,16 @@ pub struct Effects {
pub bevel: Option<String>,
/// Unmodelled 3-D XML kept for round-trip (`scene3d`, `sp3d`).
pub raw3d: Option<String>,
/// `a:fillOverlay`: a fill blended over the shape's fill (`blend`: `over`, `mult`, `screen`,
/// `darken`, `lighten`). Only solid and gradient overlays are kept.
pub fill_overlay: Option<FillOverlay>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FillOverlay {
pub blend: String,
pub fill: Fill,
}
impl Effects {
@@ -397,6 +407,7 @@ impl Effects {
&& self.soft_edge.is_none()
&& self.reflection.is_none()
&& self.bevel.is_none()
&& self.fill_overlay.is_none()
}
}
+8
View File
@@ -257,6 +257,14 @@ pub fn effects(el: &El) -> Effects {
"innerShdw" => fx.inner_shadow = Some(shadow(e, true)),
"glow" => fx.glow = Some(Glow { color: color(e).unwrap_or(ColorRef::rgb(Rgba::BLACK)), radius: pt(e, "rad").unwrap_or(0.0).max(0.0) }),
"softEdge" => fx.soft_edge = Some(pt(e, "rad").unwrap_or(0.0).max(0.0)),
"fillOverlay" => {
let fill = e.elements().find_map(|f| match f.local() {
"solidFill" => color(f).map(|c| Fill::Solid { color: c }),
"gradFill" => Some(Fill::Gradient(gradient(f))),
_ => None,
});
fx.fill_overlay = fill.map(|fill| deckcraft_model::style::FillOverlay { blend: e.attr("blend").unwrap_or("over").to_string(), fill });
}
"reflection" => {
fx.reflection = Some(Reflection {
blur: pt(e, "blurRad").unwrap_or(0.0),
+48 -34
View File
@@ -76,40 +76,7 @@ pub fn fill(w: &mut W, x: &mut Exp, o: &mut Out, f: &Fill) {
match f {
Fill::None => w.empty0("a:noFill"),
Fill::Solid { color: c } => solid(w, c),
Fill::Gradient(g) => {
w.open("a:gradFill", A::new().a("rotWithShape", if g.rotate_with_shape { "1" } else { "0" }));
// No stops: no `a:gsLst`, so the gradient keeps taking them from its style's fill.
let mut stops = g.stops.clone();
if stops.len() == 1 {
let mut s = stops[0].clone();
s.pos = 1.0;
stops.push(s);
}
if !stops.is_empty() {
w.open0("a:gsLst");
for s in &stops {
w.open("a:gs", A::new().a("pos", pct(s.pos.clamp(0.0, 1.0))));
color(w, &s.color);
w.close("a:gs");
}
w.close("a:gsLst");
}
match &g.shape {
GradientShape::Linear { angle, scaled } => {
w.empty("a:lin", A::new().a("ang", ang(*angle)).a("scaled", if *scaled { "1" } else { "0" }))
}
GradientShape::Path { path, focus } => {
let p = match path.as_str() {
"rect" | "shape" | "circle" => path.as_str(),
_ => "circle",
};
w.open("a:path", A::new().a("path", p));
w.empty("a:fillToRect", A::new().a("l", pct(focus[0])).a("t", pct(focus[1])).a("r", pct(focus[2])).a("b", pct(focus[3])));
w.close("a:path");
}
}
w.close("a:gradFill");
}
Fill::Gradient(g) => gradient(w, g),
Fill::Picture(pf) => blip_fill(w, x, o, "a:blipFill", pf),
Fill::Pattern(p) => {
w.open("a:pattFill", A::new().a("prst", if p.preset.is_empty() { "pct5" } else { &p.preset }));
@@ -275,8 +242,55 @@ fn shadow(w: &mut W, tag: &str, s: &deckcraft_model::style::Shadow) {
w.close(tag);
}
fn gradient(w: &mut W, g: &deckcraft_model::style::Gradient) {
w.open("a:gradFill", A::new().a("rotWithShape", if g.rotate_with_shape { "1" } else { "0" }));
// No stops: no `a:gsLst`, so the gradient keeps taking them from its style's fill.
let mut stops = g.stops.clone();
if stops.len() == 1 {
let mut s = stops[0].clone();
s.pos = 1.0;
stops.push(s);
}
if !stops.is_empty() {
w.open0("a:gsLst");
for s in &stops {
w.open("a:gs", A::new().a("pos", pct(s.pos.clamp(0.0, 1.0))));
color(w, &s.color);
w.close("a:gs");
}
w.close("a:gsLst");
}
match &g.shape {
GradientShape::Linear { angle, scaled } => w.empty("a:lin", A::new().a("ang", ang(*angle)).a("scaled", if *scaled { "1" } else { "0" })),
GradientShape::Path { path, focus } => {
let p = match path.as_str() {
"rect" | "shape" | "circle" => path.as_str(),
_ => "circle",
};
w.open("a:path", A::new().a("path", p));
w.empty("a:fillToRect", A::new().a("l", pct(focus[0])).a("t", pct(focus[1])).a("r", pct(focus[2])).a("b", pct(focus[3])));
w.close("a:path");
}
}
w.close("a:gradFill");
}
pub fn effects(w: &mut W, fx: &Effects) {
w.open0("a:effectLst");
// Schema order: blur, fillOverlay, glow, innerShdw, outerShdw, prstShdw, reflection, softEdge.
if let Some(ov) = &fx.fill_overlay {
let blend = match ov.blend.as_str() {
b @ ("over" | "mult" | "screen" | "darken" | "lighten") => b,
_ => "over",
};
w.open("a:fillOverlay", A::new().a("blend", blend));
match &ov.fill {
Fill::Solid { color: c } => solid(w, c),
Fill::Gradient(g) => gradient(w, g),
_ => w.empty0("a:noFill"),
}
w.close("a:fillOverlay");
}
if let Some(g) = &fx.glow {
w.open("a:glow", A::new().a("rad", emu(g.radius).max(0)));
color(w, &g.color);
+31
View File
@@ -102,3 +102,34 @@ fn a_gradient_without_stops_is_saved_without_stops() {
let s = q.slides[0].shapes.iter().find(|s| s.name == "Styled").expect("shape");
assert_eq!(s.fill, Some(Fill::Gradient(own)));
}
#[test]
fn a_fill_overlay_round_trips() {
use deckcraft_model::style::{FillOverlay, Gradient, GradientShape, GradientStop};
let mut p = defaults::new_presentation(None);
let id = ShapeId(p.alloc_id());
let first = p.slides[0].id;
let overlay = FillOverlay {
blend: "mult".into(),
fill: Fill::Gradient(Gradient {
stops: vec![
GradientStop { pos: 0.0, color: deckcraft_model::ColorRef::scheme(deckcraft_color::SchemeSlot::Accent1) },
GradientStop { pos: 1.0, color: deckcraft_model::ColorRef::rgb(deckcraft_color::Rgba::rgb(10, 20, 30)) },
],
shape: GradientShape::Linear { angle: 4.5, scaled: true },
rotate_with_shape: true,
}),
};
p.slide_mut(first).expect("slide").shapes.push(Shape {
id,
name: "Overlaid".into(),
xfrm: Some(Xfrm::new(10.0, 10.0, 200.0, 100.0)),
fill: Some(Fill::solid(deckcraft_model::ColorRef::rgb(deckcraft_color::Rgba::WHITE))),
effects: Some(deckcraft_model::Effects { fill_overlay: Some(overlay.clone()), ..Default::default() }),
..Default::default()
});
let bytes = deckcraft_pptx::export(&p).expect("export");
let q = deckcraft_pptx::import(&bytes).expect("import");
let s = q.slides[0].shapes.iter().find(|s| s.name == "Overlaid").expect("shape");
assert_eq!(s.effects.as_ref().and_then(|e| e.fill_overlay.clone()), Some(overlay));
}
+126 -10
View File
@@ -238,11 +238,14 @@ pub struct Renderer {
/// What the frame being drawn has painted so far, in output pixels: the editor learns from it
/// how far a slide's drawing (text spilling out of its box too) reaches off the slide.
drawn: Option<Rect>,
/// The transform a top-level shape is drawn under (slide to pixels); a group's children draw
/// under it combined with the group's child-coordinate mapping, which must not scale lines.
view: Affine,
}
impl Default for Renderer {
fn default() -> Self {
Renderer { resources: Resources::new(), paths: Vec::new(), bg: None, drawn: None }
Renderer { resources: Resources::new(), paths: Vec::new(), bg: None, drawn: None, view: Affine::IDENTITY }
}
}
@@ -660,6 +663,43 @@ impl Renderer {
}
fn shape(&mut self, ctx: &mut RenderContext, f: &Frame, rctx: &Ctx, s: &Shape, parent: Affine, depth: usize) {
if depth == 0 {
let outer = std::mem::replace(&mut self.view, parent);
self.shape_at(ctx, f, rctx, s, parent, depth);
self.view = outer;
} else {
self.shape_at(ctx, f, rctx, s, parent, depth);
}
}
/// How lines are drawn for a shape under `m` at `depth`: the transform to stroke under and the
/// one that takes the shape's outline into it. Inside a group they are the slide-level view and
/// the rest of the chain, so the group's child-coordinate scale moves and sizes the outline but
/// never the line width; outside a group, `m` itself and no change to the outline.
fn line_space(&self, m: Affine, depth: usize) -> (Affine, Affine) {
let view = self.view;
if depth > 0 && view.determinant().abs() > 1e-12 && view.is_finite() { (view, view.inverse() * m) } else { (m, Affine::IDENTITY) }
}
/// The size and transform a shape's text is set in: inside a group whose child coordinates
/// scale the shape, the shape's size in slide points and `m` with that scale taken out, so
/// insets and font sizes stay in points; otherwise `w`, `h` and `m` themselves.
fn text_space(&self, m: Affine, depth: usize, w: f64, h: f64) -> (f64, f64, Affine) {
let (_, rel) = self.line_space(m, depth);
let c = rel.as_coeffs();
let (sx, sy) = (c[0].hypot(c[1]), c[2].hypot(c[3]));
let ok = |k: f64| k.is_finite() && k > 1e-9;
if depth == 0 || !ok(sx) || !ok(sy) || ((sx - 1.0).abs() < 1e-9 && (sy - 1.0).abs() < 1e-9) {
return (w, h, m);
}
let (tw, th) = (w * sx, h * sy);
if !tw.is_finite() || !th.is_finite() {
return (w, h, m);
}
(tw, th, m * Affine::scale_non_uniform(1.0 / sx, 1.0 / sy))
}
fn shape_at(&mut self, ctx: &mut RenderContext, f: &Frame, rctx: &Ctx, s: &Shape, parent: Affine, depth: usize) {
if depth > 32 || (s.hidden && !f.opts.show_hidden) || f.opts.skip.contains(&s.id) {
return;
}
@@ -718,20 +758,34 @@ impl Renderer {
bp.line_to((*px, *py));
}
}
ctx.set_transform(parent);
let (base, rel) = self.line_space(parent, depth);
bp.apply_affine(rel);
ctx.set_transform(base);
ctx.set_paint(color(sk.color, if sk.highlighter { 0.4 } else { 1.0 }));
ctx.set_stroke(kurbo::Stroke::new(sk.width.max(0.1)).with_caps(kurbo::Cap::Round).with_join(kurbo::Join::Round));
ctx.stroke_path(&bp);
}
}
_ => self.geometry_shape(ctx, f, rctx, s, m, x.w, x.h, &st),
_ => self.geometry_shape(ctx, f, rctx, s, m, x.w, x.h, &st, depth),
}
if layered {
ctx.pop_layer();
}
}
fn geometry_shape(&mut self, ctx: &mut RenderContext, f: &Frame, rctx: &Ctx, s: &Shape, m: Affine, w: f64, h: f64, st: &ShapeState) {
#[allow(clippy::too_many_arguments)]
fn geometry_shape(
&mut self,
ctx: &mut RenderContext,
f: &Frame,
rctx: &Ctx,
s: &Shape,
m: Affine,
w: f64,
h: f64,
st: &ShapeState,
depth: usize,
) {
let (geo, fades) = match self.paths.iter().find(|p| p.id == s.id) {
Some(pm) => morph_path::geometry(pm, s, w, h),
None => (shape_geometry(s, w, h), Vec::new()),
@@ -749,7 +803,12 @@ impl Renderer {
let fill = if let Some(t) = st.tint { Some(Fill::solid(deckcraft_model::ColorRef::rgb(t))) } else { fill };
// Effects below the shape.
if let Some(e) = &effects {
self.effects_below(ctx, rctx, e, fx_ph, &geo, &fill, m, w, h);
// A picture (or picture fill) casts its shadow from its pixels, not its frame.
let content = match (&s.kind, &fill) {
(ShapeKind::Picture { fill: pf }, _) | (_, Some(Fill::Picture(pf))) => Some(paint::resolved(rctx, pf, None).into_owned()),
_ => None,
};
self.effects_below(ctx, rctx, e, fx_ph, &geo, &fill, content.as_ref(), m, w, h);
}
let soft = effects.as_ref().and_then(|e| e.soft_edge).filter(|r| *r > 0.0);
if let Some(r) = soft {
@@ -813,14 +872,41 @@ impl Renderer {
}
}
}
// `a:fillOverlay`: a fill blended over the shape's fill (PowerPoint's "Flow" themes multiply
// a gradient over a tiled picture), inside the filled outline, under the line.
if let Some(ov) = effects.as_ref().and_then(|e| e.fill_overlay.as_ref())
&& fill.as_ref().is_some_and(|f| !f.is_none())
{
let mix = match ov.blend.as_str() {
"mult" => peniko::Mix::Multiply,
"screen" => peniko::Mix::Screen,
"darken" => peniko::Mix::Darken,
"lighten" => peniko::Mix::Lighten,
_ => peniko::Mix::Normal,
};
for (i, sp) in geo.paths.iter().enumerate().filter(|(i, sp)| sp.fill != FillMode::None && fade(*i).fill > 0.0) {
ctx.set_transform(m);
ctx.push_layer(Some(&sp.path), Some(peniko::BlendMode::new(mix, peniko::Compose::SrcOver)), None, None, None);
paint::fill_path(ctx, rctx, &ov.fill, fx_ph, &sp.path, Rect::new(0.0, 0.0, w, h), m, FillMode::Norm, fade(i).fill, f.pres);
ctx.pop_layer();
}
}
// Outline.
if line.fill.as_ref().is_some_and(|f| !f.is_none()) {
let lw = line.width.unwrap_or(0.75).max(0.0);
let (base, rel) = self.line_space(m, depth);
for (i, sp) in geo.paths.iter().enumerate().filter(|(i, p)| p.stroke && fade(*i).stroke > 0.0) {
stroke(ctx, rctx, &line, line_ph, &sp.path, m, lw, fade(i).stroke);
let path = if rel == Affine::IDENTITY {
std::borrow::Cow::Borrowed(&sp.path)
} else {
let mut moved = sp.path.clone();
moved.apply_affine(rel);
std::borrow::Cow::Owned(moved)
};
stroke(ctx, rctx, &line, line_ph, &path, base, lw, fade(i).stroke);
}
if s.is_line() || geo.is_open() {
arrowheads(ctx, rctx, &line, line_ph, &geo, m, lw);
arrowheads(ctx, rctx, &line, line_ph, &geo, rel, base, lw);
}
}
if let Some(r) = soft {
@@ -872,6 +958,16 @@ impl Renderer {
if let Some(body) = &s.text
&& !skip_text
{
// Text in a group is set at the shape's size on the slide, in points: a group's
// child-coordinate scale sizes and places the box, never the type (#233's twin).
let (tw, th, m) = self.text_space(m, depth, w, h);
let text_geo;
let geo = if (tw, th) == (w, h) {
&geo
} else {
text_geo = shape_geometry(s, tw, th);
&text_geo
};
let tr = geo.text_rect;
if !body.is_empty() {
let l = deckcraft_text::layout(rctx, s, body, &Opts { rect: tr, fields: &f.fields, prompt_color: None, no_shrink: false });
@@ -915,6 +1011,7 @@ impl Renderer {
ph: Option<Rgba>,
geo: &Geometry,
fill: &Option<Fill>,
content: Option<&deckcraft_model::style::PictureFill>,
m: Affine,
w: f64,
h: f64,
@@ -942,8 +1039,24 @@ impl Renderer {
// Blurred by a third of the blur radius, as PowerPoint's export shows.
ctx.push_layer(None, None, Some((c.a as f32) / 255.0), None, Some(blur(sh.blur / 3.0 * k)));
ctx.set_transform(sm);
ctx.set_paint(color(c.with_alpha(255), 1.0));
ctx.fill_path(&silhouette);
match content {
// As PowerPoint draws it: the shadow is the picture's own coverage (a logo on a
// transparent background casts the logo's shadow): the picture, clipped to the
// shape, recoloured to the shadow colour.
Some(pf) => {
ctx.push_clip_layer(&silhouette);
paint::picture(ctx, rctx.pres, pf, Rect::new(0.0, 0.0, w, h), sm, None);
ctx.push_layer(None, Some(peniko::BlendMode::new(peniko::Mix::Normal, peniko::Compose::SrcIn)), None, None, None);
ctx.set_paint(color(c.with_alpha(255), 1.0));
ctx.fill_rect(&Rect::new(0.0, 0.0, w, h).inflate(1.0, 1.0));
ctx.pop_layer();
ctx.pop_layer();
}
None => {
ctx.set_paint(color(c.with_alpha(255), 1.0));
ctx.fill_path(&silhouette);
}
}
ctx.pop_layer();
}
if let Some(g) = &e.glow {
@@ -1069,9 +1182,12 @@ fn end_points(path: &BezPath) -> Option<((Point, Point), (Point, Point))> {
Some(((first, second), (last, prev)))
}
fn arrowheads(ctx: &mut RenderContext, rctx: &Ctx, line: &Line, ph: Option<Rgba>, geo: &Geometry, m: Affine, lw: f64) {
#[allow(clippy::too_many_arguments)]
fn arrowheads(ctx: &mut RenderContext, rctx: &Ctx, line: &Line, ph: Option<Rgba>, geo: &Geometry, rel: Affine, m: Affine, lw: f64) {
let Some(sp) = geo.paths.iter().find(|p| p.stroke) else { return };
let Some(((a, a2), (b, b2))) = end_points(&sp.path) else { return };
// The outline's ends in the space the arrowheads are sized and drawn in.
let (a, a2, b, b2) = (rel * a, rel * a2, rel * b, rel * b2);
let col = match &line.fill {
Some(Fill::Solid { color: c }) => rctx.color(c, ph),
_ => Rgba::BLACK,
+171
View File
@@ -1443,3 +1443,174 @@ fn metafile_pattern_brush_tiles_and_averages_when_tiny() {
let p = img.get_pixel(16, 16);
assert!((100..156).contains(&p[0]) && p[3] > 200, "average grey: {p:?}");
}
/// A 400 x 200 group at (100, 100) holding a dashed 4 pt rectangle and a 3 pt line with an
/// arrowhead, placed in the group's child coordinates by `to_child` (slide point to child point).
fn outlined_group(child: Xfrm, to_child: impl Fn(f64, f64) -> (f64, f64)) -> Image {
use deckcraft_model::style::{Dash, LineEnd};
let ink = |w: f64| deckcraft_model::style::Line { dash: None, ..deckcraft_model::style::Line::solid(ColorRef::rgb(Rgba::rgb(200, 0, 0)), w) };
let place = |x0: f64, y0: f64, x1: f64, y1: f64| {
let ((a, b), (c, d)) = (to_child(x0, y0), to_child(x1, y1));
Xfrm::new(a, b, c - a, d - b)
};
let rect = Shape {
id: ShapeId(11),
xfrm: Some(place(140.0, 120.0, 300.0, 200.0)),
geom: Geom::preset("rect"),
line: Some(deckcraft_model::style::Line { dash: Some(Dash::Preset { name: "dash".into() }), ..ink(4.0) }),
..Default::default()
};
let end = LineEnd { kind: "triangle".into(), w: "lg".into(), len: "lg".into() };
let line = Shape {
id: ShapeId(12),
xfrm: Some(Xfrm { flip_v: true, ..place(150.0, 170.0, 450.0, 260.0) }),
geom: Geom::preset("line"),
line: Some(deckcraft_model::style::Line { tail: Some(end), ..ink(3.0) }),
..Default::default()
};
let pts: Vec<(f64, f64, f32)> = [(160.0, 240.0), (260.0, 285.0)].iter().map(|(x, y)| to_child(*x, *y)).map(|(x, y)| (x, y, 1.0)).collect();
let ink = Shape {
id: ShapeId(13),
xfrm: Some(place(100.0, 100.0, 500.0, 300.0)),
kind: ShapeKind::Ink {
strokes: vec![deckcraft_model::InkStroke { points: pts, color: Rgba::rgb(200, 0, 0), width: 5.0, highlighter: false }],
},
..Default::default()
};
let group = Shape {
id: ShapeId(10),
xfrm: Some(Xfrm::new(100.0, 100.0, 400.0, 200.0)),
kind: ShapeKind::Group { children: vec![rect, line, ink], child },
..Default::default()
};
render_slide(&deck_with(vec![group]), 0, &RenderOpts { scale: 1.0, ..Default::default() })
}
fn inked(img: &Image) -> usize {
img.pixels.as_chunks::<4>().0.iter().filter(|px| px[1] < 200).count()
}
#[test]
fn group_child_scale_does_not_scale_line_widths() {
// Children laid out 1:1 with the slide are the reference.
let reference = outlined_group(Xfrm::new(100.0, 100.0, 400.0, 200.0), |x, y| (x, y));
let drawn = inked(&reference);
assert!((500..20_000).contains(&drawn), "the reference draws thin lines: {drawn}");
// The same drawing in a small legacy child space (scale 100), and one scaled unevenly
// (100 across, 50 down): same outlines, same line widths, dashes and arrowhead.
let uniform = outlined_group(Xfrm::new(1.0, 1.0, 4.0, 2.0), |x, y| (1.0 + (x - 100.0) / 100.0, 1.0 + (y - 100.0) / 100.0));
let uneven = outlined_group(Xfrm::new(1.0, 1.0, 4.0, 4.0), |x, y| (1.0 + (x - 100.0) / 100.0, 1.0 + (y - 100.0) / 50.0));
for (name, img) in [("uniform", &uniform), ("uneven", &uneven)] {
let (n, d) = (inked(img), differing(&reference, img));
assert!(n.abs_diff(drawn) * 20 < drawn, "{name}: {n} inked pixels against {drawn}");
assert!(d * 20 < drawn, "{name}: {d} differing values against {drawn} inked pixels");
}
}
#[test]
fn a_picture_casts_its_shadow_from_its_pixels() {
// PowerPoint shades only where a picture paints: a logo on a transparent background casts the
// logo's shadow, not its frame's. Here the left half of the image is transparent.
let png = {
let img = image::RgbaImage::from_fn(8, 4, |x, _| if x < 4 { image::Rgba([0, 0, 0, 0]) } else { image::Rgba([20, 160, 20, 255]) });
let mut out = std::io::Cursor::new(vec![]);
image::DynamicImage::ImageRgba8(img).write_to(&mut out, image::ImageFormat::Png).unwrap();
out.into_inner()
};
let shadow = deckcraft_model::style::Shadow {
color: ColorRef::rgb(deckcraft_color::Rgba::BLACK),
blur: 0.0,
dist: 20.0,
dir: 90.0,
inner: false,
sx: 1.0,
sy: 1.0,
kx: 0.0,
ky: 0.0,
align: String::new(),
rotate_with_shape: false,
};
for as_fill in [false, true] {
let mut p = Presentation::default();
let media = p.add_media("logo.png", "image/png", png.clone());
let pf = deckcraft_model::style::PictureFill { media, ..Default::default() };
let mut sh = Shape { id: ShapeId(600), xfrm: Some(Xfrm::new(100.0, 100.0, 400.0, 200.0)), ..Default::default() };
if as_fill {
sh.fill = Some(Fill::Picture(pf));
sh.line = Some(deckcraft_model::style::Line { fill: Some(Fill::None), ..Default::default() });
} else {
sh.kind = ShapeKind::Picture { fill: pf };
}
sh.effects = Some(deckcraft_model::Effects { outer_shadow: Some(shadow.clone()), ..Default::default() });
std::sync::Arc::make_mut(&mut p.slides[0]).shapes = vec![sh];
let img = render_slide(&p, 0, &RenderOpts { scale: 1.0, ..Default::default() });
// Below the picture, 10 pt down: shadow under the opaque right half only.
let left = img.pixel(200, 310);
let right = img.pixel(400, 310);
assert!(left[0] > 240, "no shadow under the transparent half ({as_fill}): {left:?}");
assert!(right[0] < 40, "shadow under the opaque half ({as_fill}): {right:?}");
// The transparent half shows the slide, not a shadow behind it.
assert!(img.pixel(200, 200)[0] > 240, "{as_fill}");
}
}
#[test]
fn text_in_a_scaled_group_keeps_its_point_size() {
// A group's child coordinates scale its shapes' boxes, never their type: a 24 pt word in a
// group whose child space is 1/1600 of its size (as old decks write them) or 4 times it is
// 24 pt on the slide, and inside its box (it used to grow until the slide turned black).
let draw = |scale: f64| {
let mut p = Presentation::default();
let mut body = TextBody::from_text("Hello");
body.paragraphs[0].runs[0].props.size = Some(24.0);
body.paragraphs[0].runs[0].props.fill = Some(Fill::solid(ColorRef::rgb(deckcraft_color::Rgba::BLACK)));
let child = Shape { id: ShapeId(601), xfrm: Some(Xfrm::new(0.0, 0.0, 400.0 / scale, 200.0 / scale)), text: Some(body), ..Default::default() };
let g = Shape {
id: ShapeId(600),
xfrm: Some(Xfrm::new(100.0, 100.0, 400.0, 200.0)),
kind: ShapeKind::Group { children: vec![child], child: Xfrm::new(0.0, 0.0, 400.0 / scale, 200.0 / scale) },
..Default::default()
};
std::sync::Arc::make_mut(&mut p.slides[0]).shapes = vec![g];
render_slide(&p, 0, &RenderOpts { scale: 1.0, ..Default::default() })
};
let ((_, y0, _, y1), _) = ink(&draw(1.0));
let plain = y1 - y0;
assert!(plain > 10 && plain < 30, "24 pt word ink height {plain}");
for scale in [1600.0, 4.0, 0.25] {
let ((x0, sy0, x1, sy1), _) = ink(&draw(scale));
assert!((sy1 - sy0).abs_diff(plain) <= 1, "scale {scale}: ink height {} vs {plain}", sy1 - sy0);
assert!(x0 >= 100 && x1 <= 500 && sy0 >= 100 && sy1 <= 300, "scale {scale}: ink inside the box");
}
}
#[test]
fn a_fill_overlay_blends_over_the_fill() {
// `a:fillOverlay blend="mult"`: a 50% grey multiplied over a light fill darkens it; "screen"
// lightens a dark one; the overlay stays inside the shape.
use deckcraft_model::style::FillOverlay;
let draw = |base: [u8; 3], blend: &str| {
let mut p = Presentation::default();
let mut sh = Shape {
id: ShapeId(600),
xfrm: Some(Xfrm::new(100.0, 100.0, 200.0, 100.0)),
fill: Some(Fill::solid(ColorRef::rgb(deckcraft_color::Rgba::rgb(base[0], base[1], base[2])))),
line: Some(deckcraft_model::style::Line { fill: Some(Fill::None), ..Default::default() }),
..Default::default()
};
sh.effects = Some(deckcraft_model::Effects {
fill_overlay: Some(FillOverlay { blend: blend.into(), fill: Fill::solid(ColorRef::rgb(deckcraft_color::Rgba::rgb(128, 128, 128))) }),
..Default::default()
});
std::sync::Arc::make_mut(&mut p.slides[0]).shapes = vec![sh];
let img = render_slide(&p, 0, &RenderOpts { scale: 1.0, ..Default::default() });
(img.pixel(200, 150), img.pixel(50, 50))
};
let (mult, outside) = draw([200, 100, 50], "mult");
assert!((mult[0] as i32 - 100).abs() <= 3 && (mult[1] as i32 - 50).abs() <= 3 && (mult[2] as i32 - 25).abs() <= 3, "{mult:?}");
assert_eq!(&outside[..3], &[255, 255, 255], "nothing outside the shape");
let (screen, _) = draw([0, 0, 0], "screen");
assert!((screen[0] as i32 - 128).abs() <= 3, "{screen:?}");
let (over, _) = draw([200, 100, 50], "over");
assert!((over[0] as i32 - 128).abs() <= 3 && (over[1] as i32 - 128).abs() <= 3, "{over:?}");
}
+16 -3
View File
@@ -201,6 +201,9 @@ struct Style {
/// The `a:ea` and `a:cs` families (theme references resolved), if the document names one.
ea: Option<String>,
cs: Option<String>,
/// The `a:sym` family: private-use characters (U+F000–U+F0FF, as PowerPoint stores symbol-font
/// characters) are drawn in it.
sym: Option<String>,
/// Heading font (`+mj-…`): the theme's major font set applies.
major: bool,
/// Pair kerning on: `a:rPr/@kern` is set and the size reaches it.
@@ -315,6 +318,7 @@ fn make_style(ctx: &Ctx, r: &RunProps, scale: f64, prompt: Option<Rgba>) -> Styl
lang: r.lang.clone().filter(|l| !l.is_empty()),
ea,
cs,
sym: r.font_sym.as_deref().map(|f| ctx.master.theme.font(f)).filter(|f| !f.trim().is_empty()),
major,
kern: r.kern.is_some_and(|k| k > 0.0 && size + 1e-6 >= k * scale),
}
@@ -588,9 +592,18 @@ fn shape_cells(ctx: &Ctx, text: &str, char_style: &[usize], styles: &[Style], fa
// Emoji, and pictographs asked to look like text (U+FE0E), pick their own face.
let neutral =
cluster.iter().all(|c| script::script_of(*c).is_none()) && !deckcraft_fonts::is_emoji_cluster(cluster) && !cluster.contains(&'\u{FE0E}');
let face = match prev.as_ref() {
Some(p) if neutral && deckcraft_fonts::covers_cluster(p, cluster) && char_style.get(a.wrapping_sub(1)) == Some(&si) => p.clone(),
_ => {
// A symbol-font character (U+F0xx) with an `a:sym` font draws in that font when it's there.
let sym_face = st
.sym
.as_deref()
.filter(|_| cluster.first().is_some_and(|c| ('\u{F000}'..='\u{F0FF}').contains(c)))
.filter(|f| db.has_family(f))
.map(|f| db.face(f, st.style_name))
.filter(|f| deckcraft_fonts::covers_cluster(f, cluster));
let face = match (sym_face, prev.as_ref()) {
(Some(f), _) => f,
(None, Some(p)) if neutral && deckcraft_fonts::covers_cluster(p, cluster) && char_style.get(a.wrapping_sub(1)) == Some(&si) => p.clone(),
(None, _) => {
let chain = chains.entry((si, slot, sc)).or_insert_with(|| face_chain(ctx, st, slot, sc));
db.cascade(cluster, chain, st.style_name)
}
+22
View File
@@ -759,3 +759,25 @@ fn symbol_char_maps_symbol_font_codes() {
assert_eq!(symbol_char(&face, "Wingdings", '\u{F06E}'), Some('\u{25A0}'));
assert_eq!(symbol_char(&face, "Wingdings", '\u{100}'), None, "not a symbol code");
}
#[test]
fn symbol_font_characters_draw_in_the_sym_font() {
// PowerPoint stores a Symbol-font character as U+F0xx with `<a:sym typeface="Symbol"/>`:
// U+F0DE is the Symbol font's double arrow (⇒). It must come from that font, not from
// whichever installed font happens to map U+F0DE (Wingdings draws an arrow at another angle).
let symbol = "Symbol";
if !FontDb::global().has_family(symbol) {
eprintln!("skipped: no Symbol font installed");
return;
}
let (p, mut sh) = setup("x\u{F0DE}y", 600.0, 300.0);
let para = &mut sh.text.as_mut().unwrap().paragraphs[0];
para.props.bullet = Some(Bullet::None);
para.runs[0].props.font = Some("Arial".into());
para.runs[0].props.font_sym = Some(symbol.into());
let l = lay(&p, &sh, 600.0, 300.0);
let families: Vec<(String, (usize, usize))> = l.runs.iter().map(|r| (r.face.family.clone(), r.chars)).collect();
assert!(families.iter().any(|(f, c)| f.eq_ignore_ascii_case(symbol) && c.0 == 1), "{families:?}");
// The letters around it keep the run's font.
assert!(families.iter().all(|(f, c)| c.0 == 1 || !f.eq_ignore_ascii_case(symbol)), "{families:?}");
}
+3 -2
View File
@@ -1,6 +1,6 @@
# File-format parity with PowerPoint
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** major (created; formats taken from PowerPoint 16.113.4's Info.plist, PPTX coverage measured from `crates/pptx`) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** trivial (Groups with a small legacy child coordinate space draw outlines, dashes, arrowheads and ink at their own width (#233); previously major: created; formats taken from PowerPoint 16.113.4's Info.plist, PPTX coverage measured from `crates/pptx`) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365)
Every format PowerPoint reads or writes, DeckCraft's support, fidelity and how it is tested.
Gaps are itemized in [gaps.md](gaps.md#file-formats). Dimension score: **~58% ready**
@@ -63,7 +63,7 @@ the round trip even though DeckCraft doesn't model it.
| Themes: colour, font (Latin/EA/CS), effect schemes, background styles | yes | yes | Unknown theme parts kept |
| Notes slides and notes master | yes | yes | No notes-master editing view |
| Handout master | no | no | |
| Shapes: preset geometry (~180 presets), custom geometry, groups, connectors | yes | yes | Presets re-derived in `crates/geom/src/preset.rs` (and `preset/extra.rs`) |
| Shapes: preset geometry (~180 presets), custom geometry, groups, connectors | yes | yes | Presets re-derived in `crates/geom/src/preset.rs` (and `preset/extra.rs`). Outlines, dashes, arrowheads and ink inside a group, and text, keep their size in points whatever the group's child-coordinate scale (#233). |
| Fills: solid, gradient, picture (stretch/tile/crop), pattern, group | yes | yes | |
| Lines: dash, compound, caps, joins, arrowheads | yes | yes | |
| Effects: shadow, glow, soft edges, reflection | yes | yes | |
@@ -101,4 +101,5 @@ the round trip even though DeckCraft doesn't model it.
|---|---|---|
| 2026-10-12 | minor | EMF/WMF text and pattern brushes drawn; OLE (VML) and ActiveX previews read |
| 2026-10-12 | minor | Text warps rendered; their adjust values read and written |
| 2026-10-12 | trivial | Groups with a small legacy child coordinate space draw outlines, dashes, arrowheads and ink at their own width (#233) |
| 2026-10-10 | major | Created from PowerPoint 16.113.4's `CFBundleDocumentTypes`, `crates/pptx` reader/writer and tests, and the open round-trip issues |
-2
View File
@@ -120,8 +120,6 @@ imitate Microsoft's. No pixel comparison against PowerPoint screenshots has been
| Date | Change | Summary |
|---|---|---|
| 2026-10-12 | minor | Off-slide objects drawn and editable around the slide in Normal view (#270) |
| 2026-10-12 | minor | Selection Pane matched to PowerPoint (#133): drag and drop, arrows, groups, eye, Lock |
| 2026-10-12 | minor | Text editing keys: Ctrl+arrows, Ctrl+Backspace/Delete, Ctrl+Up/Down, Home/End on wrapped lines, Shift+F3, font size keys, as observed in PowerPoint for Windows (#268) |
| 2026-10-10 | major | Created: shell, panes and dialogs, direct manipulation, shortcuts and visual fidelity against PowerPoint 16.113 |