mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 02:37:01 -06:00
SVG export: type with small capitals, superscript, subscript or tab leaders is written as outlines (#3869)
This commit is contained in:
@@ -180,6 +180,30 @@ fn reopened_preserve_editing_svg_saves_as_the_full_document() {
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
|
||||
/// #3869: small capitals, superscript and subscript, and tab leaders, which SVG text can't draw,
|
||||
/// are written as outlines (as vertical type and ruby are) rather than as plain text at full size;
|
||||
/// type without them stays text.
|
||||
#[test]
|
||||
fn type_svg_text_cant_draw_is_written_as_outlines() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 500, "height": 200})).unwrap();
|
||||
s.execute("text.create", &json!({"x": 50, "y": 100, "text": "Small caps x2 H2O", "size": 30})).unwrap();
|
||||
let plain = svg(&mut s, json!({}));
|
||||
assert!(plain.contains("<text"), "plain type stays text: {plain}");
|
||||
for style in [json!({"smallCaps": true}), json!({"position": "superscript"}), json!({"position": "subscript"})] {
|
||||
let mut t = Session::new();
|
||||
t.execute("file.new", &json!({"width": 500, "height": 200})).unwrap();
|
||||
let id = t.execute("text.create", &json!({"x": 50, "y": 100, "text": "Small caps x2 H2O", "size": 30})).unwrap()["id"].clone();
|
||||
let mut p = style.clone();
|
||||
p["id"] = id;
|
||||
p["start"] = json!(0);
|
||||
p["end"] = json!(5);
|
||||
t.execute("text.setRangeStyle", &p).unwrap();
|
||||
let out = svg(&mut t, json!({}));
|
||||
assert!(!out.contains("<text") && out.contains("<path"), "{style}: {out}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_writes_svg_and_remembers_its_options() {
|
||||
let mut s = session(1);
|
||||
|
||||
Reference in New Issue
Block a user