mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-12 18:15:49 +00:00
Merge pull request #6590 from dotCooCoo/fix/text-style-leading-strict
Type: text.setStyle refuses a leading with trailing text
This commit is contained in:
@@ -8,7 +8,7 @@ use vectorcraft_doc::{AreaFit, Document, Justify, Node, NodeId, NodeKind, RubyAl
|
||||
use vectorcraft_geom::{Affine, PathData, Vec2};
|
||||
|
||||
use super::edit::selected_roots;
|
||||
use super::pathops::{len_param, length_given, number_given, shape_node};
|
||||
use super::pathops::{length_given, number_given, shape_node};
|
||||
use super::{
|
||||
CommandSpec, EngineError, Result, Session, bad, check_numbers, cmd, color_value, f64_req, has_doc, has_selection, id_param, index, number_or, ok,
|
||||
str_param, switch_or, targets, text_param,
|
||||
@@ -824,7 +824,9 @@ fn set_style(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let leading = match p.get("leading") {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(Value::String(a)) if a.eq_ignore_ascii_case("auto") => Some(None),
|
||||
Some(_) => Some(Some(len_param(p, "leading").ok_or_else(|| bad(C, "leading must be a number or \"auto\""))?.clamp(0.1, 5000.0))),
|
||||
Some(_) => {
|
||||
Some(Some(length_given(p, "leading", C).ok().flatten().ok_or_else(|| bad(C, "leading must be a number or \"auto\""))?.clamp(0.1, 5000.0)))
|
||||
}
|
||||
};
|
||||
let tracking = number_given(p, "tracking", C)?;
|
||||
let justify = match text_param(p, "justify", C)? {
|
||||
|
||||
@@ -522,6 +522,7 @@ fn character_ruby_and_path_handle_refuse_a_param_of_the_wrong_type() {
|
||||
("text.setStyle", json!({"size": 30, "justify": {"value": "center"}}), string("justify")),
|
||||
("text.setStyle", json!({"features": ["dlig", 5]}), tags.clone()),
|
||||
("text.setStyle", json!({"leading": true}), "leading must be a number or \"auto\"".to_string()),
|
||||
("text.setStyle", json!({"leading": "12abc"}), "leading must be a number or \"auto\"".to_string()),
|
||||
("text.setRangeStyle", json!({"id": id.0, "font": 5}), string("font")),
|
||||
("text.setRangeStyle", json!({"id": id.0, "size": 30, "style": false}), string("style")),
|
||||
("text.setRangeStyle", json!({"id": id.0, "features": [null]}), tags),
|
||||
|
||||
Reference in New Issue
Block a user