Merge pull request #2668 from storytold/fix/2338-range-position

M4: superscript and subscript per range of characters (#2338)
This commit is contained in:
BFlat authored and GitHub committed 2026-11-28 08:41:04 +07:00
commit 5aca499f21
12 files changed
+185 -28

No files matched your search

+48 -3
View File
@@ -114,6 +114,17 @@ pub enum TextCase {
SmallCaps,
}
/// Where characters sit on the line: superscript (smaller and raised) or subscript (smaller and
/// lowered), drawn with the font's `sups` / `subs` glyphs or synthesised without them.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub enum TextPosition {
#[default]
None,
Superscript,
Subscript,
}
impl TextCase {
pub fn apply(self, s: &str) -> String {
self.apply_after(s, None)
@@ -339,6 +350,9 @@ pub struct TextStyle {
#[serde(skip_serializing_if = "Option::is_none")]
pub decoration_look: Option<Box<DecorationLook>>,
pub case: TextCase,
/// Superscript or subscript for these chars; `None` leaves the layer's `sups` / `subs`.
#[serde(skip_serializing_if = "crate::node::is_default")]
pub position: TextPosition,
/// Run fills (None = node fills).
pub fills: Option<Vec<Paint>>,
/// Hyperlink.
@@ -391,6 +405,7 @@ impl Default for TextStyle {
decoration: TextDecoration::None,
decoration_look: None,
case: TextCase::Original,
position: TextPosition::None,
fills: None,
link: None,
variations: std::collections::BTreeMap::new(),
@@ -416,10 +431,12 @@ impl TextStyle {
|| self.variations.get("slnt").is_some_and(|v| *v != 0.0)
}
/// Take what text style `def` sets (font, size, line height, letter spacing, decoration, case
/// and axis values) and link to it as `id`; fills and hyperlinks stay.
/// Take what text style `def` sets (font, size, line height, letter spacing, decoration, case,
/// a position when it has one, and axis values) and link to it as `id`; fills, hyperlinks and
/// a position the style doesn't set stay.
pub fn take_text_style(&mut self, def: &TextStyle, id: &str) {
*self = TextStyle { fills: self.fills.take(), link: self.link.take(), style_id: Some(id.to_string()), ..def.clone() };
let position = if def.position == TextPosition::None { self.position } else { def.position };
*self = TextStyle { fills: self.fills.take(), link: self.link.take(), style_id: Some(id.to_string()), position, ..def.clone() };
}
/// Whether these chars show what text style `def` sets.
@@ -432,6 +449,7 @@ impl TextStyle {
&& self.decoration == def.decoration
&& self.decoration_look == def.decoration_look
&& self.case == def.case
&& (def.position == TextPosition::None || self.position == def.position)
&& self.variations == def.variations
}
@@ -719,6 +737,33 @@ impl TextData {
};
}
/// Where chars styled `s` sit: their own position, else the layer's `sups` / `subs` (`sups`
/// first, as drawn).
pub fn position_of(&self, s: &TextStyle) -> TextPosition {
let on = |tag: &str| self.features.get(tag).copied().unwrap_or(false);
match s.position {
TextPosition::None if on("sups") => TextPosition::Superscript,
TextPosition::None if on("subs") => TextPosition::Subscript,
p => p,
}
}
/// Set chars `start..end` to `position`. The layer's `sups` / `subs` move onto its chars
/// first, so a range set to none is drawn on the line.
pub fn set_position(&mut self, start: usize, end: usize, position: TextPosition) {
let layer = self.position_of(&TextStyle::default());
self.features.remove("sups");
self.features.remove("subs");
if layer != TextPosition::None {
self.restyle(0, self.char_count(), |s| {
if s.position == TextPosition::None {
s.position = layer;
}
});
}
self.restyle(start, end, |s| s.position = position);
}
/// The style at char index `i`.
pub fn style_at(&self, i: usize) -> &TextStyle {
self.runs.iter().find(|r| r.start <= i && i < r.end).map(|r| &r.style).unwrap_or(&self.style)
+15 -4
View File
@@ -1,6 +1,8 @@
//! Document inspection as JSON, so agents can verify their work without screenshots.
use figcraft_doc::{Document, Node, NodeId, NodeKind, StrokeCap, StrokeJoin, TextAlignV, TextCase, TextData, TextDecoration};
use figcraft_doc::{
Document, Node, NodeId, NodeKind, StrokeCap, StrokeJoin, TextAlignV, TextCase, TextData, TextDecoration, TextPosition, TextStyle,
};
use serde_json::{Value, json};
use crate::Session;
@@ -111,6 +113,7 @@ pub const NODE_KEYS: &[&str] = &[
"textDecorationThickness",
"textDirection",
"textPath",
"textPosition",
"textStyleRanges",
"type",
"variableModes",
@@ -448,9 +451,7 @@ fn text_props(t: &TextData, o: &mut serde_json::Map<String, Value>, options: &In
insert_prop(o, options, "textAlignVertical", || json!(t.align_v));
}
insert_prop(o, options, "textAutoResize", || json!(t.auto_resize));
if t.style.case != TextCase::default() {
insert_prop(o, options, "textCase", || json!(t.style.case));
}
case_props(&t.style, o, options);
for (k, v) in [("paragraphSpacing", t.paragraph_spacing), ("paragraphIndent", t.paragraph_indent)] {
if v != 0.0 {
insert_prop(o, options, k, || json!(v));
@@ -529,6 +530,16 @@ fn text_props(t: &TextData, o: &mut serde_json::Map<String, Value>, options: &In
}
}
/// The base style's case and position, when not the defaults.
fn case_props(s: &TextStyle, o: &mut serde_json::Map<String, Value>, options: &InspectOptions) {
if s.case != TextCase::default() {
insert_prop(o, options, "textCase", || json!(s.case));
}
if s.position != TextPosition::None {
insert_prop(o, options, "textPosition", || json!(s.position));
}
}
fn kind_props(doc: &Document, n: &Node, o: &mut serde_json::Map<String, Value>, options: &InspectOptions) {
match &n.kind {
NodeKind::Ellipse { start, sweep, inner } if (*sweep).abs() < std::f64::consts::TAU - 1e-9 || *inner > 0.0 => {
+6 -1
View File
@@ -4,7 +4,7 @@ use figcraft_color::{Color, Paint};
use figcraft_doc::{
AutoLayout, Brush, ChildLayout, DecorationStyle, DevStatus, Document, Effect, GridTrack, LayoutMode, LetterSpacing, LineHeight, ListStyle,
MAX_LIST_INDENT, MaskType, Node, NodeId, NodeKind, Sizing, StrokeCap, StrokeProps, TextAutoResize, TextCase, TextData, TextDecoration,
WidthPoint, WidthPreset, WidthProfile, style_weight, valid_axis_tag, valid_feature_tag,
TextPosition, WidthPoint, WidthPreset, WidthProfile, style_weight, valid_axis_tag, valid_feature_tag,
};
use figcraft_geom::{Affine, Point};
use serde_json::{Map, Value, json};
@@ -980,6 +980,7 @@ fn apply_text(cmd: &str, doc: &mut Document, id: NodeId, props: &Map<String, Val
| "letterSpacing"
| "textDecoration"
| "textCase"
| "textPosition"
| "hyperlink"
| "textFills"
| "fontVariations"
@@ -1402,6 +1403,10 @@ pub fn apply_text_style(cmd: &str, t: &mut TextData, start: usize, end: usize, k
let c: TextCase = enum_of(v).ok_or_else(|| bad(cmd, "textCase: original|upper|lower|title|smallCaps"))?;
t.restyle(start, end, |s| s.case = c);
}
"textPosition" => {
let p: TextPosition = enum_of(v).ok_or_else(|| bad(cmd, "textPosition: none|superscript|subscript"))?;
t.set_position(start, end, p);
}
"hyperlink" => {
let l = string_val(v);
t.restyle(start, end, |s| s.link = l.clone());
+1 -1
View File
@@ -604,7 +604,7 @@ pub fn specs() -> Vec<CommandSpec> {
spec!(
"text.style",
"Style text range",
"{id?, start?, end?, fontFamily?, fontStyle?, fontWeight?, fontVariations? | variationSettings?, fontSize?, lineHeight?, letterSpacing?, textDecoration?, textDecorationStyle?, textDecorationThickness?, textDecorationOffset?, textDecorationSkipInk?, textDecorationColor?, textCase?, hyperlink?, textFills?}",
"{id?, start?, end?, fontFamily?, fontStyle?, fontWeight?, fontVariations? | variationSettings?, fontSize?, lineHeight?, letterSpacing?, textDecoration?, textDecorationStyle?, textDecorationThickness?, textDecorationOffset?, textDecorationSkipInk?, textDecorationColor?, textCase?, textPosition? (none|superscript|subscript), hyperlink?, textFills?}",
true,
|s, p| {
let ids = req_targets("text.style", s, p)?;
+5
View File
@@ -392,6 +392,11 @@ fn text_decls(doc: &Document, n: &Node, tx: &figcraft_doc::TextData, t: &mut Tok
TextDecoration::Underline => put("text-decoration", "underline".into()),
TextDecoration::Strikethrough => put("text-decoration", "line-through".into()),
}
match tx.position_of(s) {
figcraft_doc::TextPosition::None => {}
figcraft_doc::TextPosition::Superscript => put("vertical-align", "super".into()),
figcraft_doc::TextPosition::Subscript => put("vertical-align", "sub".into()),
}
decoration_decls(s, put);
if tx.leading_trim == figcraft_doc::LeadingTrim::CapHeight {
put("text-box", "trim-both cap alphabetic".into());
+56
View File
@@ -710,6 +710,62 @@ fn superscript_and_subscript_are_synthesised_without_glyphs_for_them() {
assert_eq!(glyphs(&s), plain, "off again");
}
#[test]
fn a_range_of_characters_is_raised_or_lowered_on_its_own() {
// #2338: a footnote marker, "ab(1)" with only "(1)" raised, through `text.style`.
let font = test_mono_font();
let mut s = Session::new();
let t = text(&mut s, "ab(1)", json!({"fontFamily": font, "fontSize": 40}));
let glyphs = |s: &Session| -> Vec<(f64, f64)> {
let (l, _) = figcraft_text::layout_node(s.doc().unwrap().node(t).unwrap()).unwrap();
l.glyphs.iter().map(|g| (g.size, g.y)).collect()
};
let raised = |g: &[(f64, f64)], p: &[(f64, f64)]| g.len() == p.len() && g.iter().zip(p).all(|(g, p)| g.0 < p.0 && g.1 < p.1);
let plain = glyphs(&s);
assert_eq!(plain.len(), 5);
s.execute("text.style", &json!({"id": t, "start": 2, "end": 5, "textPosition": "superscript"})).unwrap();
let g = glyphs(&s);
assert_eq!(g[..2], plain[..2], "the chars before stay on the line");
assert!(raised(&g[2..], &plain[2..]), "smaller and raised: {g:?} against {plain:?}");
s.execute("text.style", &json!({"id": t, "start": 2, "end": 5, "textPosition": "subscript"})).unwrap();
let g = glyphs(&s);
assert!(g[2..].iter().zip(&plain[2..]).all(|(g, p)| g.0 < p.0 && g.1 > p.1), "smaller and lowered: {g:?} against {plain:?}");
// The layer's `sups` move onto its chars, so a range set to none sits on the line.
s.execute("text.style", &json!({"id": t, "textPosition": "none"})).unwrap();
assert_eq!(glyphs(&s), plain);
s.execute("text.setFeatures", &json!({"ids": [t], "features": {"sups": true}})).unwrap();
s.execute("text.style", &json!({"id": t, "start": 0, "end": 2, "textPosition": "none"})).unwrap();
let g = glyphs(&s);
assert_eq!(g[..2], plain[..2], "set to none despite the layer's sups");
assert!(raised(&g[2..], &plain[2..]), "the rest still raised: {g:?} against {plain:?}");
assert!(s.doc().unwrap().node(t).unwrap().kind.text().unwrap().features.is_empty(), "the chars hold the position now");
// A text style keeps the position and raises the chars it's applied to.
let u = text(&mut s, "ab(1)", json!({"fontFamily": font, "fontSize": 40}));
s.execute("style.create", &json!({"type": "text", "name": "Note", "value": {"fontFamily": font, "fontSize": 40, "position": "superscript"}}))
.unwrap();
s.execute("style.apply", &json!({"ids": [u], "style": "Note", "start": 2, "end": 5})).unwrap();
let (l, _) = figcraft_text::layout_node(s.doc().unwrap().node(u).unwrap()).unwrap();
let g: Vec<(f64, f64)> = l.glyphs.iter().map(|g| (g.size, g.y)).collect();
assert_eq!(g[..2], plain[..2]);
assert!(raised(&g[2..], &plain[2..]), "the style's chars raised: {g:?} against {plain:?}");
// A style that sets no position leaves the chars' own, and they stay linked to it when the
// layer's `sups` move onto them.
let v = text(&mut s, "ab(1)", json!({"fontFamily": font, "fontSize": 40}));
s.execute("style.create", &json!({"type": "text", "name": "Body", "value": {"fontFamily": font, "fontSize": 40}})).unwrap();
s.execute("style.apply", &json!({"ids": [v], "style": "Body"})).unwrap();
s.execute("text.setFeatures", &json!({"ids": [v], "features": {"sups": true}})).unwrap();
s.execute("text.style", &json!({"id": v, "start": 0, "end": 2, "textPosition": "none"})).unwrap();
let linked = |s: &Session| s.doc().unwrap().node(v).unwrap().kind.text().unwrap().spans().iter().all(|(_, _, st)| st.style_id.is_some());
assert!(linked(&s), "still linked to Body");
s.execute("style.apply", &json!({"ids": [v], "style": "Body"})).unwrap();
let (l, _) = figcraft_text::layout_node(s.doc().unwrap().node(v).unwrap()).unwrap();
let g: Vec<(f64, f64)> = l.glyphs.iter().map(|g| (g.size, g.y)).collect();
assert!(g[..2] == plain[..2] && raised(&g[2..], &plain[2..]), "applying Body again keeps the positions: {g:?}");
}
/// A synthetic monospaced TrueType font (outline-less glyphs, every printable ASCII character 500 of
/// 1000 units wide), loaded into the font database so text measures the same on every machine.
fn test_mono_font() -> &'static str {
+3
View File
@@ -176,6 +176,9 @@ impl<'d> Exporter<'d> {
if !td.features.is_empty() {
self.warn("OpenType features were left out");
}
if styles.clone().any(|st| st.position != figcraft_doc::TextPosition::None) {
self.warn("superscript and subscript were left out");
}
}
/// The editable network (with per-point corner radii, handle mirroring and end caps) and,
+11 -1
View File
@@ -6,7 +6,7 @@ use std::sync::Arc;
use figcraft_doc::{
DecorationLength, DecorationStyle, LeadingTrim, LetterSpacing, LineHeight, ListStyle, ParaList, TextAlignH, TextAutoResize, TextCase, TextData,
TextDecoration, TextDirection, TextStyle, WrapStyle, color::PaintKind, valid_feature_tag,
TextDecoration, TextDirection, TextPosition, TextStyle, WrapStyle, color::PaintKind, valid_feature_tag,
};
use figcraft_geom::{Affine, BezPath, Rect};
use harfrust::{Direction, Feature, ShapeOptions, ShaperInstance, Tag, UnicodeBuffer, Variation};
@@ -1708,6 +1708,16 @@ fn shape_segment(chars: &[char], seg: &Segment, face: &Arc<Face>, features: &[Fe
}
let small_at = |src: usize| src.checked_sub(start).and_then(|i| small.get(i)).copied().unwrap_or(false);
let mut feats: Vec<Feature> = features.to_vec();
// These chars' own position wins over the layer's `sups` / `subs` (#2338).
let run_script = match style.position {
TextPosition::None => None,
TextPosition::Superscript => Some(b"sups"),
TextPosition::Subscript => Some(b"subs"),
};
if let Some(tag) = run_script {
feats.retain(|f| f.tag != Tag::new(b"sups") && f.tag != Tag::new(b"subs"));
feats.push(Feature::new(Tag::new(tag), 1, ..));
}
if native_smcp {
feats.push(Feature::new(Tag::new(b"smcp"), 1, ..));
}
+20 -7
View File
@@ -210,7 +210,7 @@ pub(crate) fn field_row<R>(ui: &mut Ui, label: &str, add: impl FnOnce(&mut Ui, f
#[cfg(test)]
mod variable_tests {
use egui::{Event, Modifiers, PointerButton, Pos2, RawInput};
use figcraft_doc::WrapStyle;
use figcraft_doc::{TextPosition, WrapStyle};
use figcraft_engine::Session;
use super::*;
@@ -432,7 +432,8 @@ mod variable_tests {
#[test]
fn details_position_sets_superscript_subscript_or_neither() {
// #2338: Type settings ▸ Details ▸ Position, for the selected layer.
// #2338: Type settings ▸ Details ▸ Position, for the selected layer, then for the selected
// chars while editing.
let mut p = settings_panel();
// The tab is a clickable label: its text is the node's value.
let tab = p.nodes.iter().find(|n| n.value() == Some("Details") || n.label() == Some("Details")).expect("the Details tab");
@@ -443,18 +444,30 @@ mod variable_tests {
let toggled = |l: &str| p.nodes.iter().find(|n| n.label() == Some(l)).and_then(|n| n.toggled());
["None", "Superscript", "Subscript"].into_iter().filter(|l| toggled(l) == Some(egui::accesskit::Toggled::True)).collect::<Vec<_>>()
};
let feats = |p: &Panel| {
let t = p.app.session.doc().unwrap().node(p.text).unwrap().kind.text().unwrap().features.clone();
(t.get("sups").copied(), t.get("subs").copied())
let positions = |p: &Panel| {
let t = p.app.session.doc().unwrap().node(p.text).unwrap().kind.text().unwrap().clone();
t.spans().into_iter().map(|(a, b, st)| (a, b, t.position_of(st))).collect::<Vec<_>>()
};
assert_eq!(on(&p), ["None"]);
for (label, want) in [("Superscript", (Some(true), None)), ("Subscript", (None, Some(true))), ("None", (None, None))] {
for (label, want) in [("Superscript", TextPosition::Superscript), ("Subscript", TextPosition::Subscript), ("None", TextPosition::None)] {
let at = node_center(&p, label);
p.click(at);
p.frame(vec![]);
assert_eq!(feats(&p), want, "{label}");
assert_eq!(positions(&p), [(0, 7, want)], "{label}");
assert_eq!(on(&p), [label]);
}
// While editing, the selected chars ("two") and nothing else.
figcraft_engine::textedit::begin(&mut p.app.session, p.text, Some(4), false).unwrap();
figcraft_engine::textedit::set_caret(&mut p.app.session, 7, true).unwrap();
p.frame(vec![]);
let at = node_center(&p, "Superscript");
p.click(at);
assert_eq!(positions(&p), [(0, 4, TextPosition::None), (4, 7, TextPosition::Superscript)]);
assert_eq!(on(&p), ["Superscript"], "the control shows the selected chars' position");
figcraft_engine::textedit::set_caret(&mut p.app.session, 0, false).unwrap();
figcraft_engine::textedit::set_caret(&mut p.app.session, 7, true).unwrap();
p.frame(vec![]);
assert!(on(&p).is_empty(), "chars that differ: {:?}", on(&p));
assert!(p.app.ui.last_error.is_none(), "{:?}", p.app.ui.last_error);
}
}
+14 -9
View File
@@ -469,7 +469,7 @@ fn type_settings(
let face = uniform(styles, |s| (s.font_family.clone(), s.font_style.clone())).and_then(|(f, s)| figcraft_text::find_face(&f, &s));
let face_name = face.as_ref().map(|f| format!("{} {}", f.family, f.style)).unwrap_or_else(|| tr("Mixed fonts").into());
widgets::label(ui, &face_name, t.text_secondary);
position_row(app, ui, doc, ids, w);
position_row(app, ui, doc, ids, apply_style, w);
egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {
for (tag, label, default_on) in FEATURES {
let state = common(doc, ids, |n| n.kind.text().map(|t| t.features.get(tag).copied())).flatten();
@@ -486,17 +486,22 @@ fn type_settings(
}
}
/// Position: the layers' text as superscript or subscript (`sups`, `subs`; drawn smaller and
/// raised or lowered where the font has no glyphs for them), or neither. `sups` wins when a layer
/// has both, as when it is drawn (#2338).
fn position_row(app: &mut FigApp, ui: &mut Ui, doc: &Document, ids: &[NodeId], w: f32) {
/// Position: superscript or subscript (drawn smaller and raised or lowered where the font has no
/// glyphs for them), or neither, for the selected chars while editing, else whole layers (#2338).
fn position_row(app: &mut FigApp, ui: &mut Ui, doc: &Document, ids: &[NodeId], apply_style: &dyn Fn(&mut FigApp, &str, Value), w: f32) {
caption(ui, tr("Position"));
let on = |t: &figcraft_doc::TextData, tag: &str| t.features.get(tag).copied().unwrap_or(false);
let active = common(doc, ids, |n| n.kind.text().map(|t| if on(t, "sups") { 1 } else { usize::from(on(t, "subs")) * 2 })).flatten();
let range = figcraft_engine::textedit::selected_range(&app.session);
let active = common(doc, ids, |n| {
let t = n.kind.text()?;
let sel = range.filter(|r| r.0 == n.id && r.1 < r.2);
let mut at = t.spans().into_iter().filter(|(s, e, _)| sel.is_none_or(|(_, a, b)| *s < b && *e > a)).map(|(_, _, st)| t.position_of(st));
let first = at.next()?;
at.all(|p| p == first).then_some(first as usize)
})
.flatten();
let items = [("—", tr_noop("None")), ("X²", tr_noop("Superscript")), ("X₂", tr_noop("Subscript"))];
if let Some(i) = text_seg(ui, "position", &items, active, w) {
let want = |k: usize| if i == k { json!(true) } else { Value::Null };
app.run("text.setFeatures", json!({"ids": ids, "features": {"sups": want(1), "subs": want(2)}}));
apply_style(app, "textPosition", json!((["none", "superscript", "subscript"].get(i).copied().unwrap_or("none"))));
}
ui.add_space(4.0);
}
+3
View File
@@ -321,6 +321,9 @@ Or in a project's `.mcp.json`:
`textDecorationOffset` (`auto`, px, or `"10%"` of the font size; the offset runs from the baseline
down to an underline's top edge), `textDecorationSkipInk` (underlines break around descenders) and
`textDecorationColor` (a colour, or `auto` for the text's) are character props too.
`textPosition` (`none`, `superscript`, `subscript`) is one as well, so `text.style` with
`start`/`end` raises or lowers only those chars; it wins over the layer's `sups` / `subs`
features, which move onto the chars the first time a position is set.
- **Wrap style** (`auto`, `balance`, `pretty`) works at three levels: `wrapStyle` on `node.set`
sets the layer (every paragraph); with `start`/`end` it sets the paragraphs those chars touch,
and a paragraph's own style beats the layer's. `text.wrapStyle` sets the selected paragraphs while
+3 -2
View File
@@ -1,6 +1,6 @@
# UI and interaction parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (Cmd/Ctrl+L copies a link to the selected layer, as in Figma; M4: the eyedropper colours the stroke of a layer that has only a stroke, samples for an open colour picker from the shortcut too, and shows the colour under it beside the pointer; Shift with a double-click goes a level deeper and keeps the rest of the selection, so layers nested in neighbouring artboards can be selected together; M1: Frame selection makes a frame without a fill; M1: centred auto-width text keeps its middle as it grows and shrinks; M1: a drag on a section's background, or on the background of a frame in it, draws a marquee; the Layers panel's eye and padlock stay at the list's right edge, and a name takes at most 400 pt; in vector edit mode, deleting a point selects the next one on its path, so Delete pressed again goes on along it; the hover and selection outline of a curved layer bends smoothly instead of showing straight pieces; text copied while editing, or a whole text layer copied, pastes into a text edit with its formatting and its layer's colour, and Shift+Cmd/Ctrl+V (also Alt+Cmd/Ctrl+V) pastes it in the style at the caret; crop mode: the layer's sides and corners crop its image in an auto layout frame too, up to the image's edges, change a locked ratio (Shift keeps it), the image's own corners scale freely with Shift proportional as a resize does, and crop mode and vector edit mode end each other; after a click on a layer row the arrow keys nudge the selection, or move a layer in an auto layout flow one place, as in Figma; the rows take the arrows once they have the keyboard (F6); Shift+Cmd/Ctrl+V with several layers selected pastes after the last of them as seen: next in an auto layout frame's flow, else below the lowest or right of the rightmost, at the selection's own gap; Tab and Shift+Tab while editing a text layer go on to the next or previous text layer of its frame, in reading order, with all of its text selected; a file opens again on the page and at the view it was left at; the desktop app reopens the files open when it quit, in their tabs' order with the same one in front, and with nothing to reopen starts on the Home screen instead of in a new file; a dropdown, button menu or context menu in the panels that is taller than the window scrolls, so its last rows can be picked; frames, sections, components and instances move, resize and draw on whole pixels whatever Snap to pixel grid says and whatever they snap to, as Figma's help says; the pixel grid shows on a dark canvas and dark fills as well as on white, its lines one screen pixel wide in a light grey at a fifth of its strength, as measured in Figma; Shift+Cmd/Ctrl+' says at the bottom of the window whether snapping to the pixel grid is now on or off; Paste properties links the copied layer's colour, effect, grid and text styles and binds the variables it follows, and a frame's layout grids come along; links another file lacks paste as values; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); a dragged layer is drawn from a sprite that moves with its outline (#2033); the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a laLine truncated
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-28 · **Change:** minor (Cmd/Ctrl+L copies a link to the selected layer, as in Figma; M4: the eyedropper colours the stroke of a layer that has only a stroke, samples for an open colour picker from the shortcut too, and shows the colour under it beside the pointer; Shift with a double-click goes a level deeper and keeps the rest of the selection, so layers nested in neighbouring artboards can be selected together; M1: Frame selection makes a frame without a fill; M1: centred auto-width text keeps its middle as it grows and shrinks; M1: a drag on a section's background, or on the background of a frame in it, draws a marquee; the Layers panel's eye and padlock stay at the list's right edge, and a name takes at most 400 pt; in vector edit mode, deleting a point selects the next one on its path, so Delete pressed again goes on along it; the hover and selection outline of a curved layer bends smoothly instead of showing straight pieces; text copied while editing, or a whole text layer copied, pastes into a text edit with its formatting and its layer's colour, and Shift+Cmd/Ctrl+V (also Alt+Cmd/Ctrl+V) pastes it in the style at the caret; crop mode: the layer's sides and corners crop its image in an auto layout frame too, up to the image's edges, change a locked ratio (Shift keeps it), the image's own corners scale freely with Shift proportional as a resize does, and crop mode and vector edit mode end each other; after a click on a layer row the arrow keys nudge the selection, or move a layer in an auto layout flow one place, as in Figma; the rows take the arrows once they have the keyboard (F6); Shift+Cmd/Ctrl+V with several layers selected pastes after the last of them as seen: next in an auto layout frame's flow, else below the lowest or right of the rightmost, at the selection's own gap; Tab and Shift+Tab while editing a text layer go on to the next or previous text layer of its frame, in reading order, with all of its text selected; a file opens again on the page and at the view it was left at; the desktop app reopens the files open when it quit, in their tabs' order with the same one in front, and with nothing to reopen starts on the Home screen instead of in a new file; a dropdown, button menu or context menu in the panels that is taller than the window scrolls, so its last rows can be picked; frames, sections, components and instances move, resize and draw on whole pixels whatever Snap to pixel grid says and whatever they snap to, as Figma's help says; the pixel grid shows on a dark canvas and dark fills as well as on white, its lines one screen pixel wide in a light grey at a fifth of its strength, as measured in Figma; Shift+Cmd/Ctrl+' says at the bottom of the window whether snapping to the pixel grid is now on or off; Paste properties links the copied layer's colour, effect, grid and text styles and binds the variables it follows, and a frame's layout grids come along; links another file lacks paste as values; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); a dragged layer is drawn from a sprite that moves with its outline (#2033); the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); Type settings ▸ Details ▸ Position sets the selected text layers, or the selected characters while editing, to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 202Line truncated
Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys,
drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status:
@@ -102,7 +102,7 @@ interaction feel only partly compared: the interactions measured so far, case by
| Text: point, auto height, fixed; caret, words, lines, IME | done | Backspace or Delete at the start of a list item takes its marker and keeps its level, the paragraph starting where the item's text did ("delete the counter, but keep the same level of indentation", Create bulleted and numbered lists; `text_tail_tests::list_keys_at_list_items`, text crate `behaviour_tests`); Tab and Shift+Tab while editing a text layer that isn't a list item go on to the next or previous text layer of its frame in reading order, all of its text selected, and do nothing at the last and the first (`text_tab_tests`); max lines on auto-width text keep it auto width, hugging up to that many lines and growing with its longest line ("Text resizing is set to auto height or auto width", Explore text properties; `text_behaviour_tests::max_lines_on_auto_width_text_keeps_auto_width_and_hugs_that_many_lines`); Alt+Enter while editing opens the link at the caret, web and mail links only (`text.openLink`; "press ⌥Option Return/Alt Enter to activate a focused link", Accessibility at Figma; `text_link_tests`); the font picker previews a family on the canvas while hovered (no undo step; Escape restores, #653) and Up/Down step through it (#352); a selection highlight after a line break starts at that line's start and an empty last line shows its mark (#665); carets step over whole emoji and accented letters; colour emoji draw from their colour tables (#300); IME composition replayed in tests as macOS sends it, not yet checked on a Mac (#747); CJK words by script run (no dictionary); vertical trim in Type settings; the caret takes the text's solid fill colour, measured in Figma's web app, 2026-11-09; gradient and image fills (not measured) give a black caret on a light surface and a white one on a dark one (the nearest layer around the text whose top visible fill is a solid at least half opaque as drawn, counting layer opacity, else the page; a layer whose top fill is a gradient or an image is passed over), not the interface's text colour, which is white in the dark theme and vanished on the default light page (#2190) (#2156; `caret_tests`); no spell check |
| Text: wrap style (Auto, Balance, Pretty) | done | per text layer (`wrapStyle` on `node.set`, `text.wrapStyle`, the Type settings control under Vertical trim, inspect, CSS `text-wrap: balance` or `pretty`): Auto breaks greedily; Balance narrows each paragraph as far as it goes without another line, so its lines come out close to the same length (what browsers do for `text-wrap: balance`); Pretty keeps lines full and, when the last line is one word, narrows one of the last four lines just enough to give a word to the lines after it (Explore text properties: "Auto: Figma fits as many words as possible on each line before wrapping to the next", "Balance: Figma distributes text as evenly as possible across every line, so each line is close to the same length", "Pretty: Figma keeps each line full, but adjusts the last four lines to avoid an orphan"). Saved line breaks from a file still win. At three levels (the text layer, a paragraph and a text style, per Explore text properties): the paragraph level is the caret's or the selection's paragraphs while editing (`text.wrapStyle`; the control follows them), or `start`/`end` on `node.set wrapStyle` (a paragraph's own style beats the layer's; setting the layer sets every paragraph again; Enter carries it to the new paragraph; inspect reports `lineWrapStyles` when paragraphs differ and CSS `text-wrap` only when they agree); the text-style level is a style's `wrapStyle` (shown read-only in the style editor, applied with the style, moved by `style.update`, unlinking when edited). The `.fig` import/export mapping stays open (#1827): a `.fig` export leaves the wrap styles out and a `.fig` import reads every text as Auto, so the wrap styles are lost through a `.fig` round trip. Test: `text_behaviour_tests::wrap_style_per_paragraph_overrides_the_layers`, `styles_behaviour_tests::text_styles_carry_the_wrap_style`, `text_behaviour_tests::balance_and_pretty_wrap_styles_break_lines_as_documented` |
| Text: direction override (Text ▸ Text direction) | done | per paragraph (`ParaList::direction`: auto, ltr, rtl): Text ▸ Text direction ▸ Auto / Left to right / Right to left and `text.direction {direction, ids?}` set the edited paragraphs while editing, else every paragraph of the selected texts; `node.set textDirection` the layer's (or the chars `start`/`end` name); the Type settings control appears once a right-to-left script is in the text or a direction is forced; inspect reports `textDirection` when the paragraphs agree and `lineDirections` otherwise; Developer Mode's CSS writes `direction: ltr` or `rtl` when every paragraph is forced the same way (with `text-align: left` beside `rtl`, as Left is absolute on the canvas); `.fig` import and export carry each line's `sourceDirectionality`, read up to the paragraph count. Layout gives the paragraph its base level, so a forced right-to-left paragraph of Latin letters starts at the right, mirrors its list gutter and indent and orders its runs right to left, and a forced left-to-right paragraph of Hebrew the other way ("By default, Figma automatically handles text direction based on language detection. However, controls are available to override text direction per paragraph", "Go to Text > Text direction. Select Left to right or Right to left", Add right-to-left text). Not included: a direction in text styles (the article names none). Tests: `text_behaviour_tests::text_direction_is_forced_per_paragraph`, `fig::text_direction_tests` |
| Text: superscript and subscript | done | `sups` / `subs` use the font's own glyphs where it has the feature and every letter or digit of the run gets one; otherwise the standard glyphs are drawn shrunk and raised or lowered by the font's OS/2 superscript and subscript metrics (0.65 em at 0.35 em up or 0.14 em down without them), and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says ("Figma draws a synthesized version by using the font's standard version of the character, shrinking it, and positioning it accordingly"; mixed glyphs "all update to the synthesized form for consistency"), #1828; tests `text::tests::superscript_native_or_synthesised_and_never_mixed`, `text_behaviour_tests::superscript_and_subscript_are_synthesised_without_glyphs_for_them`. Type settings ▸ Details ▸ Position (None, Superscript, Subscript) sets them on the selected layers (#2338); a range of characters can't be raised alone yet, as the features are the layer's |
| Text: superscript and subscript | done | `sups` / `subs` use the font's own glyphs where it has the feature and every letter or digit of the run gets one; otherwise the standard glyphs are drawn shrunk and raised or lowered by the font's OS/2 superscript and subscript metrics (0.65 em at 0.35 em up or 0.14 em down without them), and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says ("Figma draws a synthesized version by using the font's standard version of the character, shrinking it, and positioning it accordingly"; mixed glyphs "all update to the synthesized form for consistency"), #1828; tests `text::tests::superscript_native_or_synthesised_and_never_mixed`, `text_behaviour_tests::superscript_and_subscript_are_synthesised_without_glyphs_for_them`. Type settings ▸ Details ▸ Position (None, Superscript, Subscript) sets them on the selected layers, or on the selected characters while editing, so a footnote marker can be raised alone (#2338): a position per character (`textPosition` on `text.style` and `node.set`) that wins over the layer's `sups` / `subs`, kept in text styles (one without a position leaves the characters' own) and written as `vertical-align` in the CSS inspect shows; `.fig` export leaves it out with a warning, as it does OpenType features; tests `text_behaviour_tests::a_range_of_characters_is_raised_or_lowered_on_its_own`, `typography::variable_tests::details_position_sets_superscript_subscript_or_neither` |
| Eyedropper (I) | done | picks the colour seen under the pointer (opaque) into the selection's fill and the recent colours, one undo step (`fx_behaviour_tests`): one screen pixel centred on the pointer, sampled as the canvas draws it when zoomed in, so an image magnified past 2x gives the pixel under the pointer, not a blend with its neighbours; zoomed out it samples the full-resolution image (the canvas may show a smaller copy, which the eyedropper does not use), so it can differ slightly from the shown colour (#2189, `eyedropper_image_tests`); with Cmd/Ctrl+Shift held it makes a colour style or variable of it instead, as the reference app's eyedropper does: a Create from color window asks which, its name (the next free "Color n") and a variable's collection (the file's first, or a new one made with it in the same undo step), and leaves the selection's fills alone (`eyedropper_create_tests`, `sampled_color_tests`) |
| Comment (C), Shift+C to show/hide | done | local only |
| Annotation tool (Shift+T) | done | picks the layer under the pointer, or the selection (or an `id`) with `tool.annotation`, and opens its note in the Inspect tab with the new-note field focused; it works in Developer Mode and in Design mode, and stays selected until V or Escape (inferred). Figma's placement, cursor and whether the tool stays selected are unmeasured (Developer Mode is paywalled in the web app); staying selected until V or Escape, like the Comment tool, is inferred, and there is no toolbar button or icon yet |
@@ -212,6 +212,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged
| Date | Change | Summary |
|---|---|---|
| 2026-11-28 | patch | M4, #2338: superscript and subscript were the layer's, so a footnote marker such as the "(1)" in "$29/month(1)" couldn't be raised alone. Each character now has a position (none, superscript, subscript): `textPosition` on `text.style` (with `start`/`end`) and `node.set`, and Type settings ▸ Details ▸ Position sets the selected characters while editing, else whole layers, and shows theirs. A character's position wins over the layer's `sups` / `subs`, which move onto the characters the first time a position is set, so a range set to none sits on the line. Text styles keep it (`position` in a style's definition; a style that sets none leaves the characters' own, so older styles don't drop a raised marker), inspect reports `textPosition` and its CSS `vertical-align: super` or `sub`, and `.fig` export warns that it was left out. Tests: `text_behaviour_tests::a_range_of_characters_is_raised_or_lowered_on_its_own`, `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. |
| 2026-11-09 | patch | M8, #2033: a dragged layer moves with its outline: the layers a translate-only drag moves are drawn from a sprite (a texture rendered once at the start) at the same shift as the outline, and the base render, made once without them, is not asked for again until the drag ends (see the row "A dragged layer moves with its outline" for the conditions and trade-offs). |
| 2026-11-09 | patch | M3, #2090: the Scale tool no longer snaps variable-bound lengths back to the variable's value. An instance multiplies its new `scale_factor` and keeps its bindings, drawn at the variable's value times the factor (modes and variable edits stay live); every other scaled layer outside an instance keeps the scaled value and drops the binding of the length fields it scaled, and so does a scaled instance's own layer when the instance is detached (the instances inside it take its factor on). Measured in the incumbent for the gap only (an instance keeps the binding at value x factor, a plain frame bakes it, and detaching a scaled instance bakes it); the other lengths are assumed to follow, and a main component is unmeasured; a scale that would take an instance past 0.001 to 1000 times is refused. Tests: `scale_bound_values_tests`. |
| 2026-11-24 | patch | M4: Copy properties (Alt+Cmd/Ctrl+C) took a layer's values and left behind what they come from: a frame filled from a colour variable or a style pasted a plain colour, unlinked, and a pasted layer's own bindings stayed and could hold the old value over the pasted one. It now also carries the fill, stroke, effect, grid and text style links, the variables bound to what it copies (not size, auto layout spacing, visibility or text content) and a frame's layout grids; the pasted layer's bindings on what the copy carries give way, others stay. Pasted into another file (the copy came from another tab), or after its style was deleted, a link is left out, its values pasted and the layer's own link on them dropped. Tests: `paste_properties_tests` (4). |