Type: character formats, Ruby and Move Type Path Handle reject a param of the wrong type

`text.setStyle` read `font`, `style` and `justify` with `str_param`,
`size` with `len_param` and `tracking` with `num_param`, so a value of
the wrong type was skipped: `{"size": 30, "style": ["Bold"]}` set the
size and ignored the style, and `{"font": "Inter", "size": [12]}` set
the font and ignored the size. `features` dropped an entry that was not
a string and applied the rest. `text.setRangeStyle` skipped a `font` or
`style` that was not a string, `type.ruby` skipped such a `text`,
`position` or `align`, and `text.setPathHandle` moved the out handle
for any `which` other than "in".

Each of these now returns an error that names the param, before the
command edits the document. Omitting a param or giving null keeps its
default. `size` and `leading` still take a length with a unit
("12 pt", "5 mm"), and `tracking` still takes a number written as a
string ("20").

- `text.setStyle`: `font`, `style`, `justify` (`text_param`), `size`
  and `tracking` (checked reads in `typecmd.rs`), `features`.
- `text.setRangeStyle`: `font`, `style`, `features`.
- `type.ruby`: `text`, `position`, `align`.
- `text.setPathHandle`: `which` must be "in" or "out".

Docs: docs/mcp.md.
This commit is contained in:
dotCooCoo
2026-11-10 14:56:13 -08:00
parent 3c82854a46
commit bf09404c33
4 changed files with 120 additions and 15 deletions
+10 -1
View File
@@ -1358,7 +1358,7 @@ naming the key, and change nothing: `radius` in `shape.rectangle`; `sides` and `
in `shape.flare`; `decay` and `segments` in `shape.spiral`; `rows` and `columns` in `shape.rectangularGrid`; `concentric`
and `radial` in `shape.polarGrid`; `size` and the `width`, `height` and `fitMinPercent` of `area` in `text.create`;
`size` and `fitMinPercent` in `text.createInPath`; `start`, `end`, `size`, `tracking`,
`baselineShift`, `hScale`, `vScale`, `rotation` and `strokeWidth` in `text.setRangeStyle`; `start` and `end` in
`baselineShift`, `hScale`, `vScale`, `rotation` and `strokeWidth` in `text.setRangeStyle`; `strokeWidth` in `text.setStyle`; `start` and `end` in
`text.editRange` and `text.getRange`; `at` in `text.startList`; `start`, `hScale`, `vScale` and `rotation` in `text.touchType`; `start` in
`text.glyphAlternates` and `text.setGlyphAlternate`; `by`, `start` and
`end` in `type.step`; `by` in `type.size.increase` and `type.size.decrease`; `size` in `type.ruby`; `width`, `height`
@@ -1370,6 +1370,15 @@ and `amount` in `color.harmony`; `angle` in `paint.editGradient` and in the `gra
`width` and `tolerance` in `livePaint.strokeEdge`. A null is read as a key left out. A gradient stop that names a
swatch refuses a `tint` that is not a number with `` stop 0: `tint` must be a number ``.
`text.setStyle` refuses a `size` that is neither a number nor a length with a unit (`"12 pt"`, `"5 mm"`) with
`` `size` must be a number, not true ``, and a `tracking` that is neither a number nor a number written as a string
(`"20"`) with `` `tracking` must be a number, not false ``. It and `text.setRangeStyle` refuse a `font` or `style` that is not a string
with `` `font` must be a string ``, and a `features` list with an entry that is not a string with
`features must be a list of tags`; `text.setStyle` refuses such a `justify` too. `type.ruby` refuses a `text`,
`position` or `align` that is not a string, and `text.setPathHandle` refuses a `which` other than `in` or `out` with
`` `which` must be one of in, out ``. Each leaves the document, the selection and the undo history as they were, also
when the call gives another param it could apply. A null is read as a key left out.
A byte offset must be a whole number of at least 0. `at` in `text.startList`, and `start` and `end` in
`text.editRange`, `text.getRange` and `text.setRangeStyle`, and in `type.step` and `addon.type.textTweaker` given an `id`,
refuse a negative or fractional number with