T: Type on a Path — tool, options, screen and PDF

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-02 20:34:20 -04:00
co-authored by Claude Opus 5.5
parent bfe4220840
commit eb4fa9c64c
15 changed files with 454 additions and 6 deletions
+4 -1
View File
@@ -469,7 +469,10 @@ impl Renderer {
Content::Text(tf) => {
let cs = self.story(f, tf.story, page_name);
if let Some(ft) = cs.frame(it.id) {
self.draw_text(ctx, f, &cs, ft, xf);
match &tf.options.path {
Some(pt) => self.draw_path_text(ctx, f, &cs, ft, xf, bp, pt),
None => self.draw_text(ctx, f, &cs, ft, xf),
}
}
}
_ => {}
+33
View File
@@ -330,3 +330,36 @@ fn cell_stroke(s: &designcraft_doc::CellStroke) -> kurbo::Stroke {
_ => st,
}
}
impl Renderer {
/// Type on a path: glyphs follow the frame's path.
#[allow(clippy::too_many_arguments)]
pub(crate) fn draw_path_text(
&mut self,
ctx: &mut RenderContext,
f: &Frame,
cs: &Arc<ComposedStory>,
ft: &FrameText,
xf: Affine,
path: &BezPath,
pt: &designcraft_doc::PathType,
) {
let doc = f.doc;
ctx.set_transform(f.view * xf);
for (si, bp) in designcraft_compose::path_glyphs(cs, ft, path, pt) {
let st = &cs.styles[si as usize];
if let Some(c) = doc.resolve_color(&st.fill, st.fill_tint) {
ctx.set_paint(color_of(&c, 1.0));
ctx.fill_path(&bp);
}
if st.stroke != designcraft_color::swatch::NONE
&& let Some(c) = doc.resolve_color(&st.stroke, st.stroke_tint)
{
ctx.set_paint(color_of(&c, 1.0));
ctx.set_stroke(kurbo::Stroke::new(st.stroke_weight));
ctx.stroke_path(&bp);
}
self.stats.glyphs += 1;
}
}
}