Add text layers

Introduce editable text layers: a resizable text box with editable text,
font size, color, font family, and alignment.

Core:
- New TextLayer/TextContent (text_layer.rs), wired into AnyLayer/LayerType
  and all the exhaustive match sites; structured so content can be keyframed
  later via content_at().
- fonts.rs: thread-local parley FontContext with three bundled fonts
  (Liberation Sans/Serif/Mono, SIL OFL), system-font enumeration consolidated
  to base families, document-embedded fonts, glyph/caret/selection geometry,
  and a background preloader for the picker fonts.
- Rendering via parley layout + Scene::draw_glyphs (renderer.rs); text
  composites through the vector path.
- Actions: CreateTextClipAction (vector-layer branch, undoable),
  SetTextContentAction, ResizeTextBoxAction.
- .beam font embedding: MediaKind::Font rows (content-hash dedupe) written on
  save and registered on load, with bundled-default fallback.
- VectorClip content bounds include text boxes so text-only clips are
  selectable/draggable.

Editor:
- Text tool: click empty/raster/video to create a top-level text layer, or a
  vector layer to create+enter a clip containing the text; click an existing
  box to edit it.
- Hybrid in-place editing: a hidden egui TextEdit drives input/IME/caret while
  the text and caret/selection render in Vello; empty just-created layers are
  removed on commit.
- Selection outline + 8 resize handles (re-wrap text) with hover cursors;
  factored the corner/edge resize-cursor mapping shared with the Transform tool.
- Info panel: edit text, size, color, alignment, box size, and a font-family
  picker that previews each entry in its own font (fonts preloaded in the
  background to avoid hitches).

Deps: add parley (git, pinned to match vello's peniko); bundle Liberation
fonts under lightningbeam-core/assets/fonts. Gitignore the local
.cargo/config.toml used to select a machine's ffmpeg.
This commit is contained in:
Skyler Lehmkuhl
2026-06-27 18:14:47 -04:00
parent 58a3c829d7
commit fd582828c2
37 changed files with 2070 additions and 184 deletions
@@ -489,8 +489,8 @@ impl Document {
}
}
}
crate::layer::AnyLayer::Raster(_) => {
// Raster layers don't have clip instances
crate::layer::AnyLayer::Raster(_) | crate::layer::AnyLayer::Text(_) => {
// Raster and text layers don't have clip instances
}
crate::layer::AnyLayer::Group(group) => {
// Recurse into group children to find their clip instance endpoints
@@ -530,8 +530,8 @@ impl Document {
}
}
}
crate::layer::AnyLayer::Raster(_) => {
// Raster layers don't have clip instances
crate::layer::AnyLayer::Raster(_) | crate::layer::AnyLayer::Text(_) => {
// Raster and text layers don't have clip instances
}
crate::layer::AnyLayer::Group(g) => {
process_group_children(&g.children, doc, max_end, calc_end);
@@ -937,6 +937,7 @@ impl Document {
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Group(_) => &[],
AnyLayer::Raster(_) => &[],
AnyLayer::Text(_) => &[],
};
let instance = instances.iter().find(|inst| &inst.id == instance_id)?;
@@ -977,6 +978,7 @@ impl Document {
AnyLayer::Effect(effect) => &effect.clip_instances,
AnyLayer::Group(_) => &[],
AnyLayer::Raster(_) => &[],
AnyLayer::Text(_) => &[],
};
for instance in instances {
@@ -1039,6 +1041,7 @@ impl Document {
AnyLayer::Vector(_) => return Some(desired_start), // Shouldn't reach here
AnyLayer::Group(_) => return Some(desired_start), // Groups don't have own clips
AnyLayer::Raster(_) => return Some(desired_start), // Raster layers don't have own clips
AnyLayer::Text(_) => return Some(desired_start), // Text layers don't have own clips
};
let mut occupied_ranges: Vec<(f64, f64, Uuid)> = Vec::new();
@@ -1134,6 +1137,7 @@ impl Document {
AnyLayer::Vector(v) => &v.clip_instances,
AnyLayer::Group(_) => &[],
AnyLayer::Raster(_) => &[],
AnyLayer::Text(_) => &[],
};
// Collect non-group clip ranges
@@ -1205,6 +1209,7 @@ impl Document {
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Group(_) => &[],
AnyLayer::Raster(_) => &[],
AnyLayer::Text(_) => &[],
};
for other in instances {
@@ -1253,6 +1258,7 @@ impl Document {
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Group(_) => &[],
AnyLayer::Raster(_) => &[],
AnyLayer::Text(_) => &[],
};
let mut nearest_start = f64::MAX;
@@ -1300,6 +1306,7 @@ impl Document {
AnyLayer::Vector(vector) => &vector.clip_instances,
AnyLayer::Group(_) => &[],
AnyLayer::Raster(_) => &[],
AnyLayer::Text(_) => &[],
};
let mut nearest_end = 0.0;