mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 09:36:45 +00:00
Merge main into fix/transform-copies-raster-effects-groups
This commit is contained in:
@@ -444,8 +444,8 @@ pub fn export(doc: &Document, opts: &DxfOptions) -> Result<DxfOutput, String> {
|
||||
return Err("the export region is not finite".into());
|
||||
}
|
||||
// Symbols' art is placed without clipping, as the scene places it.
|
||||
let baked =
|
||||
vectorcraft_effects::bake_document_placing_symbols(doc, false, vectorcraft_effects::WrittenLayers { hidden: true, non_printing: true });
|
||||
let layers = vectorcraft_effects::WrittenLayers { hidden: true, non_printing: true, hidden_objects: false };
|
||||
let baked = vectorcraft_effects::bake_document_placing_symbols(doc, false, layers);
|
||||
let doc = baked.as_ref().unwrap_or(doc);
|
||||
Ok(scene::Scene::new(doc, opts).run())
|
||||
}
|
||||
|
||||
@@ -316,6 +316,7 @@ fn content_hash(text: &crate::TextObject) -> Option<[u64; 2]> {
|
||||
let inline_bounds = text.runs.iter().filter_map(|r| r.inline.as_ref()).map(|i| i.bounds.map(|b| [b.x0, b.y0, b.x1, b.y1].map(f64::to_bits)));
|
||||
for h in &mut feed.0 {
|
||||
h.write_u8(u8::from(text.first_para_continues));
|
||||
h.write_u32(text.first_para_lead.map_or(u32::MAX, u32::from));
|
||||
for b in inline_bounds.clone() {
|
||||
match b {
|
||||
None => h.write_u8(0),
|
||||
|
||||
@@ -67,6 +67,12 @@ pub struct TextObject {
|
||||
/// it on a frame that leaves its thread and on a copy. Not saved.
|
||||
#[serde(skip)]
|
||||
pub first_para_continues: bool,
|
||||
/// Threaded text whose first paragraph continues ([`TextObject::first_para_continues`]): the
|
||||
/// last character of that paragraph in the frames before that a repeat mark could stand for
|
||||
/// (Kurikaeshi Moji Shori), or None. The engine sets it with `first_para_continues`; layout
|
||||
/// reads it only while `first_para_continues` is on. Not saved.
|
||||
#[serde(skip)]
|
||||
pub first_para_lead: Option<char>,
|
||||
/// Area Type Options (area type only).
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
pub area: AreaOptions,
|
||||
|
||||
@@ -94,6 +94,7 @@ impl TextObject {
|
||||
para: ParaStyle::default(),
|
||||
paras: Vec::new(),
|
||||
first_para_continues: false,
|
||||
first_para_lead: None,
|
||||
area: AreaOptions::default(),
|
||||
path_effect: PathEffect::default(),
|
||||
path_align: PathAlign::default(),
|
||||
|
||||
@@ -271,6 +271,9 @@ pub struct ParaStyle {
|
||||
/// dashes, two ellipses, two two-dot leaders, a vertical kana repeat mark's two halves). Kept
|
||||
/// with kinsoku None, where it has no effect. Off by default.
|
||||
pub bunri_kinshi: bool,
|
||||
/// Kurikaeshi Moji Shori (Paragraph panel menu): a repeat mark (々, ゝ, ゞ, ヽ or ヾ) that starts
|
||||
/// a line is drawn as the character it repeats, and the text keeps the mark. Off by default.
|
||||
pub kurikaeshi_moji_shori: bool,
|
||||
/// Roman Hanging Punctuation (Paragraph panel menu): quotation marks, hyphens, full stops and
|
||||
/// commas starting or ending a line hang outside the margin, and asterisks, tildes, ellipses,
|
||||
/// dashes, colons and semicolons hang by half. East Asian punctuation hangs by burasagari.
|
||||
@@ -375,6 +378,8 @@ struct ParaStyleFile {
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
bunri_kinshi: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
kurikaeshi_moji_shori: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
roman_hanging: bool,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
kashida: Kashida,
|
||||
@@ -412,6 +417,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -439,6 +445,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -470,6 +477,7 @@ impl From<ParaStyleFile> for ParaStyle {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
@@ -496,6 +504,7 @@ impl From<ParaStyleFile> for ParaStyle {
|
||||
kinsoku,
|
||||
kinsoku_type,
|
||||
bunri_kinshi,
|
||||
kurikaeshi_moji_shori,
|
||||
roman_hanging,
|
||||
kashida,
|
||||
korean_line_break_anywhere,
|
||||
|
||||
+14
-10
@@ -167,7 +167,7 @@ struct Placing {
|
||||
layers: WrittenLayers,
|
||||
}
|
||||
|
||||
/// The layers an exporter writes besides the shown, printing ones
|
||||
/// The layers and objects an exporter writes besides the shown, printing ones
|
||||
/// ([`bake_document_placing_symbols`]). Template layers are never written.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub struct WrittenLayers {
|
||||
@@ -175,16 +175,19 @@ pub struct WrittenLayers {
|
||||
pub hidden: bool,
|
||||
/// Layers that do not print.
|
||||
pub non_printing: bool,
|
||||
/// Hidden objects other than layers (written hidden, as SVG writes them when it keeps hidden
|
||||
/// layers).
|
||||
pub hidden_objects: bool,
|
||||
}
|
||||
|
||||
/// Does the export leave `n` and everything in it out, while [`bake_document_placing_symbols`]
|
||||
/// bakes? A hidden object other than a layer, a template layer, and a hidden layer or a layer
|
||||
/// bakes? A template layer, and a hidden object other than a layer, a hidden layer or a layer
|
||||
/// that does not print when the export leaves those out ([`WrittenLayers`]).
|
||||
fn unwritten(n: &Node) -> bool {
|
||||
PLACING.with(|p| {
|
||||
p.borrow().as_ref().is_some_and(|p| match n.kind {
|
||||
NodeKind::Layer { template, printable, .. } => template || !(printable || p.layers.non_printing) || !(n.visible || p.layers.hidden),
|
||||
_ => !n.visible,
|
||||
_ => !(n.visible || p.layers.hidden_objects),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1047,13 +1050,14 @@ pub fn bake_document(doc: &Document) -> Option<Document> {
|
||||
/// (live geometry effects, color adjustments and the rest [`needs_bake`] counts, in its own art or
|
||||
/// in the art of the symbols it places) replaced by that art as the instance places it, baked
|
||||
/// ([`placed_symbol_art`]), so the art draws as on the canvas wherever the instance is. For
|
||||
/// exporters that write each instance's art in its place (PDF, print, EPS, DXF), rather than
|
||||
/// writing each symbol once. `clip_slices`: whether 9-slice cells are clipped
|
||||
/// ([`Document::place_symbol_art`]) or not ([`Document::place_symbol_art_unclipped`]), as the
|
||||
/// exporter places other instances. `layers`: the hidden layers and layers that do not print
|
||||
/// that the exporter writes. Instances the export does not write (hidden ones, those in hidden
|
||||
/// objects, on template layers, and on the layers `layers` leaves out) stay as they are. The
|
||||
/// symbols' own art is left as it is.
|
||||
/// exporters that write each instance's art in its place (PDF, print, EPS, DXF, EMF, WMF), and
|
||||
/// for SVG, which writes the instances of other symbols as one shared definition. `clip_slices`:
|
||||
/// whether 9-slice cells are clipped ([`Document::place_symbol_art`]) or not
|
||||
/// ([`Document::place_symbol_art_unclipped`]), as the exporter places other instances. `layers`:
|
||||
/// the hidden layers, layers that do not print and hidden objects that the exporter writes.
|
||||
/// Instances the export does not write (template layers, and the hidden objects and layers
|
||||
/// `layers` leaves out, with what is in them) stay as they are. The symbols' own art is left as
|
||||
/// it is.
|
||||
pub fn bake_document_placing_symbols(doc: &Document, clip_slices: bool, layers: WrittenLayers) -> Option<Document> {
|
||||
bake(doc, Some((clip_slices, vectorcraft_doc::MAX_SYMBOL_NODES, layers)))
|
||||
}
|
||||
|
||||
@@ -1328,7 +1328,7 @@ fn placing_symbols_keeps_the_instances_stain() {
|
||||
}
|
||||
|
||||
/// Every layer written, as DXF writes them (template layers are never written).
|
||||
const ALL: WrittenLayers = WrittenLayers { hidden: true, non_printing: true };
|
||||
const ALL: WrittenLayers = WrittenLayers { hidden: true, non_printing: true, hidden_objects: false };
|
||||
|
||||
fn is_instance(d: &Document, id: u64) -> bool {
|
||||
d.node(NodeId(id)).is_some_and(|n| matches!(n.kind, NodeKind::SymbolInstance { .. }))
|
||||
@@ -1455,10 +1455,20 @@ fn placing_symbols_skips_instances_the_export_leaves_out() {
|
||||
}
|
||||
// An export that writes the layers that do not print, or the hidden layers, places that
|
||||
// layer's instance first; the template layer's instance is never placed.
|
||||
for (layers, first) in [(WrittenLayers { non_printing: true, hidden: false }, 921), (WrittenLayers { non_printing: false, hidden: true }, 931)] {
|
||||
for (layers, first) in
|
||||
[(WrittenLayers { non_printing: true, ..WrittenLayers::default() }, 921), (WrittenLayers { hidden: true, ..WrittenLayers::default() }, 931)]
|
||||
{
|
||||
let out = bake(&d, Some((true, each, layers))).unwrap();
|
||||
assert!(!is_instance(&out, first) && is_instance(&out, 900) && is_instance(&out, 911), "{layers:?}");
|
||||
}
|
||||
// An export that writes hidden objects (SVG keeping hidden layers) places the hidden instance
|
||||
// first, and the instance in the hidden group would come next; the hidden layer's instance
|
||||
// stays, since that layer is still left out.
|
||||
let out = bake(&d, Some((true, each, WrittenLayers { hidden_objects: true, ..WrittenLayers::default() }))).unwrap();
|
||||
assert!(!is_instance(&out, 901), "the hidden instance is placed");
|
||||
for id in [900, 903, 911, 921, 931] {
|
||||
assert!(is_instance(&out, id), "{id} stays as it is");
|
||||
}
|
||||
}
|
||||
|
||||
/// `leaf` in `levels` groups, with ids from `id` up.
|
||||
|
||||
@@ -210,21 +210,21 @@ pub fn effect_catalog() -> Vec<EffectInfo> {
|
||||
CLASSIC_EXTRUDE,
|
||||
"Extrude & Bevel (Classic)…",
|
||||
&["Effect", "3D and Materials", "3D (Classic)"],
|
||||
"{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults are VectorCraft's own.",
|
||||
"{depth: pt (0..2000, 50), cap: bool (true: solid; false: hollow), bevel: none|classic|rounded|cove|step|ogee (none), bevelHeight: pt (1..100, 4; the bevel is as wide as it is tall), bevelInside: bool (false: added around the shape; true: carved into it), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face, hidden ones included, and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none|blackOverprint (black; the color the faces darken toward; none keeps the paint and adds only the highlight; blackOverprint keeps the paint and draws the shading over it as overprinting black, on the black plate, with no highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom, and with blackOverprint every face keeps its paint and swatch link whether it is on or off), drawHiddenFaces: bool (false; also draws the faces turned away, behind the others)}. The front face is the art, extruded backwards about the center of its bounds; a solid is built for the top fill and for each stroke, each in its own paint. The defaults are VectorCraft's own.",
|
||||
json!({"depth":50.0,"cap":true,"bevel":"none","bevelHeight":4.0,"bevelInside":false,"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"plastic","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"highlightIntensity":60.0,"highlightSize":90.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000","preserveSpotColors":false,"drawHiddenFaces":false}),
|
||||
),
|
||||
g(
|
||||
CLASSIC_REVOLVE,
|
||||
"Revolve (Classic)…",
|
||||
&["Effect", "3D and Materials", "3D (Classic)"],
|
||||
"{angle: degrees (0..360, 360; how far the profile sweeps round the axis), cap: bool (true: solid, the open ends closed; false: hollow), offset: pt (0..1000, 0; the axis's distance from the profile, a ring past 0), edge: left|right (left; the axis is at the left or the right edge of the profile's bounds), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none (black; the color the faces darken toward; none keeps the paint and adds only the highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom)}. The profile sweeps round a vertical axis, as Revolve's does, painted with the top fill (else the top stroke); every face is drawn, back to front. The defaults are VectorCraft's own.",
|
||||
"{angle: degrees (0..360, 360; how far the profile sweeps round the axis), cap: bool (true: solid, the open ends closed; false: hollow), offset: pt (0..1000, 0; the axis's distance from the profile, a ring past 0), edge: left|right (left; the axis is at the left or the right edge of the profile's bounds), rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: wireframe|none|diffuse|plastic (plastic; wireframe draws the edges of every face and fills none; none keeps the paint unlit; diffuse lights the faces softly; plastic adds a glossy highlight), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, every face whichever way it faces), highlightIntensity: % (0..100, 60; plastic only), highlightSize: % (0..100, 90; 100 broad, 0 a small spot; plastic only), blendSteps: integer (1..256, 25; how many levels the shading and the highlight are rounded to), shadingColor: black|custom|none|blackOverprint (black; the color the faces darken toward; none keeps the paint and adds only the highlight; blackOverprint keeps the paint and draws the shading over it as overprinting black, on the black plate, with no highlight), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, lighter where the highlight is, with black multiplied and overprinting where the faces darken, so a spot color keeps its plate; it does nothing while shadingColor is custom, and with blackOverprint every face keeps its paint and swatch link whether it is on or off)}. The profile sweeps round a vertical axis, as Revolve's does, painted with the top fill (else the top stroke); every face is drawn, back to front. The defaults are VectorCraft's own.",
|
||||
json!({"angle":360.0,"cap":true,"offset":0.0,"edge":"left","rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"plastic","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"highlightIntensity":60.0,"highlightSize":90.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000","preserveSpotColors":false}),
|
||||
),
|
||||
g(
|
||||
CLASSIC_ROTATE,
|
||||
"Rotate (Classic)…",
|
||||
&["Effect", "3D and Materials", "3D (Classic)"],
|
||||
"{rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: none|diffuse (diffuse; none keeps the paint unlit; diffuse lights the art softly), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, the art whichever way it faces), blendSteps: integer (1..256, 25; how many levels the shading is rounded to), shadingColor: black|custom|none (black; the color the art darkens toward; none keeps the paint), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, with black multiplied and overprinting where the art darkens, so a spot color keeps its plate; it does nothing while shadingColor is custom)}. Every fill and stroke turns as one flat plane about the center of the object's bounds, as Rotate's do, each in its own paint, and is seen from either side. The defaults are VectorCraft's own.",
|
||||
"{rotationX: degrees (-180..180, -21.88), rotationY: degrees (-180..180, -23.4), rotationZ: degrees (-180..180, 9.06; the defaults are the Off-Axis Front position), perspectiveAngle: degrees (0..160, 0; 0 is none, wider brings the eye nearer), surface: none|diffuse (diffuse; none keeps the paint unlit; diffuse lights the art softly), lights: null or array of 1..10 objects (intensity: % 0..100, rotation: degrees -180..180, height: degrees 0..90, behind: bool; overrides the single-light fields; the lights add up; color and softness are not used), lightRotation: degrees (-180..180, 125.26; round the object on the page, 0 on its right, counterclockwise), lightHeight: degrees (0..90, 30; 0 beside the object, 90 straight in front), lightBehind: bool (false; true lights it from behind), lightIntensity: % (0..100, 100), ambient: % (0..100, 50; Ambient Light, the art whichever way it faces), blendSteps: integer (1..256, 25; how many levels the shading is rounded to), shadingColor: black|custom|none|blackOverprint (black; the color the art darkens toward; none keeps the paint; blackOverprint keeps the paint and draws the shading over it as overprinting black, on the black plate), shadingCustom: #rrggbb (#000000; the color shadingColor custom darkens toward), preserveSpotColors: bool (false; a color linked to a spot or global swatch stays a tint of that swatch, with black multiplied and overprinting where the art darkens, so a spot color keeps its plate; it does nothing while shadingColor is custom, and with blackOverprint the art keeps its paint and swatch link whether it is on or off)}. Every fill and stroke turns as one flat plane about the center of the object's bounds, as Rotate's do, each in its own paint, and is seen from either side. The defaults are VectorCraft's own.",
|
||||
json!({"rotationX":-21.88,"rotationY":-23.4,"rotationZ":9.06,"perspectiveAngle":0.0,"surface":"diffuse","lights":null,"lightRotation":125.26438968275465,"lightHeight":30.0,"lightBehind":false,"lightIntensity":100.0,"ambient":50.0,"blendSteps":25,"shadingColor":"black","shadingCustom":"#000000","preserveSpotColors":false}),
|
||||
),
|
||||
g(
|
||||
|
||||
@@ -103,8 +103,8 @@ pub use solids::{
|
||||
with_graphic,
|
||||
};
|
||||
pub use solids::{
|
||||
GRAPHIC_MAX_OFFSET, GRAPHIC_SCALE_RANGE, GRAPHICS_NOT_TAKEN, appearance_graphic_symbols, graphic_frame_at, graphics_reshaped_after,
|
||||
rename_appearance_graphic_symbol,
|
||||
GRAPHIC_MAX_OFFSET, GRAPHIC_SCALE_RANGE, GRAPHICS_NOT_TAKEN, appearance_graphic_symbols, exports_three_d, graphic_frame_at,
|
||||
graphics_reshaped_after, rename_appearance_graphic_symbol,
|
||||
};
|
||||
pub use stylize::{ScribbleSetting, scribble_setting_id, scribble_settings};
|
||||
pub use svg_filter::SVG_FILTER;
|
||||
|
||||
@@ -175,6 +175,20 @@ pub(crate) fn footprint(path: &vectorcraft_geom::BezPath, seam: f64) -> vectorcr
|
||||
/// every face is a facet a surface draws: a path filled and stroked by its seam, or a facet composed
|
||||
/// in a clip of its footprint, neither with an opacity mask.
|
||||
pub(crate) fn sealed(id: vectorcraft_doc::NodeId, faces: &[std::sync::Arc<vectorcraft_doc::Node>]) -> Option<vectorcraft_doc::Node> {
|
||||
use std::sync::Arc;
|
||||
use vectorcraft_doc::{Node, NodeKind};
|
||||
let (clip, mut underlay) = underlay(id, faces)?;
|
||||
underlay.extend(faces.iter().cloned());
|
||||
Some(Node::new(id, NodeKind::Group { children: vec![Arc::new(clip), Arc::new(Node::group(id, underlay))], clip: true }))
|
||||
}
|
||||
|
||||
/// The parts of [`sealed`] for `faces`: a path of the union of the facets' footprints, to clip to,
|
||||
/// and the facets grown to seams [`UNDERLAY_SEAM`] wide, in the same order. `None` under the same
|
||||
/// conditions as [`sealed`].
|
||||
pub(crate) fn underlay(
|
||||
id: vectorcraft_doc::NodeId,
|
||||
faces: &[std::sync::Arc<vectorcraft_doc::Node>],
|
||||
) -> Option<(vectorcraft_doc::Node, Vec<std::sync::Arc<vectorcraft_doc::Node>>)> {
|
||||
use std::sync::Arc;
|
||||
use vectorcraft_doc::{Appearance, Node, NodeKind};
|
||||
let mut outline = vectorcraft_geom::BezPath::new();
|
||||
@@ -207,9 +221,7 @@ pub(crate) fn sealed(id: vectorcraft_doc::NodeId, faces: &[std::sync::Arc<vector
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
let clip = Node::path(id, vectorcraft_geom::PathData::from_bezpath(&outline), Appearance::default());
|
||||
underlay.extend(faces.iter().cloned());
|
||||
Some(Node::new(id, NodeKind::Group { children: vec![Arc::new(clip), Arc::new(Node::group(id, underlay))], clip: true }))
|
||||
Some((Node::path(id, vectorcraft_geom::PathData::from_bezpath(&outline), Appearance::default()), underlay))
|
||||
}
|
||||
|
||||
/// Composite smooth solid-fill facets with one clip and three channel groups per surface. In each
|
||||
|
||||
+285
-19
@@ -296,11 +296,35 @@ fn paint_copies(faces: usize, paint: &Paint) -> usize {
|
||||
faces.saturating_mul(4).saturating_mul(paint_bytes(paint))
|
||||
}
|
||||
|
||||
/// Do Revolve's `options` light its surface with colored lights?
|
||||
fn colored(options: &Revolve) -> bool {
|
||||
options.light_color != [1.0; 3] || options.lights.is_some()
|
||||
}
|
||||
|
||||
/// Do Revolve's `faces` in `paint` lie over an underlay of themselves ([`sealed_run`])? Under
|
||||
/// colored lights (`colored`), in a solid color or a gradient, when a face takes a smooth light
|
||||
/// ramp ([`crate::lighting::rgb_gradient_art`], [`crate::lighting::gradient_art`],
|
||||
/// [`crate::lighting::smooth_paint`]). Not in a gradient with transparent stops: its composed faces
|
||||
/// carry its opacity mask, which the underlay does not take ([`crate::lighting::underlay`]).
|
||||
fn seals(faces: &[vectorcraft_three_d::Face], paint: &Paint, colored: bool) -> bool {
|
||||
colored
|
||||
&& (matches!(paint, Paint::Gradient(_)) || paint.color().is_some())
|
||||
&& faces.iter().any(|f| f.rgb_gradient.is_some() || f.light_gradient.is_some())
|
||||
&& crate::lighting::opaque_paint(paint).1.is_none()
|
||||
}
|
||||
|
||||
/// The bytes the copies of `paint` take on Revolve's `faces` ([`paint_copies`]), twice that when the
|
||||
/// faces lie over an underlay of themselves ([`seals`]).
|
||||
fn surface_copies(faces: &[vectorcraft_three_d::Face], paint: &Paint, colored: bool) -> usize {
|
||||
let copies = paint_copies(faces.len(), paint);
|
||||
if seals(faces, paint, colored) { copies.saturating_mul(2) } else { copies }
|
||||
}
|
||||
|
||||
/// An error when `path` does not revolve or when its surface in `item`'s paint takes `copies`, the
|
||||
/// bytes of an object's paint copies so far, past [`MAX_PAINT_COPIES`].
|
||||
fn check_surface(path: &PathData, b: Rect, options: Revolve, item: Option<&AppearanceItem>, copies: &mut usize) -> Result<(), String> {
|
||||
let faces = vectorcraft_three_d::revolve(path, b, options)?;
|
||||
*copies = copies.saturating_add(item.map_or(0, |i| paint_copies(faces.len(), &paint_of(i).0)));
|
||||
*copies = copies.saturating_add(item.map_or(0, |i| surface_copies(&faces, &paint_of(i).0, colored(&options))));
|
||||
if *copies > MAX_PAINT_COPIES {
|
||||
return Err("Revolve paint is too complex for this surface; reduce Segments or simplify the gradient".into());
|
||||
}
|
||||
@@ -438,7 +462,9 @@ fn group_shadow(
|
||||
/// with its classic surface, as Extrude & Bevel (Classic) does. Revolve's graphics, with the
|
||||
/// symbols of `doc`, are drawn on the faces of the side ([`crate::solids::graphics::surface_parts`]):
|
||||
/// a face with a part of a graphic is a group of the face and that part. With `cast`, the sweep
|
||||
/// that draws the surface also keeps the faces its shadow is cast from ([`SolidFaces`]).
|
||||
/// that draws the surface also keeps the faces its shadow is cast from ([`SolidFaces`]). The last
|
||||
/// value is whether the faces go over an underlay of themselves ([`seals`]): the caller seals them
|
||||
/// ([`sealed_surface`], [`sealed_runs`]) in the order it draws them.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn surface(
|
||||
doc: Option<&Document>,
|
||||
@@ -453,7 +479,7 @@ fn surface(
|
||||
expand: bool,
|
||||
copies: &mut Copies,
|
||||
cast: bool,
|
||||
) -> Option<(Vec<Drawn>, Node, Option<SolidFaces>)> {
|
||||
) -> Option<(Vec<Drawn>, Node, Option<SolidFaces>, bool)> {
|
||||
#[cfg(test)]
|
||||
crate::solids::SOLIDS_BUILT.with(|n| n.set(n.get() + 1));
|
||||
// A loaded file or a profile edited past the limits keeps drawing its source path instead
|
||||
@@ -473,15 +499,16 @@ fn surface(
|
||||
let drawn =
|
||||
facets.iter().map(|f| Drawn { depth: f.depth, points: f.contours.first().cloned().unwrap_or_default(), plane: f.plane }).collect();
|
||||
let p = merged_params(&fx.id, &fx.params);
|
||||
return Some((drawn, crate::solids::classic::surface(n, facets, &paint, opacity, blend, &p), kept));
|
||||
return Some((drawn, crate::solids::classic::surface(n, facets, &paint, opacity, blend, &p), kept, false));
|
||||
}
|
||||
let colored = options.light_color != [1.0; 3] || options.lights.is_some();
|
||||
let colored = colored(&options);
|
||||
let (faces, kept) = if cast {
|
||||
vectorcraft_three_d::revolve_shadowed(path, b, options).ok().map(|(f, kept)| (f, Some(kept)))?
|
||||
} else {
|
||||
(vectorcraft_three_d::revolve(path, b, options).ok()?, None)
|
||||
};
|
||||
copies.surfaces = copies.surfaces.saturating_add(paint_copies(faces.len(), &paint));
|
||||
let seal = seals(&faces, &paint, colored);
|
||||
copies.surfaces = copies.surfaces.saturating_add(surface_copies(&faces, &paint, colored));
|
||||
if copies.surfaces > MAX_PAINT_COPIES {
|
||||
return None;
|
||||
}
|
||||
@@ -604,7 +631,62 @@ fn surface(
|
||||
let mut group = Node::group(n.id, children);
|
||||
group.opacity = opacity;
|
||||
group.blend = blend;
|
||||
Some((keys, group, kept))
|
||||
Some((keys, group, kept, seal))
|
||||
}
|
||||
|
||||
/// Plain `surface` ([`surface`]: a group of its faces) over an underlay of its faces when `seal`
|
||||
/// ([`sealed_run`]), keeping the surface's opacity and blending mode.
|
||||
fn sealed_surface(id: NodeId, surface: Node, seal: bool) -> Node {
|
||||
let NodeKind::Group { children, clip: false } = &surface.kind else { return surface };
|
||||
let Some(mut out) = seal.then(|| sealed_run(id, children)).flatten() else { return surface };
|
||||
out.opacity = surface.opacity;
|
||||
out.blend = surface.blend;
|
||||
out
|
||||
}
|
||||
|
||||
/// The faces `run` of one surface, in drawing order, over an underlay of themselves, all clipped
|
||||
/// once to the faces' outline, as [`crate::lighting::sealed`] draws them. A face drawn with a part
|
||||
/// of a graphic, a group of the face and that part, takes its face's underlay and stays in the
|
||||
/// order with its part; the part is cut to its face's outline ([`crate::solids::graphics::surface_parts`]),
|
||||
/// so the clip keeps it. `None` when [`crate::lighting::underlay`] does not take the faces.
|
||||
fn sealed_run(id: NodeId, run: &[Arc<Node>]) -> Option<Node> {
|
||||
let faces: Vec<Arc<Node>> = run
|
||||
.iter()
|
||||
.map(|face| match &face.kind {
|
||||
NodeKind::Group { children, clip: false } => children.first().cloned(),
|
||||
_ => Some(face.clone()),
|
||||
})
|
||||
.collect::<Option<_>>()?;
|
||||
if faces.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let (clip, mut underlay) = crate::lighting::underlay(id, &faces)?;
|
||||
underlay.extend(run.iter().cloned());
|
||||
Some(Node::new(id, NodeKind::Group { children: vec![Arc::new(clip), Arc::new(Node::group(id, underlay))], clip: true }))
|
||||
}
|
||||
|
||||
/// `faces` in their drawing order, each with the index of its surface. Each run of consecutive
|
||||
/// faces of one surface that `seal` takes lies over an underlay of its own faces ([`sealed_run`]),
|
||||
/// so no underlay reaches under another surface's faces, as Inflate's surfaces do
|
||||
/// (`crate::solids::underlaid_runs`). A run the underlay does not take keeps its faces.
|
||||
fn sealed_runs(id: NodeId, faces: Vec<(usize, Arc<Node>)>, seal: impl Fn(usize) -> bool) -> Vec<Arc<Node>> {
|
||||
let mut out = Vec::with_capacity(faces.len());
|
||||
let mut run: Vec<Arc<Node>> = vec![];
|
||||
let mut faces = faces.into_iter().peekable();
|
||||
while let Some((surface, face)) = faces.next() {
|
||||
run.push(face);
|
||||
if faces.peek().is_some_and(|(next, _)| *next == surface) {
|
||||
continue;
|
||||
}
|
||||
match seal(surface).then(|| sealed_run(id, &run)).flatten() {
|
||||
Some(sealed) => {
|
||||
out.push(Arc::new(sealed));
|
||||
run.clear();
|
||||
}
|
||||
None => out.append(&mut run),
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A face [`surface`] draws: its depth and, for [`crate::solids::surface_order`], its polygon on the
|
||||
@@ -636,7 +718,8 @@ fn object_surface(
|
||||
let b = path.bounds()?;
|
||||
let (paint, opacity, blend) = paint_of(item);
|
||||
let cast = casts(fx, opacity);
|
||||
surface(doc, n, path, b, fx_options(fx), fx, paint, opacity, blend, expand, copies, cast).map(|(_, art, kept)| (art, kept))
|
||||
surface(doc, n, path, b, fx_options(fx), fx, paint, opacity, blend, expand, copies, cast)
|
||||
.map(|(_, art, kept, seal)| (sealed_surface(n.id, art, seal), kept))
|
||||
}
|
||||
|
||||
/// The paint of a graphic's solid color `c` on `face`, shaded as the face shades a solid fill of
|
||||
@@ -1055,6 +1138,8 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option<Node> {
|
||||
let mut surfaces = vec![];
|
||||
// The faces each member's surface kept for the shadow, member by member.
|
||||
let mut kept = vec![];
|
||||
// Whether each member's faces lie over an underlay of themselves ([`surface`]).
|
||||
let mut seals = vec![];
|
||||
let mut opaque = true;
|
||||
// The graphics go once, on the side of the member with the longest profile. Without graphics
|
||||
// no member is measured for them.
|
||||
@@ -1072,10 +1157,14 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option<Node> {
|
||||
let expand = expand && s.scopes.is_empty();
|
||||
let doc = doc.filter(|_| longest == Some(k));
|
||||
let cast = casts(fx, opacity * s.opacity);
|
||||
let (depths, art, faces) = surface(doc, n, &s.path, b, options, fx, paint, opacity, blend, expand, &mut copies, cast)?;
|
||||
let (depths, art, faces, seal) = surface(doc, n, &s.path, b, options, fx, paint, opacity, blend, expand, &mut copies, cast)?;
|
||||
surfaces.push((depths, art, s.scopes.as_slice()));
|
||||
kept.push(faces);
|
||||
seals.push(seal);
|
||||
}
|
||||
// The faces of a member whose surface takes an underlay lie over one, run by run in the one
|
||||
// order of every member's faces ([`sealed_runs`]).
|
||||
let seal = |member: usize| seals.get(member) == Some(&true);
|
||||
if surfaces.is_empty() {
|
||||
return None;
|
||||
}
|
||||
@@ -1101,7 +1190,7 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option<Node> {
|
||||
let order = crate::solids::surface_order(faces.iter().map(|(d, ..)| (d.points.as_slice(), d.plane, d.depth)));
|
||||
let faces = in_order(faces, &order);
|
||||
if opaque {
|
||||
vec![Arc::new(Node::group(n.id, faces.into_iter().map(|(.., face)| face).collect()))]
|
||||
vec![Arc::new(Node::group(n.id, sealed_runs(n.id, faces.into_iter().map(|(_, member, .., face)| (member, face)).collect(), seal)))]
|
||||
} else {
|
||||
// An opaque member's face goes in the order on its own. The faces of a member with
|
||||
// transparency share a run, one group with the opacity and blending mode of its fill or
|
||||
@@ -1110,6 +1199,8 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option<Node> {
|
||||
// where one group can't be both behind and in front of another face.
|
||||
struct Run<'a> {
|
||||
member: Option<usize>,
|
||||
// The member the faces are of.
|
||||
of: usize,
|
||||
scopes: &'a [Scope],
|
||||
bounds: Rect,
|
||||
faces: Vec<Arc<Node>>,
|
||||
@@ -1125,12 +1216,12 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option<Node> {
|
||||
let paints = opacity > 0.0 && scopes.iter().all(|s| s.opacity > 0.0);
|
||||
let Some(cover) = Coverage::of(&face).filter(|_| paints) else {
|
||||
// A face that paints nothing goes in the order on its own and overlaps nothing.
|
||||
runs.push(Run { member: None, scopes, bounds: Rect::ZERO, faces: vec![face], cover: vec![], opacity, blend });
|
||||
runs.push(Run { member: None, of: member, scopes, bounds: Rect::ZERO, faces: vec![face], cover: vec![], opacity, blend });
|
||||
continue;
|
||||
};
|
||||
let masked = masks.get(member).is_some_and(Option::is_some);
|
||||
if opacity >= 1.0 && blend == Default::default() && scopes.is_empty() && !masked {
|
||||
runs.push(Run { member: None, scopes, bounds: cover.bounds, faces: vec![face], cover: vec![cover], opacity, blend });
|
||||
runs.push(Run { member: None, of: member, scopes, bounds: cover.bounds, faces: vec![face], cover: vec![cover], opacity, blend });
|
||||
continue;
|
||||
}
|
||||
let mut clear = |r: &Run| {
|
||||
@@ -1153,24 +1244,49 @@ fn group_art(doc: Option<&Document>, n: &Node, expand: bool) -> Option<Node> {
|
||||
if let Some(last) = last_run.get_mut(member) {
|
||||
*last = Some(runs.len());
|
||||
}
|
||||
runs.push(Run { member: Some(member), scopes, bounds: cover.bounds, faces: vec![face], cover: vec![cover], opacity, blend });
|
||||
runs.push(Run {
|
||||
member: Some(member),
|
||||
of: member,
|
||||
scopes,
|
||||
bounds: cover.bounds,
|
||||
faces: vec![face],
|
||||
cover: vec![cover],
|
||||
opacity,
|
||||
blend,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
let runs = runs.into_iter().filter_map(|mut r| {
|
||||
// Consecutive faces of opaque members on their own wait in `solo` and go over an
|
||||
// underlay of their member's faces, run by run ([`sealed_runs`]).
|
||||
let mut out: Vec<(&[Scope], Arc<Node>)> = Vec::with_capacity(runs.len());
|
||||
let mut solo: Vec<(usize, Arc<Node>)> = vec![];
|
||||
for mut r in runs {
|
||||
// A face on its own needs a group only for the opacity or blending mode of its fill or stroke.
|
||||
if r.member.is_none() && r.opacity >= 1.0 && r.blend == Default::default() {
|
||||
return r.faces.pop().map(|face| (r.scopes, face));
|
||||
let Some(face) = r.faces.pop() else { continue };
|
||||
if r.scopes.is_empty() && !r.cover.is_empty() {
|
||||
solo.push((r.of, face));
|
||||
} else {
|
||||
out.extend(sealed_runs(n.id, std::mem::take(&mut solo), seal).into_iter().map(|face| (&[][..], face)));
|
||||
out.push((r.scopes, face));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let mut group = Node::group(n.id, r.faces);
|
||||
out.extend(sealed_runs(n.id, std::mem::take(&mut solo), seal).into_iter().map(|face| (&[][..], face)));
|
||||
let mut group = match r.member.filter(|m| seal(*m)).and_then(|_| sealed_run(n.id, &r.faces)) {
|
||||
Some(sealed) => sealed,
|
||||
None => Node::group(n.id, r.faces),
|
||||
};
|
||||
group.opacity = r.opacity;
|
||||
group.blend = r.blend;
|
||||
if let Some(mask) = r.member.and_then(|m| masks.get(m)).cloned().flatten() {
|
||||
group.extras_mut().mask = Some(mask);
|
||||
}
|
||||
Some((r.scopes, Arc::new(group)))
|
||||
});
|
||||
scoped(n.id, runs.collect(), 0)
|
||||
out.push((r.scopes, Arc::new(group)));
|
||||
}
|
||||
out.extend(sealed_runs(n.id, solo, seal).into_iter().map(|face| (&[][..], face)));
|
||||
scoped(n.id, out, 0)
|
||||
}
|
||||
};
|
||||
// One shadow for every member's surface, behind them all.
|
||||
@@ -1693,6 +1809,156 @@ mod tests {
|
||||
assert_eq!(revolve_art(&two), None, "past the budget the source draws");
|
||||
let object = painted(3, 0.0, stops * 2);
|
||||
assert!(validate_revolve(&object, &json!({})).is_err(), "one object past the budget");
|
||||
// Under a colored light the faces lie over an underlay of themselves, which copies their
|
||||
// paints again: the gradient that fits in white light is past the budget.
|
||||
let lit = json!({"lightColor": "#ff0000"});
|
||||
let object = painted(4, 0.0, stops);
|
||||
assert_eq!(validate_revolve(&object, &json!({})), Ok(()));
|
||||
let refused = validate_revolve(&object, &lit).unwrap_err();
|
||||
assert!(refused.contains("simplify the gradient"), "{refused}");
|
||||
let mut drawn = (*object).clone();
|
||||
drawn.appearance.effects.push(crate::new_effect(REVOLVE, &lit).unwrap());
|
||||
assert_eq!(revolve_art(&drawn), None, "past the budget the source draws");
|
||||
}
|
||||
|
||||
/// Is `u` the underlay [`crate::lighting::underlay`] draws for `face`, a face [`surface`] draws?
|
||||
fn underlies(u: &Node, face: &Node) -> bool {
|
||||
match (&u.kind, &face.kind) {
|
||||
(NodeKind::Path { .. }, NodeKind::Path { .. }) => {
|
||||
u.path_data() == face.path_data()
|
||||
&& u.appearance.items.iter().all(|i| !matches!(i, AppearanceItem::Stroke(s) if s.width != crate::lighting::UNDERLAY_SEAM))
|
||||
}
|
||||
(NodeKind::Group { children: under, clip: true }, NodeKind::Group { children, clip: true }) => {
|
||||
matches!((under.get(1), children.get(1)), (Some(a), Some(b)) if Arc::ptr_eq(a, b))
|
||||
}
|
||||
(_, NodeKind::Group { children, clip: false }) => children.first().is_some_and(|f| underlies(u, f)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// The runs of faces in `art` that lie over an underlay of themselves ([`sealed_run`]), each
|
||||
/// run's faces in drawing order.
|
||||
pub(super) fn sealed_faces(art: &Node) -> Vec<Vec<Arc<Node>>> {
|
||||
let mut out = vec![];
|
||||
art.walk(&mut |n| {
|
||||
let NodeKind::Group { children, clip: true } = &n.kind else { return };
|
||||
let [clip, inner] = &children[..] else { return };
|
||||
let NodeKind::Group { children: drawn, clip: false } = &inner.kind else { return };
|
||||
let (under, faces) = drawn.split_at(drawn.len() / 2);
|
||||
if clip.path_data().is_some() && !inner.isolate && drawn.len() % 2 == 0 && under.iter().zip(faces).all(|(u, f)| underlies(u, f)) {
|
||||
out.push(faces.to_vec());
|
||||
}
|
||||
});
|
||||
out
|
||||
}
|
||||
|
||||
/// `n`'s surface as [`surface`] draws it before its faces are sealed, and whether they are.
|
||||
fn unsealed(n: &Node) -> (Node, bool) {
|
||||
let path = n.path_data().unwrap();
|
||||
let fx = n.appearance.effects.first().unwrap();
|
||||
let (paint, opacity, blend) = paint_of(n.appearance.items.first().unwrap());
|
||||
let (_, art, _, seal) =
|
||||
surface(None, n, path, path.bounds().unwrap(), fx_options(fx), fx, paint, opacity, blend, false, &mut Copies::default(), false).unwrap();
|
||||
(art, seal)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn colored_light_faces_lie_over_an_underlay_of_themselves_once_per_surface() {
|
||||
use vectorcraft_doc::color::{BlendMode, Gradient, GradientKind, GradientPaint, GradientStop};
|
||||
let lit = |params: Value, paint: Paint| {
|
||||
let mut n = profile_node();
|
||||
n.appearance = Appearance::basic(paint, Paint::None, 0.0).into();
|
||||
n.appearance.effects.push(crate::new_effect(REVOLVE, ¶ms).unwrap());
|
||||
n
|
||||
};
|
||||
let red = Paint::solid(Color::rgb(0.8, 0.2, 0.1));
|
||||
let ramp = |opacity: f32| {
|
||||
let stops = [Color::WHITE, Color::rgb(0.5, 0.5, 0.5)].into_iter().enumerate();
|
||||
let stops = stops.map(|(i, c)| GradientStop { opacity, ..GradientStop::new(i as f32, c) }).collect();
|
||||
Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(GradientKind::Linear, stops))))
|
||||
};
|
||||
let lights = json!([{"color": "#ff8080", "rotation": 120.0}, {"color": "#8080ff", "rotation": -30.0}]);
|
||||
// In white light nothing is sealed.
|
||||
let white = lit(json!({}), red.clone());
|
||||
assert!(!unsealed(&white).1);
|
||||
assert!(sealed_faces(&revolve_art(&white).unwrap()).is_empty());
|
||||
for (name, n) in [
|
||||
("solid", lit(json!({"lightColor": "#ff0000"}), red.clone())),
|
||||
("gradient", lit(json!({"lightColor": "#ff0000"}), ramp(1.0))),
|
||||
("two lights", lit(json!({"lights": lights}), ramp(1.0))),
|
||||
("edge-on", lit(json!({"lightColor": "#ff0000", "rotationX": -80}), red.clone())),
|
||||
] {
|
||||
// Every face of the surface, in its order, lies over its underlay, once.
|
||||
let (plain, seal) = unsealed(&n);
|
||||
assert!(seal, "{name}");
|
||||
let faces = plain.children().unwrap().to_vec();
|
||||
assert_eq!(sealed_faces(&revolve_art(&n).unwrap()), vec![faces], "{name}");
|
||||
}
|
||||
// The surface's opacity and blending mode apply once, to the sealed surface.
|
||||
let mut n = lit(json!({"lightColor": "#ff0000"}), ramp(1.0));
|
||||
if let Some(AppearanceItem::Fill(f)) = n.appearance.items.first_mut() {
|
||||
f.opacity = 0.5;
|
||||
f.blend = BlendMode::Multiply;
|
||||
}
|
||||
let art = revolve_art(&n).unwrap();
|
||||
assert_eq!(sealed_faces(&art).len(), 1);
|
||||
// Inside the surface only a face's own lit art blends (its light multiplied over its paint).
|
||||
let once = |chain: &Chain| chain.first() == Some(&(0.5, BlendMode::Multiply)) && chain.iter().skip(1).all(|(o, _)| *o == 1.0);
|
||||
let faces = faces_in_order(&art);
|
||||
assert!(faces.iter().all(|(_, chain)| once(chain)), "{:?}", faces.iter().map(|f| &f.1).find(|c| !once(c)));
|
||||
// Faces in a gradient with transparent stops carry its opacity mask, which the underlay
|
||||
// does not take: the surface keeps its faces as they are, and their paints are not
|
||||
// counted twice.
|
||||
let n = lit(json!({"lightColor": "#ff0000"}), ramp(0.6));
|
||||
let (plain, seal) = unsealed(&n);
|
||||
assert!(!seal);
|
||||
assert_eq!(sealed_surface(n.id, plain.clone(), true), plain);
|
||||
assert!(sealed_faces(&revolve_art(&n).unwrap()).is_empty());
|
||||
let path = n.path_data().unwrap();
|
||||
let faces = vectorcraft_three_d::revolve(path, path.bounds().unwrap(), fx_options(&n.appearance.effects[0])).unwrap();
|
||||
assert_eq!(surface_copies(&faces, &ramp(0.6), true), paint_copies(faces.len(), &ramp(0.6)));
|
||||
assert_eq!(surface_copies(&faces, &ramp(1.0), true), 2 * paint_copies(faces.len(), &ramp(1.0)));
|
||||
// Revolve (Classic) takes no colored light, so none of its faces are sealed.
|
||||
assert!(!colored(&classic::options(&json!({"lightColor": "#ff0000"}))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_members_run_of_faces_lies_over_an_underlay_of_its_own() {
|
||||
// Rings one above the other: their faces alternate in the one order, so each ring's
|
||||
// faces go over underlays run by run, and no run holds faces of both.
|
||||
let ring = |id, y: f64, opacity: f32| {
|
||||
let mut n = (*member(id, 40.0)).clone();
|
||||
if let Some(AppearanceItem::Fill(f)) = n.appearance.items.first_mut() {
|
||||
f.opacity = opacity;
|
||||
}
|
||||
if let NodeKind::Path { path, .. } = &mut n.kind {
|
||||
*path = PathData::from_bezpath(&(Affine::translate((0.0, y)) * path.to_bezpath()));
|
||||
}
|
||||
Arc::new(n)
|
||||
};
|
||||
let lit = json!({"segments": 16, "lightColor": "#ff0000"});
|
||||
for opacity in [1.0, 0.5] {
|
||||
let members = vec![ring(1, 0.0, 1.0), ring(2, 200.0, opacity)];
|
||||
let art = revolve_art(&group_with(lit.clone(), members.clone())).unwrap();
|
||||
let runs = sealed_faces(&art);
|
||||
assert!(runs.len() >= 2, "{opacity}: {} runs", runs.len());
|
||||
for run in &runs {
|
||||
let ys: Vec<f64> = run.iter().filter_map(|f| f.visual_bounds()).map(|b| b.center().y).collect();
|
||||
assert!(ys.iter().all(|y| *y < 100.0) || ys.iter().all(|y| *y > 100.0), "{opacity}: a run holds one ring's faces: {ys:?}");
|
||||
}
|
||||
// Each ring's opacity applies once, to its faces and their underlays; inside, only a
|
||||
// face's own lit art blends.
|
||||
let faded = |chain: &Chain| chain.iter().filter(|(o, _)| *o != 1.0).count();
|
||||
let chains: Vec<Chain> = faces_in_order(&art).into_iter().map(|(_, c)| c).collect();
|
||||
assert!(chains.iter().all(|c| faded(c) <= 1 && c.iter().all(|(o, _)| *o == 1.0 || *o == opacity)), "{opacity}");
|
||||
assert_eq!(chains.iter().any(|c| faded(c) == 1), opacity < 1.0, "{opacity}");
|
||||
if opacity == 1.0 {
|
||||
// Opaque rings share one order, and every face in it lies over an underlay.
|
||||
let white = revolve_art(&group_with(json!({"segments": 16}), members)).unwrap();
|
||||
let count = white.children().unwrap()[0].children().unwrap().len();
|
||||
assert_eq!(runs.iter().map(Vec::len).sum::<usize>(), count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -164,6 +164,41 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// With Black Overprint every face keeps the blue, and the faces that darken get black over it,
|
||||
/// overprinting, as strong as the darkening of the shading color Black.
|
||||
#[test]
|
||||
fn black_overprint_keeps_the_blue_under_overprinting_black() {
|
||||
let darkened = revolved(json!({"surface": "diffuse"}));
|
||||
let art = revolved(json!({"surface": "diffuse", "shadingColor": "blackOverprint"}));
|
||||
let (darkened, drawn) = (faces(&darkened), faces(&art));
|
||||
assert_eq!(darkened.len(), drawn.len());
|
||||
let mut shaded = 0;
|
||||
for (face, black) in drawn.iter().zip(&darkened) {
|
||||
let fills: Vec<&vectorcraft_doc::FillLayer> = face
|
||||
.appearance
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|i| match i {
|
||||
AppearanceItem::Fill(f) => Some(f),
|
||||
AppearanceItem::Stroke(_) => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!((fills[0].paint.color(), fills[0].overprint), (Some(BLUE), false));
|
||||
let k = match fills.get(1) {
|
||||
Some(shadow) => {
|
||||
let Some(Color::Gray { k }) = shadow.paint.color() else { panic!("black shading: {:?}", shadow.paint) };
|
||||
assert_eq!((shadow.blend, shadow.overprint), (vectorcraft_doc::color::BlendMode::Multiply, true));
|
||||
shaded += 1;
|
||||
k
|
||||
}
|
||||
None => 0.0,
|
||||
};
|
||||
let b = fill(black).unwrap().to_rgb()[2];
|
||||
assert!((b - 0.8 * (1.0 - k)).abs() < 1e-3, "black at {k} matches the darkened blue {b}");
|
||||
}
|
||||
assert!(shaded > 0, "faces turned from the light get black");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn angle_offset_edge_and_cap_shape_the_surface() {
|
||||
let full = revolved(json!({"rotationX": 0, "rotationY": 0, "rotationZ": 0})).visual_bounds().unwrap();
|
||||
|
||||
@@ -279,6 +279,23 @@ fn under_several_lights_a_graphic_takes_each_faces_own_lit_art() {
|
||||
assert!(translucent > base && opaque - base == 2 * (translucent - base), "{base} {opaque} {translucent}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn under_a_colored_light_each_part_of_a_graphic_stays_right_after_its_face_over_the_underlay() {
|
||||
let d = document();
|
||||
let n = revolved(&CYLINDER, json!({"shade": true, "lightColor": "#ff8040", "graphics": [{"symbol": "Red"}]}));
|
||||
let art = revolve_art_in(Some(&d), &n).unwrap();
|
||||
// One run holds every face; a face with a part of the bar is a group of the face and that part.
|
||||
let runs = super::tests::sealed_faces(&art);
|
||||
assert_eq!(runs.len(), 1);
|
||||
let carrying: Vec<&Arc<Node>> = runs[0].iter().filter(|f| matches!(f.kind, NodeKind::Group { clip: false, .. })).collect();
|
||||
assert!(!carrying.is_empty());
|
||||
assert!(carrying.iter().all(|f| f.children().is_some_and(|c| c.len() > 1 && parts(&c[0], false).is_empty())));
|
||||
// Every part of the bar is drawn in the run, after its face, and none in the underlay.
|
||||
let in_run: usize = carrying.iter().map(|f| parts(f, false).len()).sum();
|
||||
assert!(in_run > 0);
|
||||
assert_eq!(in_run, parts(&art, false).len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn graphics_past_the_point_limit_are_refused() {
|
||||
let mut d = document();
|
||||
|
||||
@@ -102,6 +102,21 @@ pub fn has_solid(n: &Node) -> bool {
|
||||
solid(&n.appearance.effects).is_some() || n.appearance.items.iter().any(|i| i.visible() && solid(i.effects()).is_some())
|
||||
}
|
||||
|
||||
/// Does `n` carry a 3D effect that [`three_d_meshes`] builds solids from: a visible Revolve, or
|
||||
/// else a visible Extrude & Bevel, Inflate or Rotate effect, which on a group or layer must be on
|
||||
/// the object itself (one on a group's fill or stroke draws nothing to export)? It does not build
|
||||
/// the solids, so [`three_d_meshes`] can still refuse an object it passes.
|
||||
pub fn exports_three_d(n: &Node) -> bool {
|
||||
let container = is_container(n);
|
||||
if crate::has_revolve(n) {
|
||||
!container || n.appearance.effects.iter().any(|e| e.visible && crate::is_revolve(&e.id))
|
||||
} else if container {
|
||||
solid(&n.appearance.effects).is_some()
|
||||
} else {
|
||||
has_solid(n)
|
||||
}
|
||||
}
|
||||
|
||||
/// The Position presets: (id, [rotation X, Y, Z]). Front, Back, Left, Right, Top and Bottom face
|
||||
/// the art that way; Off-Axis tilts each 20° down and 25° aside (showing the top and right);
|
||||
/// Isometric lays the art on the left, right, top or bottom plane of an isometric view (the
|
||||
|
||||
@@ -20,8 +20,8 @@ pub const ROTATE_SURFACES: [&str; 2] = ["none", "diffuse"];
|
||||
/// The width of a Wireframe edge, in points.
|
||||
const WIRE: f64 = 0.5;
|
||||
|
||||
/// The Shading Color choices: black, a custom color, or none.
|
||||
pub const SHADING_COLORS: [&str; 3] = ["black", "custom", "none"];
|
||||
/// The Shading Color choices: black, a custom color, none, or black overprinting the paint.
|
||||
pub const SHADING_COLORS: [&str; 4] = ["black", "custom", "none", "blackOverprint"];
|
||||
|
||||
/// The surface settings of Extrude & Bevel (Classic)'s parameters.
|
||||
pub fn classic_shading(p: &Value) -> ClassicShading {
|
||||
@@ -55,8 +55,8 @@ pub fn classic_extrude_options(p: &Value) -> Extrude {
|
||||
}
|
||||
}
|
||||
|
||||
/// The color faces darken toward: black, the custom color, or none (faces keep their paint and only
|
||||
/// the highlight lightens them).
|
||||
/// The color faces darken toward: black (for Black Overprint too), the custom color, or none (faces
|
||||
/// keep their paint and only the highlight lightens them).
|
||||
fn shading_color(p: &Value) -> Option<Color> {
|
||||
match text(p, "shadingColor", "black") {
|
||||
"none" => None,
|
||||
@@ -200,27 +200,54 @@ fn preserves_spot_colors(p: &Value) -> bool {
|
||||
|
||||
/// A face of `paint`, a color linked to a swatch, with Preserve Spot Colors: the swatch at a lower
|
||||
/// tint for the highlight `spec`, its link kept so a spot color stays on its own plate, and, where
|
||||
/// tone `tone` is below full light and the faces darken (`shade`), black over it at `1 - tone`,
|
||||
/// multiplied and overprinting, so it prints on the black plate. `seam` is the width of the seam
|
||||
/// tone `tone` is below full light and the faces darken (`shade`), black over it as
|
||||
/// [`overprinting_black`] draws it, so it prints on the black plate. `seam` is the width of the seam
|
||||
/// stroke each layer draws around the face.
|
||||
fn linked_face(paint: &Paint, tone: f64, spec: f64, shade: Option<Color>, seam: f64) -> Vec<AppearanceItem> {
|
||||
let Paint::Solid { color, swatch, tint } = paint else { return vec![] };
|
||||
let keep = (1.0 - spec).clamp(0.0, 1.0) as f32;
|
||||
let fill = Paint::Solid { color: color.tinted(keep), swatch: swatch.clone(), tint: tint * keep };
|
||||
let mut items = vec![AppearanceItem::Fill(FillLayer::new(fill.clone())), AppearanceItem::Stroke(crate::lighting::seam_stroke(fill, seam))];
|
||||
if shade.is_some() && tone < 1.0 {
|
||||
let black = Paint::solid(Color::gray((1.0 - tone).clamp(0.0, 1.0) as f32));
|
||||
let mut layer = FillLayer::new(black.clone());
|
||||
layer.blend = BlendMode::Multiply;
|
||||
layer.overprint = true;
|
||||
let mut edge = crate::lighting::seam_stroke(black, seam);
|
||||
edge.blend = BlendMode::Multiply;
|
||||
edge.overprint = true;
|
||||
items.extend([AppearanceItem::Fill(layer), AppearanceItem::Stroke(edge)]);
|
||||
if shade.is_some() {
|
||||
items.extend(overprinting_black(tone, seam));
|
||||
}
|
||||
items
|
||||
}
|
||||
|
||||
/// The black that shades a face at tone `tone` on the black plate, when the tone is below full
|
||||
/// light: a fill of black at `1 - tone`, multiplied and overprinting, and its seam stroke `seam`
|
||||
/// wide, overprinting with Darken, so where the stroke lies over the face's own black, or over a
|
||||
/// neighbor's, the face is not darkened twice.
|
||||
fn overprinting_black(tone: f64, seam: f64) -> Vec<AppearanceItem> {
|
||||
if tone >= 1.0 {
|
||||
return vec![];
|
||||
}
|
||||
let black = Paint::solid(Color::gray((1.0 - tone).clamp(0.0, 1.0) as f32));
|
||||
let mut layer = FillLayer::new(black.clone());
|
||||
layer.blend = BlendMode::Multiply;
|
||||
layer.overprint = true;
|
||||
let mut edge = crate::lighting::seam_stroke(black, seam);
|
||||
edge.blend = BlendMode::Darken;
|
||||
edge.overprint = true;
|
||||
vec![AppearanceItem::Fill(layer), AppearanceItem::Stroke(edge)]
|
||||
}
|
||||
|
||||
/// Whether the shading color of parameters `p` is Black Overprint.
|
||||
fn black_overprint(p: &Value) -> bool {
|
||||
text(p, "shadingColor", "black") == "blackOverprint"
|
||||
}
|
||||
|
||||
/// A face of `paint` with Black Overprint: the paint unchanged, and where tone `tone` is below full
|
||||
/// light, black over it as [`overprinting_black`] draws it, so the paint's own inks print as they
|
||||
/// are and the shading prints on the black plate. The highlight is not drawn. `seam` is the width of
|
||||
/// the seam stroke each layer draws around the face.
|
||||
fn overprinted_face(paint: &Paint, tone: f64, seam: f64) -> Vec<AppearanceItem> {
|
||||
let mut items =
|
||||
vec![AppearanceItem::Fill(FillLayer::new(paint.clone())), AppearanceItem::Stroke(crate::lighting::seam_stroke(paint.clone(), seam))];
|
||||
items.extend(overprinting_black(tone, seam));
|
||||
items
|
||||
}
|
||||
|
||||
/// The width of the stroke [`surface`] draws around `face` with parameters `p`: a wire edge on
|
||||
/// Wireframe, else the seam between faces.
|
||||
pub(crate) fn stroke_width(face: &Facet, p: &Value) -> f64 {
|
||||
@@ -229,15 +256,17 @@ pub(crate) fn stroke_width(face: &Facet, p: &Value) -> f64 {
|
||||
|
||||
/// One solid's faces in paint `paint`, as a group with the paint's opacity and blend mode, one child
|
||||
/// for each facet: the edges of the faces on Wireframe, else each face filled in its paint shaded by
|
||||
/// its tone and highlight (with Preserve Spot Colors, a color linked to a swatch as [`linked_face`]
|
||||
/// draws it). A gradient with transparent stops is shaded opaque and then masked by
|
||||
/// its own transparency, so the shading follows the gradient's coverage; without a placement of its
|
||||
/// own, it is placed once on all the faces ([`crate::lighting::opaque_surface_paint`]).
|
||||
/// its tone and highlight (with Black Overprint, as [`overprinted_face`] draws it; with Preserve Spot
|
||||
/// Colors, a color linked to a swatch as [`linked_face`] draws it). A gradient with transparent stops
|
||||
/// is shaded opaque and then masked by its own transparency, so the shading follows the gradient's
|
||||
/// coverage; without a placement of its own, it is placed once on all the faces
|
||||
/// ([`crate::lighting::opaque_surface_paint`]).
|
||||
pub(crate) fn surface(n: &Node, facets: Vec<Facet>, source: &Paint, opacity: f32, blend: BlendMode, p: &Value) -> Node {
|
||||
let shading = classic_shading(p);
|
||||
let lights = lights(p);
|
||||
let shade = shading_color(p);
|
||||
let preserve = preserves_spot_colors(p);
|
||||
let overprint = black_overprint(p);
|
||||
let wire = shading.surface == ClassicSurface::Wireframe;
|
||||
let (paint, mask) = if wire { (source.clone(), None) } else { crate::lighting::opaque_surface_paint(source, || super::facets_bounds(&facets)) };
|
||||
let paint = &paint;
|
||||
@@ -252,6 +281,10 @@ pub(crate) fn surface(n: &Node, facets: Vec<Facet>, source: &Paint, opacity: f32
|
||||
let (tone, spec) = shading.tone(face.normal, &lights);
|
||||
// A narrow stroke of the face's own paint closes the hairline seams between faces.
|
||||
let seam = super::seam_width(&face);
|
||||
if overprint {
|
||||
let items = overprinted_face(paint, tone, seam);
|
||||
return Arc::new(Node::path(n.id, face.path(), Appearance { items, ..Default::default() }));
|
||||
}
|
||||
let items = match paint.color() {
|
||||
// Unshaded (No Shading, no shading color, or a face in full light) with no
|
||||
// highlight: the paint itself, its color space and swatch kept.
|
||||
|
||||
@@ -1908,6 +1908,89 @@ fn classic_shading_color_blend_steps_and_lights() {
|
||||
assert_eq!(with(json!({"drawHiddenFaces": true})).len(), 6);
|
||||
}
|
||||
|
||||
/// The fills, then the strokes, of face `face`.
|
||||
fn layers_of(face: &Node) -> (Vec<&vectorcraft_doc::FillLayer>, Vec<&StrokeLayer>) {
|
||||
let fills = face.appearance.items.iter().filter_map(|i| if let AppearanceItem::Fill(f) = i { Some(f) } else { None }).collect();
|
||||
let strokes = face.appearance.items.iter().filter_map(|i| if let AppearanceItem::Stroke(s) = i { Some(s) } else { None }).collect();
|
||||
(fills, strokes)
|
||||
}
|
||||
|
||||
/// The black over face `face` with Black Overprint, checked to be opaque and overprinting in
|
||||
/// both its fill (multiplied) and its seam stroke (Darken, so it does not darken the face twice);
|
||||
/// `None` when the face has none.
|
||||
fn overprinted_black(face: &Node) -> Option<f32> {
|
||||
let (fills, strokes) = layers_of(face);
|
||||
assert_eq!(fills.len(), strokes.len(), "each fill has its seam stroke");
|
||||
let shadow = fills.get(1)?;
|
||||
let Some(Color::Gray { k }) = shadow.paint.color() else { panic!("black shading: {:?}", shadow.paint) };
|
||||
assert_eq!((shadow.blend, shadow.overprint, shadow.opacity), (BlendMode::Multiply, true, 1.0));
|
||||
assert_eq!((strokes[1].paint.clone(), strokes[1].blend, strokes[1].overprint), (shadow.paint.clone(), BlendMode::Darken, true));
|
||||
assert!(!fills[0].overprint && !strokes[0].overprint, "the paint itself knocks out");
|
||||
Some(k)
|
||||
}
|
||||
|
||||
/// Black Overprint keeps the paint on every face and draws the shading over it as black,
|
||||
/// overprinting, as strong as the darkening of the shading color Black; the
|
||||
/// highlight is not drawn, and No Shading adds no black.
|
||||
#[test]
|
||||
fn classic_black_overprint_keeps_the_paint_under_overprinting_black() {
|
||||
let diffuse = json!({"surface": "diffuse", "ambient": 20});
|
||||
let mut over = diffuse.clone();
|
||||
over["shadingColor"] = json!("blackOverprint");
|
||||
let darkened: Vec<[f32; 3]> = classic_faces(diffuse).iter().map(fill_rgb).collect();
|
||||
let faces = classic_faces(over);
|
||||
assert_eq!(faces.len(), darkened.len());
|
||||
let mut shaded = 0;
|
||||
for (face, rgb) in faces.iter().zip(&darkened) {
|
||||
assert_eq!(layers_of(face).0[0].paint, Paint::solid(RED), "the paint is kept");
|
||||
let k = overprinted_black(face).unwrap_or(0.0);
|
||||
assert!((rgb[0] - 0.8 * (1.0 - k)).abs() < 1e-3, "black at {k} matches the darkened {rgb:?}");
|
||||
shaded += usize::from(k > 0.0);
|
||||
}
|
||||
assert!(shaded > 0, "faces turned from the light get black");
|
||||
// Plastic: no white layer for the highlight.
|
||||
let shiny = json!({"shadingColor": "blackOverprint", "highlightIntensity": 100, "highlightSize": 100, "lightHeight": 60});
|
||||
for face in classic_faces(shiny) {
|
||||
let (fills, _) = layers_of(&face);
|
||||
assert_eq!(fills[0].paint, Paint::solid(RED));
|
||||
assert!(fills.len() <= 2 && overprinted_black(&face).is_none_or(|k| k > 0.0), "{fills:?}");
|
||||
}
|
||||
// No Shading: the paint alone.
|
||||
for face in classic_faces(json!({"surface": "none", "shadingColor": "blackOverprint"})) {
|
||||
assert_eq!(overprinted_black(&face), None);
|
||||
assert_eq!(layers_of(&face).0[0].paint, Paint::solid(RED));
|
||||
}
|
||||
}
|
||||
|
||||
/// Black Overprint keeps a gradient fill on every face, with the black over it, and Rotate
|
||||
/// (Classic) draws its plane the same way.
|
||||
#[test]
|
||||
fn classic_black_overprint_keeps_gradients_and_shades_rotate() {
|
||||
use vectorcraft_doc::color::{Gradient, GradientKind, GradientPaint};
|
||||
let gradient = Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(
|
||||
GradientKind::Linear,
|
||||
vec![vectorcraft_doc::color::GradientStop::new(0.0, RED), vectorcraft_doc::color::GradientStop::new(1.0, BLUE)],
|
||||
))));
|
||||
let mut n = classic(json!({"shadingColor": "blackOverprint", "surface": "diffuse"}));
|
||||
if let Some(AppearanceItem::Fill(f)) = n.appearance.items.first_mut() {
|
||||
f.paint = gradient.clone();
|
||||
}
|
||||
let art = solid_art(&n).unwrap();
|
||||
let mut shaded = 0;
|
||||
for face in faces(&art) {
|
||||
assert_eq!(layers_of(face).0[0].paint, gradient);
|
||||
shaded += usize::from(overprinted_black(face).is_some());
|
||||
}
|
||||
assert!(shaded > 0);
|
||||
// Rotate (Classic), turned from the light: red with black over it; facing it: red alone.
|
||||
let turned = classic_rotate(json!({"rotationX": 0, "rotationY": 70, "rotationZ": 0, "lightHeight": 90, "shadingColor": "blackOverprint"}));
|
||||
let face = &turned[0].children().unwrap()[0];
|
||||
assert_eq!(layers_of(face).0[0].paint, Paint::solid(RED));
|
||||
assert!(overprinted_black(face).is_some_and(|k| k > 0.05));
|
||||
let lit = classic_rotate(json!({"rotationX": 0, "rotationY": 0, "rotationZ": 0, "lightHeight": 90, "shadingColor": "blackOverprint"}));
|
||||
assert_eq!(overprinted_black(&lit[0].children().unwrap()[0]), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classic_bevel_height_extent_and_cap_shape_the_solid() {
|
||||
let bounds = |p: Value| solid_art(&classic(p)).unwrap().visual_bounds().unwrap();
|
||||
@@ -2134,9 +2217,12 @@ fn classic_parameters_are_checked() {
|
||||
let check = |p: Value| validate_solid(&n, CLASSIC_EXTRUDE, &crate::merged_params(CLASSIC_EXTRUDE, &p));
|
||||
assert!(check(json!({})).is_ok());
|
||||
assert!(check(json!({"surface": "wireframe", "shadingColor": "custom", "shadingCustom": "#12aBcd", "blendSteps": 256, "bevel": "ogee"})).is_ok());
|
||||
assert!(check(json!({"shadingColor": "blackOverprint"})).is_ok());
|
||||
for (p, says) in [
|
||||
(json!({"surface": "glossy"}), "`surface` must be one of wireframe, none, diffuse, plastic"),
|
||||
(json!({"shadingColor": "red"}), "`shadingColor` must be one of black, custom, none"),
|
||||
(json!({"shadingColor": "red"}), "`shadingColor` must be one of black, custom, none, blackOverprint"),
|
||||
(json!({"shadingColor": "blackoverprint"}), "`shadingColor` must be one of"),
|
||||
(json!({"shadingColor": true}), "`shadingColor` must be one of"),
|
||||
(json!({"shadingCustom": "blue"}), "`shadingCustom` must be a #rrggbb color"),
|
||||
(json!({"shadingCustom": "#fff"}), "`shadingCustom` must be a #rrggbb color"),
|
||||
(json!({"depth": 2001}), "`depth` must be between 0 and 2000 (got 2001)"),
|
||||
@@ -2213,11 +2299,12 @@ fn classic_rotate_parameters_are_checked() {
|
||||
let check = |p: Value| validate_solid(&n, CLASSIC_ROTATE, &crate::merged_params(CLASSIC_ROTATE, &p));
|
||||
assert!(check(json!({})).is_ok());
|
||||
assert!(check(json!({"surface": "none", "shadingColor": "custom", "shadingCustom": "#12aBcd", "blendSteps": 1})).is_ok());
|
||||
assert!(check(json!({"shadingColor": "blackOverprint"})).is_ok());
|
||||
for (p, says) in [
|
||||
(json!({"surface": "plastic"}), "`surface` must be one of none, diffuse"),
|
||||
(json!({"surface": "wireframe"}), "`surface` must be one of none, diffuse"),
|
||||
(json!({"surface": 2}), "`surface` must be one of"),
|
||||
(json!({"shadingColor": "red"}), "`shadingColor` must be one of black, custom, none"),
|
||||
(json!({"shadingColor": "red"}), "`shadingColor` must be one of black, custom, none, blackOverprint"),
|
||||
(json!({"shadingCustom": "#fff"}), "`shadingCustom` must be a #rrggbb color"),
|
||||
(json!({"rotationX": 181}), "`rotationX` must be between -180 and 180 (got 181)"),
|
||||
(json!({"perspectiveAngle": 161}), "`perspectiveAngle` must be between 0 and 160 (got 161)"),
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::collections::HashSet;
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_doc::{ExportAsset, NodeId};
|
||||
|
||||
use super::edit::{roots_of, selected_roots};
|
||||
use super::edit::{refuse_symbol_part, roots_of, selected_roots};
|
||||
use super::fileio::{
|
||||
DEFAULT_FORMAT_3D, FORMATS_3D, SCREEN_SETTINGS_KEYS, check_screen_settings, create_dir, export_crop, export_screens, mesh_file_names, mesh_files,
|
||||
safe_file_name, store_screen_settings, with_screen_export_preset, write_file,
|
||||
@@ -62,7 +62,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Export 3D Object",
|
||||
[],
|
||||
None,
|
||||
"{ids?: [id…] (default: the selected objects), format?: usda|usdz|gltf|obj (default usda)} collect each object with an Extrude & Bevel, Revolve, Inflate or Rotate effect as a 3D asset of Window › Asset Export, named after the object (else Asset 1, Asset 2…): assets.export3D writes it as a mesh file. An object already collected as a 3D asset keeps it; an object without such an effect is refused → {assets: [asset id…] (in order), added: n}",
|
||||
"{ids?: [id…] (default: the selected objects), format?: usda|usdz|gltf|obj (default usda)} collect each object with an Extrude & Bevel, Revolve, Inflate or Rotate effect as a 3D asset of Window › Asset Export, named after the object (else Asset 1, Asset 2…): assets.export3D writes it as a mesh file. An object already collected as a 3D asset keeps it; an object in ids without such an effect is refused. Without ids, the selected objects without one (on a group or layer, one on its fill or stroke draws nothing and does not count), and a selected object inside another selected object that has one, are left out; refused when none is left → {assets: [asset id…] (in order), added: n}",
|
||||
has_doc,
|
||||
add_3d
|
||||
),
|
||||
@@ -203,10 +203,36 @@ fn three_d_asset_ids(d: &vectorcraft_doc::Document, p: &Value, key: &str, cmd: &
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
/// The selected objects `assets.add3D` collects without `ids`: those with a 3D effect it exports
|
||||
/// ([`vectorcraft_render::effects::exports_three_d`]; a path of a compound path counts as the
|
||||
/// compound path), layers included, in tree order, dropping
|
||||
/// each one inside another of them (that one's asset holds it). Refused while an object of a
|
||||
/// dynamic symbol instance's art is selected, as [`selected_roots`] is.
|
||||
fn selected_3d_roots(s: &Session) -> Result<Vec<NodeId>> {
|
||||
refuse_symbol_part(s)?;
|
||||
let st = s.doc()?;
|
||||
// A path of a compound path stands for the compound path, which holds the paint and effects.
|
||||
let found = st
|
||||
.selection
|
||||
.objects
|
||||
.iter()
|
||||
.map(|id| super::path::compound_or_self(&st.doc, *id))
|
||||
.filter(|id| st.doc.node(*id).is_some_and(vectorcraft_render::effects::exports_three_d));
|
||||
let mut paths: Vec<(Vec<usize>, NodeId)> = st.doc.index_paths(found).into_iter().map(|(id, path)| (path, id)).collect();
|
||||
paths.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
let mut kept: Vec<(Vec<usize>, NodeId)> = Vec::with_capacity(paths.len());
|
||||
for (path, id) in paths {
|
||||
if !kept.last().is_some_and(|(outer, _)| path.starts_with(outer)) {
|
||||
kept.push((path, id));
|
||||
}
|
||||
}
|
||||
Ok(kept.into_iter().map(|(_, id)| id).collect())
|
||||
}
|
||||
|
||||
fn add_3d(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "assets.add3D";
|
||||
let format = format_3d_param(p, C, Some(DEFAULT_FORMAT_3D))?;
|
||||
let ids = if p.get("ids").is_some_and(|v| !v.is_null()) { checked_ids_param(s, p, "ids", C)? } else { selected_roots(s)? };
|
||||
let ids = if p.get("ids").is_some_and(|v| !v.is_null()) { checked_ids_param(s, p, "ids", C)? } else { selected_3d_roots(s)? };
|
||||
if ids.is_empty() {
|
||||
return Err(bad(C, "select an object with a 3D effect (or give its ids)"));
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Clipboard Formats",
|
||||
[],
|
||||
None,
|
||||
"{} → {flavours: [mime…]} what Copy offers other apps for the current clipboard, best first, by the Clipboard Handling preferences: text/plain (a type-only copy's text, else the SVG markup with copyAsSvg when the images it embeds total at most 1 MiB), image/svg+xml (copyAsSvg), application/pdf (copyAsPdf), image/png (always; PDF and PNG only for objects with an area); the app publishes them on Copy and Cut",
|
||||
"{} → {flavours: [mime…]} what Copy offers other apps for the current clipboard, best first, by the Clipboard Handling preferences: text/plain (a type-only copy's text, else the SVG markup with copyAsSvg when the images it embeds total at most 1 MiB), image/svg+xml (copyAsSvg), application/pdf (copyAsPdf), image/png (always; PDF and PNG only for objects with an area); under read roots, SVG and its markup as text are left out when clipboard.exportSvg would refuse; the app publishes them on Copy and Cut",
|
||||
always,
|
||||
flavours
|
||||
),
|
||||
@@ -369,13 +369,20 @@ impl Session {
|
||||
|
||||
/// The MIME types of [`Self::clipboard_flavours`], without making them.
|
||||
pub fn clipboard_flavour_types(&self) -> Vec<&'static str> {
|
||||
self.clipboard.flavour_types(self.prefs.copy_as_svg, self.prefs.copy_as_pdf)
|
||||
self.clipboard.flavour_types(self.clipboard_svg_offered(), self.prefs.copy_as_pdf)
|
||||
}
|
||||
|
||||
/// What Copy offers other apps, best first (see `clipboard.flavours`): [`Clipboard::flavours`]
|
||||
/// by the Clipboard Handling preferences.
|
||||
/// by the Clipboard Handling preferences, without the SVG (and the SVG markup as text) that
|
||||
/// [`Self::clipboard_svg_refused`] withholds from the caller asking now.
|
||||
pub fn clipboard_flavours(&self) -> Vec<Flavour> {
|
||||
self.clipboard.flavours(self.prefs.copy_as_svg, self.prefs.copy_as_pdf)
|
||||
self.clipboard.flavours(self.clipboard_svg_offered(), self.prefs.copy_as_pdf)
|
||||
}
|
||||
|
||||
/// Does Copy offer the SVG: Include SVG Code is on and the SVG is not withheld from the caller
|
||||
/// asking now.
|
||||
fn clipboard_svg_offered(&self) -> bool {
|
||||
self.prefs.copy_as_svg && !self.clipboard_svg_refused()
|
||||
}
|
||||
|
||||
/// Replace the clipboard with `clip`, centred on `p`'s `center` (default: the first
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -501,8 +501,13 @@ fn damaged_slices_never_panic() {
|
||||
let mut f = base.clone();
|
||||
f[at] = v;
|
||||
let mut s = Session::new();
|
||||
let _ = s.execute("document.open", &json!({"name": "poster.psd", "dataBase64": b64(&f)}));
|
||||
let _ = s.execute("document.psdInfo", &json!({"dataBase64": b64(&f)}));
|
||||
// The engine's guard reports a panic as an internal error.
|
||||
for r in [
|
||||
s.execute("document.open", &json!({"name": "poster.psd", "dataBase64": b64(&f)})),
|
||||
s.execute("document.psdInfo", &json!({"dataBase64": b64(&f)})),
|
||||
] {
|
||||
assert!(!matches!(r, Err(crate::EngineError::Internal { .. })), "byte {at} set to {v}: {r:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ use vectorcraft_render::effects;
|
||||
|
||||
use super::edit::roots_of;
|
||||
use super::menucmds::{MAX_PIXELS, isolated_doc, unique_key};
|
||||
use super::pathops::{node_path, outline_strokes, outline_strokes_under, separate, shape_node};
|
||||
use super::pathops::{leaves, node_path, outline_strokes, separate, shape_node};
|
||||
use super::{CommandSpec, EngineError, Result, Session, always, bad, bool_or, cmd, has_doc, str_param, targets, unique_name};
|
||||
|
||||
mod analysis;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::analysis::{Scratch, finite, flatten_groups, has_effects, masked, outlined_text, overlapping, painted, reach};
|
||||
use super::compose::{Builder, CLEAR, Composer, Elem, Fill, Kind, Px, WHITE};
|
||||
use super::options::FlattenOptions;
|
||||
use super::{
|
||||
Affine, Appearance, AppearanceItem, Arc, BlendMode, Color, ColorMode, Document, EngineError, FillLayer, FillRule, ImageBlob, ImageObject, Inks,
|
||||
MAX_PIXELS, Node, NodeId, NodeKind, Paint, PathData, Rect, Result, composite, effects, isolated_doc, outline_strokes_under, planes_cmyk, po,
|
||||
MAX_PIXELS, Node, NodeId, NodeKind, Paint, PathData, Rect, Result, composite, effects, isolated_doc, leaves, outline_strokes, planes_cmyk, po,
|
||||
separate, shape_node, shapes, unique_key,
|
||||
};
|
||||
|
||||
@@ -14,6 +16,8 @@ pub(super) struct Plan {
|
||||
pub(super) flat: Vec<Flat>,
|
||||
/// Objects without transparency (they stay, but for the outline options).
|
||||
pub(super) kept: Vec<NodeId>,
|
||||
/// What the outline and overprint options do to each of `kept`, in its order.
|
||||
pub(super) work: Vec<Kept>,
|
||||
/// The objects with transparency of their own.
|
||||
pub(super) transparent: Vec<NodeId>,
|
||||
}
|
||||
@@ -112,7 +116,12 @@ pub(super) fn plan(src: &Document, roots: &[NodeId], o: &FlattenOptions, render:
|
||||
let reaches: Vec<Option<Rect>> = plain.iter().zip(&clipped).map(|(n, c)| reach(n).zip(reach(c)).map(|(a, b)| a.intersect(b))).collect();
|
||||
let see_through: Vec<bool> = plain.iter().map(|n| o.shows_transparency(&baked, n) || o.draws_see_through_image(n)).collect();
|
||||
let cmyk = src.color_mode == ColorMode::Cmyk;
|
||||
let mut out = Plan { flat: vec![], kept: vec![], transparent: roots.iter().zip(&see_through).filter(|(_, t)| **t).map(|(id, _)| *id).collect() };
|
||||
let mut out = Plan {
|
||||
flat: vec![],
|
||||
kept: vec![],
|
||||
work: vec![],
|
||||
transparent: roots.iter().zip(&see_through).filter(|(_, t)| **t).map(|(id, _)| *id).collect(),
|
||||
};
|
||||
// Baking above stopped early when cancelled; each group is a place to stop (a plan changes nothing).
|
||||
vectorcraft_doc::cancel::check()?;
|
||||
let mut queue = groups(src, roots, &plain, &reaches, &see_through, o)?;
|
||||
@@ -193,9 +202,101 @@ pub(super) fn plan(src: &Document, roots: &[NodeId], o: &FlattenOptions, render:
|
||||
};
|
||||
out.flat.push(Flat { roots: ids, regions, area, raster, lines });
|
||||
}
|
||||
out.work = out.kept.iter().map(|id| Kept::of(src, *id, o)).collect();
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// What the outline and overprint options do to one object without transparency, found in one
|
||||
/// walk of it.
|
||||
pub(super) struct Kept {
|
||||
pub(super) id: NodeId,
|
||||
/// Whether the options change it.
|
||||
pub(super) changes: bool,
|
||||
/// The type the text option outlines and the stroked paths the stroke option outlines, those
|
||||
/// that show and are not pieces of a compound path: what the Flattener Preview highlights.
|
||||
pub(super) shown_text: Vec<NodeId>,
|
||||
pub(super) shown_strokes: Vec<NodeId>,
|
||||
/// In paint order: the type the text option outlines and the leaf shapes ([`leaves`]) other
|
||||
/// than type that the stroke option outlines.
|
||||
steps: Vec<Step>,
|
||||
/// The objects with overprints, each with the type or leaf shape that holds it (itself
|
||||
/// included) when a step replaces that.
|
||||
overprinted: Vec<(NodeId, Option<NodeId>)>,
|
||||
}
|
||||
|
||||
/// One object [`apply`] outlines.
|
||||
enum Step {
|
||||
/// Type; `leaf`: only groups and layers hold it, so its outlines are leaf shapes for the
|
||||
/// stroke option.
|
||||
Text { id: NodeId, leaf: bool },
|
||||
/// A leaf shape other than type.
|
||||
Leaf(NodeId),
|
||||
}
|
||||
|
||||
/// Where [`Kept::visit`] is in the object it walks.
|
||||
#[derive(Clone, Copy)]
|
||||
struct At {
|
||||
/// Neither the node nor what holds it is hidden, and it is not a piece of a compound path.
|
||||
shown: bool,
|
||||
/// Only groups and layers hold the node.
|
||||
leaf: bool,
|
||||
/// The type or leaf shape holding the node that a step replaces.
|
||||
holder: Option<NodeId>,
|
||||
}
|
||||
|
||||
impl Kept {
|
||||
/// What the options `o` do to `root` of `d`: nothing when `d` doesn't hold it.
|
||||
fn of(d: &Document, root: NodeId, o: &FlattenOptions) -> Kept {
|
||||
let mut k = Kept { id: root, changes: false, shown_text: vec![], shown_strokes: vec![], steps: vec![], overprinted: vec![] };
|
||||
if let Some(n) = d.node(root) {
|
||||
k.visit(n, o, At { shown: true, leaf: true, holder: None });
|
||||
}
|
||||
k
|
||||
}
|
||||
|
||||
/// Note what the options `o` do to `n` and to everything under it.
|
||||
fn visit(&mut self, n: &Node, o: &FlattenOptions, at: At) {
|
||||
kept_seen(n);
|
||||
let shown = at.shown && n.visible;
|
||||
let mut holder = at.holder;
|
||||
if matches!(n.kind, NodeKind::Text(_)) {
|
||||
if o.text_to_outlines {
|
||||
self.changes = true;
|
||||
if shown {
|
||||
self.shown_text.push(n.id);
|
||||
}
|
||||
self.steps.push(Step::Text { id: n.id, leaf: at.leaf });
|
||||
holder = Some(n.id);
|
||||
}
|
||||
} else {
|
||||
if o.strokes_to_outlines && stroked(n) {
|
||||
self.changes = true;
|
||||
if shown {
|
||||
self.shown_strokes.push(n.id);
|
||||
}
|
||||
}
|
||||
if o.strokes_to_outlines && at.leaf && matches!(n.kind, NodeKind::Path { guide: false, clipping: false, .. } | NodeKind::Compound { .. })
|
||||
{
|
||||
self.steps.push(Step::Leaf(n.id));
|
||||
holder = Some(n.id);
|
||||
}
|
||||
}
|
||||
if !o.preserve_overprints && overprints(n) {
|
||||
self.changes = true;
|
||||
self.overprinted.push((n.id, holder));
|
||||
}
|
||||
let Some(children) = n.children() else { return };
|
||||
let inside = At {
|
||||
shown: shown && !matches!(n.kind, NodeKind::Compound { .. }),
|
||||
leaf: at.leaf && matches!(n.kind, NodeKind::Group { .. } | NodeKind::Layer { .. }),
|
||||
holder,
|
||||
};
|
||||
for c in children {
|
||||
self.visit(c, o, inside);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `roots` of `src` (`plain`: as plain art; `reaches`: where each can paint, clipped) in the
|
||||
/// groups that flatten together ([`flatten_groups`]), each in paint order, by their first object.
|
||||
/// Objects that overlap (as [`overlapping`] groups them) stay in one group when one of them is
|
||||
@@ -668,7 +769,7 @@ pub(crate) fn flatten_expanded(doc: &Document, o: &FlattenOptions) -> Result<Opt
|
||||
roots.extend(children.iter().skip(usize::from(l.clips())).filter(|c| c.visible && !c.is_ruler_guide()).map(|c| c.id));
|
||||
}
|
||||
let plan = plan(doc, &roots, o, true)?;
|
||||
if plan.flat.is_empty() && !plan.kept.iter().any(|id| doc.node(*id).is_some_and(|n| kept_work(n, o))) {
|
||||
if plan.flat.is_empty() && !plan.work.iter().any(|k| k.changes) {
|
||||
return Ok(None);
|
||||
}
|
||||
let mut d = doc.clone();
|
||||
@@ -753,19 +854,8 @@ pub(super) fn apply(d: &mut Document, sel: &mut vectorcraft_doc::Selection, plan
|
||||
d.insert(Some(layer), usize::MAX, guide)?;
|
||||
}
|
||||
let brushes = if o.strokes_to_outlines { vectorcraft_brush::library(d) } else { vec![] };
|
||||
for mut id in plan.kept {
|
||||
if o.text_to_outlines {
|
||||
id = outline_texts_under(d, id)?;
|
||||
}
|
||||
if o.strokes_to_outlines {
|
||||
id = outline_strokes_under(d, &brushes, id)?.0;
|
||||
}
|
||||
if !o.preserve_overprints
|
||||
&& let Some(n) = d.node_mut(id)
|
||||
{
|
||||
drop_overprints(n);
|
||||
}
|
||||
ids.push(id);
|
||||
for k in plan.work {
|
||||
ids.push(outline_kept(d, &brushes, k, o)?);
|
||||
}
|
||||
ids.sort_by_key(|id| d.index_path(*id));
|
||||
sel.set(ids.iter().copied());
|
||||
@@ -838,6 +928,21 @@ fn guide_seen(n: &Node) {
|
||||
#[cfg(not(test))]
|
||||
fn guide_seen(_: &Node) {}
|
||||
|
||||
#[cfg(test)]
|
||||
thread_local! {
|
||||
/// The nodes that [`Kept::of`] has looked at on this thread, in order.
|
||||
static KEPT_SEEN: std::cell::RefCell<Vec<NodeId>> = const { std::cell::RefCell::new(Vec::new()) };
|
||||
}
|
||||
|
||||
/// Note that [`Kept::of`] looked at `n`.
|
||||
#[cfg(test)]
|
||||
fn kept_seen(n: &Node) {
|
||||
KEPT_SEEN.with(|s| s.borrow_mut().push(n.id));
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
fn kept_seen(_: &Node) {}
|
||||
|
||||
/// An image of `r` (in a clip group when it is clipped).
|
||||
fn raster_node(d: &mut Document, r: Raster) -> Node {
|
||||
let key = unique_key(d, "flattened");
|
||||
@@ -858,38 +963,65 @@ fn raster_node(d: &mut Document, r: Raster) -> Node {
|
||||
crate::cmd::rasterfx::clip_group(d, path, FillRule::NonZero, image)
|
||||
}
|
||||
|
||||
/// Replace the type under `root` by its outlines: → the id now standing for `root`.
|
||||
fn outline_texts_under(d: &mut Document, root: NodeId) -> Result<NodeId> {
|
||||
let mut texts = vec![];
|
||||
if let Some(n) = d.node(root) {
|
||||
n.walk(&mut |c| {
|
||||
if matches!(c.kind, NodeKind::Text(_)) {
|
||||
texts.push(c.clone());
|
||||
/// Do what [`Kept`] `k` found to its object of `d` (`brushes`: the document's brushes, for the
|
||||
/// stroke option): its type outlined, then the strokes of its leaf shapes, the outlines of its
|
||||
/// type included, then its overprints dropped. → the id now standing for the object.
|
||||
fn outline_kept(d: &mut Document, brushes: &[vectorcraft_brush::Brush], k: Kept, o: &FlattenOptions) -> Result<NodeId> {
|
||||
let mut root = k.id;
|
||||
let mut replaced = HashSet::new();
|
||||
let dropping = !o.preserve_overprints;
|
||||
// Each replacement loses its overprints before it goes in: no new object is looked up.
|
||||
let mut put = |d: &mut Document, old: NodeId, mut new: Node, root: &mut NodeId| -> Result<()> {
|
||||
if dropping {
|
||||
drop_overprints(&mut new);
|
||||
}
|
||||
let nid = new.id;
|
||||
*d.node_mut(old).ok_or(EngineError::NoNode(old))? = new;
|
||||
replaced.insert(old);
|
||||
if old == *root {
|
||||
*root = nid;
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
// The leaf shapes of each outlined type that only groups and layers hold, by step.
|
||||
let mut outlined: Vec<Vec<Node>> = Vec::with_capacity(k.steps.len());
|
||||
for step in &k.steps {
|
||||
let mut lv = vec![];
|
||||
if let Step::Text { id, leaf } = *step
|
||||
&& let Some(out) = d.node(id).and_then(outlined_text)
|
||||
{
|
||||
let out = d.reid(&out);
|
||||
if leaf && o.strokes_to_outlines {
|
||||
leaves(&out, &mut lv);
|
||||
}
|
||||
});
|
||||
put(d, id, out, &mut root)?;
|
||||
}
|
||||
outlined.push(lv);
|
||||
}
|
||||
let mut out = root;
|
||||
for t in texts {
|
||||
let Some(o) = outlined_text(&t) else { continue };
|
||||
let o = d.reid(&o);
|
||||
let nid = o.id;
|
||||
*d.node_mut(t.id).ok_or(EngineError::NoNode(t.id))? = o;
|
||||
if t.id == root {
|
||||
out = nid;
|
||||
if o.strokes_to_outlines {
|
||||
for (step, lv) in k.steps.iter().zip(outlined) {
|
||||
let shapes = match *step {
|
||||
Step::Leaf(id) => d.node(id).cloned().into_iter().collect(),
|
||||
Step::Text { .. } => lv,
|
||||
};
|
||||
for l in shapes.iter().filter(|l| !matches!(l.kind, NodeKind::Text(_))) {
|
||||
if let Some(new) = outline_strokes(d, brushes, l) {
|
||||
put(d, l.id, new, &mut root)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Whether the outline and overprint options change `n`, an object without transparency.
|
||||
pub(super) fn kept_work(n: &Node, o: &FlattenOptions) -> bool {
|
||||
let mut any = false;
|
||||
n.walk(&mut |c| {
|
||||
any |= (o.text_to_outlines && matches!(c.kind, NodeKind::Text(_)))
|
||||
|| (o.strokes_to_outlines && stroked(c))
|
||||
|| (!o.preserve_overprints && overprints(c));
|
||||
});
|
||||
any
|
||||
if dropping {
|
||||
for (id, holder) in k.overprinted {
|
||||
if holder.is_some_and(|h| replaced.contains(&h)) {
|
||||
continue;
|
||||
}
|
||||
if let Some(n) = d.node_mut(id) {
|
||||
drop_own_overprints(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(root)
|
||||
}
|
||||
|
||||
/// Whether `n` is a path with a visible stroke (outlining turns it into a fill).
|
||||
@@ -898,12 +1030,8 @@ pub(super) fn stroked(n: &Node) -> bool {
|
||||
&& n.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Stroke(s) if s.visible && !s.paint.is_none() && s.width > 0.0))
|
||||
}
|
||||
|
||||
fn overprints(n: &Node) -> bool {
|
||||
n.appearance.items.iter().any(AppearanceItem::overprint)
|
||||
|| matches!(&n.kind, NodeKind::Text(t) if t.runs.iter().any(|r| r.style.overprint_fill || r.style.overprint_stroke))
|
||||
}
|
||||
|
||||
fn drop_overprints(n: &mut Node) {
|
||||
/// Drop the overprints of `n` itself.
|
||||
fn drop_own_overprints(n: &mut Node) {
|
||||
if overprints(n) {
|
||||
for i in &mut n.appearance.items {
|
||||
*i.overprint_mut() = false;
|
||||
@@ -914,6 +1042,16 @@ fn drop_overprints(n: &mut Node) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn overprints(n: &Node) -> bool {
|
||||
n.appearance.items.iter().any(AppearanceItem::overprint)
|
||||
|| matches!(&n.kind, NodeKind::Text(t) if t.runs.iter().any(|r| r.style.overprint_fill || r.style.overprint_stroke))
|
||||
}
|
||||
|
||||
/// Drop the overprints of `n` and of everything under it.
|
||||
fn drop_overprints(n: &mut Node) {
|
||||
drop_own_overprints(n);
|
||||
if let Some(ch) = n.children_mut() {
|
||||
for c in ch {
|
||||
drop_overprints(Arc::make_mut(c));
|
||||
@@ -994,6 +1132,208 @@ mod tests {
|
||||
assert_eq!(run(&[deep, deep]).0, vec![(sub, g2), (sub, g2)]);
|
||||
}
|
||||
|
||||
/// The objects [`kept_session`] makes.
|
||||
struct KeptArt {
|
||||
/// Each group with its stroked rectangle (its fill overprints) and its stroked type.
|
||||
groups: Vec<(NodeId, NodeId, NodeId)>,
|
||||
/// A stroked rectangle and stroked type with an overprint, on their own.
|
||||
rect: NodeId,
|
||||
text: NodeId,
|
||||
/// A stroked compound path and its pieces.
|
||||
compound: NodeId,
|
||||
pieces: Vec<NodeId>,
|
||||
/// A group holding an unstroked rectangle and a hidden stroked rectangle.
|
||||
hidden_group: NodeId,
|
||||
hidden: NodeId,
|
||||
/// An unstroked rectangle.
|
||||
plain: NodeId,
|
||||
}
|
||||
|
||||
/// A document without transparency: `n` groups, then the other objects of [`KeptArt`].
|
||||
fn kept_session(n: usize) -> (Session, KeptArt) {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
let id = |v: serde_json::Value| NodeId(v["id"].as_u64().unwrap());
|
||||
let rect = |s: &mut Session, x: f64| id(s.execute("shape.rectangle", &json!({"x": x, "y": 10, "width": 20, "height": 20})).unwrap());
|
||||
let text = |s: &mut Session, x: f64| {
|
||||
let t = id(s.execute("text.create", &json!({"x": x, "y": 80, "text": "Hi", "size": 24})).unwrap());
|
||||
s.execute("paint.setStroke", &json!({"color": "#000000", "ids": [t.0]})).unwrap();
|
||||
t
|
||||
};
|
||||
let select = |s: &mut Session, ids: &[NodeId]| {
|
||||
s.execute("select.set", &json!({"ids": ids.iter().map(|i| i.0).collect::<Vec<_>>()})).unwrap();
|
||||
};
|
||||
let overprint = |s: &mut Session, on: NodeId| {
|
||||
s.execute("attributes.set", &json!({"ids": [on.0], "overprintFill": true})).unwrap();
|
||||
};
|
||||
let unstroked = |s: &mut Session, on: NodeId| {
|
||||
s.execute("paint.setStroke", &json!({"none": true, "ids": [on.0]})).unwrap();
|
||||
};
|
||||
let mut groups = vec![];
|
||||
for i in 0..n {
|
||||
let x = (i % 10) as f64 * 30.0;
|
||||
let (r, t) = (rect(&mut s, x), text(&mut s, x));
|
||||
overprint(&mut s, r);
|
||||
select(&mut s, &[r, t]);
|
||||
groups.push((id(s.execute("object.group", &json!({})).unwrap()), r, t));
|
||||
}
|
||||
let (r, t) = (rect(&mut s, 0.0), text(&mut s, 100.0));
|
||||
overprint(&mut s, t);
|
||||
let (a, b) = (rect(&mut s, 200.0), rect(&mut s, 210.0));
|
||||
select(&mut s, &[a, b]);
|
||||
let compound = id(s.execute("object.compoundPath.make", &json!({})).unwrap());
|
||||
s.execute("paint.setStroke", &json!({"color": "#000000", "ids": [compound.0]})).unwrap();
|
||||
let pieces = s.doc().unwrap().doc.node(compound).unwrap().children().unwrap().iter().map(|c| c.id).collect();
|
||||
let (shown, hidden) = (rect(&mut s, 300.0), rect(&mut s, 310.0));
|
||||
unstroked(&mut s, shown);
|
||||
select(&mut s, &[shown, hidden]);
|
||||
let hidden_group = id(s.execute("object.group", &json!({})).unwrap());
|
||||
s.execute("object.hide", &json!({"ids": [hidden.0]})).unwrap();
|
||||
let plain = rect(&mut s, 350.0);
|
||||
unstroked(&mut s, plain);
|
||||
(s, KeptArt { groups, rect: r, text: t, compound, pieces, hidden_group, hidden, plain })
|
||||
}
|
||||
|
||||
/// Every option on: type and strokes outlined, overprints dropped.
|
||||
fn outlining() -> FlattenOptions {
|
||||
FlattenOptions { text_to_outlines: true, strokes_to_outlines: true, preserve_overprints: false, ..FlattenOptions::default() }
|
||||
}
|
||||
|
||||
/// The top-level objects of `d`'s first layer, in paint order.
|
||||
fn top_level(d: &Document) -> Vec<NodeId> {
|
||||
d.layers[0].children().unwrap().iter().map(|c| c.id).collect()
|
||||
}
|
||||
|
||||
fn sorted(mut ids: Vec<NodeId>) -> Vec<NodeId> {
|
||||
ids.sort();
|
||||
ids
|
||||
}
|
||||
|
||||
/// The nodes [`Kept::of`] looked at while `f` ran, sorted.
|
||||
fn kept_seen_by(f: impl FnOnce()) -> Vec<NodeId> {
|
||||
KEPT_SEEN.with(|v| v.borrow_mut().clear());
|
||||
f();
|
||||
sorted(KEPT_SEEN.with(|v| v.take()))
|
||||
}
|
||||
|
||||
/// The Flattener Preview, `object.flattenTransparency` and flattening a whole document each look
|
||||
/// at every node of the objects without transparency once, with type and strokes outlined and
|
||||
/// overprints dropped, an object they leave as it is included.
|
||||
#[test]
|
||||
fn kept_objects_are_looked_at_once() {
|
||||
let (mut s, _) = kept_session(100);
|
||||
let o = outlining();
|
||||
let doc = s.doc().unwrap().doc.clone();
|
||||
let roots = top_level(&doc);
|
||||
let mut nodes = vec![];
|
||||
for r in &roots {
|
||||
doc.node(*r).unwrap().walk(&mut |c| nodes.push(c.id));
|
||||
}
|
||||
nodes.sort();
|
||||
assert_eq!(nodes.len(), 309);
|
||||
let preview = kept_seen_by(|| drop(super::super::report::report(&doc, &roots, &o).unwrap()));
|
||||
assert!(preview == nodes, "the preview looked at {} nodes of {}", preview.len(), nodes.len());
|
||||
let whole = kept_seen_by(|| drop(flatten_document(&doc, &o).unwrap().unwrap()));
|
||||
assert!(whole == nodes, "flattening the document looked at {} nodes of {}", whole.len(), nodes.len());
|
||||
let ids: Vec<u64> = roots.iter().map(|r| r.0).collect();
|
||||
let command = kept_seen_by(|| {
|
||||
s.execute(
|
||||
"object.flattenTransparency",
|
||||
&json!({"ids": ids, "textToOutlines": true, "strokesToOutlines": true, "preserveOverprints": false}),
|
||||
)
|
||||
.unwrap();
|
||||
});
|
||||
assert!(command == nodes, "object.flattenTransparency looked at {} nodes of {}", command.len(), nodes.len());
|
||||
}
|
||||
|
||||
/// [`apply`]'s outlining of `kept` (objects of `d` without transparency) with `o`, done as a
|
||||
/// walk of each object for each option: → the ids standing for them, in paint order.
|
||||
fn outlined_walk_by_walk(d: &mut Document, kept: &[NodeId], o: &FlattenOptions) -> Vec<NodeId> {
|
||||
let brushes = if o.strokes_to_outlines { vectorcraft_brush::library(d) } else { vec![] };
|
||||
let mut ids = vec![];
|
||||
for &root in kept {
|
||||
let mut id = root;
|
||||
if o.text_to_outlines {
|
||||
let mut texts = vec![];
|
||||
d.node(id).unwrap().walk(&mut |c| {
|
||||
if matches!(c.kind, NodeKind::Text(_)) {
|
||||
texts.push(c.clone());
|
||||
}
|
||||
});
|
||||
for t in texts {
|
||||
let Some(out) = outlined_text(&t) else { continue };
|
||||
let out = d.reid(&out);
|
||||
if t.id == root {
|
||||
id = out.id;
|
||||
}
|
||||
*d.node_mut(t.id).unwrap() = out;
|
||||
}
|
||||
}
|
||||
if o.strokes_to_outlines {
|
||||
id = crate::cmd::pathops::outline_strokes_under(d, &brushes, id).unwrap().0;
|
||||
}
|
||||
if !o.preserve_overprints {
|
||||
drop_overprints(d.node_mut(id).unwrap());
|
||||
}
|
||||
ids.push(id);
|
||||
}
|
||||
ids.sort_by_key(|id| d.index_path(*id));
|
||||
ids
|
||||
}
|
||||
|
||||
/// With each mix of the text, stroke and overprint options, the objects without transparency
|
||||
/// end as a walk of each of them for each option leaves them: the same art, ids and selection.
|
||||
#[test]
|
||||
fn kept_objects_change_as_a_walk_per_option_changes_them() {
|
||||
let (s, _) = kept_session(3);
|
||||
let doc = Document::clone(&s.doc().unwrap().doc);
|
||||
let roots = top_level(&doc);
|
||||
for bits in 0..8u8 {
|
||||
let o = FlattenOptions {
|
||||
text_to_outlines: bits & 1 != 0,
|
||||
strokes_to_outlines: bits & 2 != 0,
|
||||
preserve_overprints: bits & 4 != 0,
|
||||
..FlattenOptions::default()
|
||||
};
|
||||
let p = plan(&doc, &roots, &o, true).unwrap();
|
||||
assert!(p.flat.is_empty(), "{o:?}");
|
||||
// In the order the plan's groups come in.
|
||||
let kept = p.kept.clone();
|
||||
assert_eq!(sorted(kept.clone()), sorted(roots.clone()), "{o:?}");
|
||||
let mut once = doc.clone();
|
||||
let mut sel = vectorcraft_doc::Selection::default();
|
||||
let (ids, ..) = apply(&mut once, &mut sel, p, &o).unwrap();
|
||||
let mut walked = doc.clone();
|
||||
let want = outlined_walk_by_walk(&mut walked, &kept, &o);
|
||||
assert_eq!(ids, want, "{o:?}");
|
||||
assert!(once == walked, "{o:?}");
|
||||
assert_eq!(once == doc, bits == 4, "{o:?}: only with every option off does nothing change");
|
||||
}
|
||||
}
|
||||
|
||||
/// The Flattener Preview lists the kept objects the options change, and of those the type and
|
||||
/// the stroked paths that show and are not pieces of a compound path.
|
||||
#[test]
|
||||
fn the_preview_lists_what_the_options_change_in_kept_objects() {
|
||||
let (s, a) = kept_session(2);
|
||||
let doc = &s.doc().unwrap().doc;
|
||||
let roots = top_level(doc);
|
||||
let r = super::super::report::report(doc, &roots, &outlining()).unwrap();
|
||||
let (g, rects, texts): (Vec<_>, Vec<_>, Vec<_>) =
|
||||
(a.groups.iter().map(|g| g.0).collect(), a.groups.iter().map(|g| g.1).collect(), a.groups.iter().map(|g| g.2).collect());
|
||||
assert_eq!(r.affected, [g.clone(), vec![a.rect, a.text, a.compound, a.hidden_group]].concat());
|
||||
// Both lists come in the order the plan's groups do.
|
||||
assert_eq!(sorted(r.text.clone()), sorted([texts, vec![a.text]].concat()));
|
||||
assert_eq!(sorted(r.strokes.clone()), sorted([rects, vec![a.rect, a.compound]].concat()));
|
||||
assert!(!r.strokes.contains(&a.hidden) && !r.strokes.iter().any(|id| a.pieces.contains(id)) && !r.affected.contains(&a.plain));
|
||||
// Dropping overprints alone changes the objects that overprint.
|
||||
let o = FlattenOptions { preserve_overprints: false, ..FlattenOptions::default() };
|
||||
let r = super::super::report::report(doc, &roots, &o).unwrap();
|
||||
assert_eq!((r.affected, r.text, r.strokes), ([g, vec![a.text]].concat(), vec![], vec![]));
|
||||
// With every option off, nothing.
|
||||
assert!(super::super::report::report(doc, &roots, &FlattenOptions::default()).unwrap().affected.is_empty());
|
||||
}
|
||||
|
||||
/// In a file without transparency with Clip Complex Regions on, art under a group's opaque
|
||||
/// image within one of its pixels joins the group, also where a long image is made at a lower
|
||||
/// resolution and its pixels are wider than at the preset's.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::analysis::draws_image;
|
||||
use super::apply::{apply, kept_work, plan};
|
||||
use super::apply::{apply, plan};
|
||||
use super::presets::{FlattenerPreset, saved_preset};
|
||||
use super::report::target_roots;
|
||||
use super::{BTreeSet, Deserialize, Document, EngineError, Node, NodeKind, Paint, Result, Serialize, Session, Value, bad, json, str_param};
|
||||
@@ -194,7 +194,7 @@ pub(super) fn flatten(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let plan = plan(&src, &roots, &o, true)?;
|
||||
let warning = crate::cmd::rasterfx::undecoded_warning(failed);
|
||||
let options = serde_json::to_value(&o).unwrap_or_default();
|
||||
if plan.flat.is_empty() && !plan.kept.iter().any(|id| src.node(*id).is_some_and(|n| kept_work(n, &o))) {
|
||||
if plan.flat.is_empty() && !plan.work.iter().any(|k| k.changes) {
|
||||
return Ok(json!({ "ids": roots.iter().map(|i| i.0).collect::<Vec<_>>(), "rasterized": 0, "vector": 0, "options": options }));
|
||||
}
|
||||
let (ids, vector, rasterized) = s.edit("Flatten Transparency", |d, sel| {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::apply::{kept_work, opaque, plan, stroked};
|
||||
use super::apply::{opaque, plan, stroked};
|
||||
use super::options::FlattenOptions;
|
||||
use super::{
|
||||
Appearance, Color, Deserialize, Document, Node, NodeId, NodeKind, Paint, PathData, Rect, Result, Serialize, Session, Value, bad, isolated_doc,
|
||||
@@ -263,15 +263,10 @@ pub fn report(doc: &Document, roots: &[NodeId], o: &FlattenOptions) -> Result<Fl
|
||||
r.rasterized.push(a.outline());
|
||||
}
|
||||
}
|
||||
for root in plan.kept.iter().filter_map(|id| doc.node(*id)).filter(|n| kept_work(n, o)) {
|
||||
r.affected.push(root.id);
|
||||
visit(root, &mut |n| {
|
||||
if o.text_to_outlines && matches!(n.kind, NodeKind::Text(_)) {
|
||||
r.text.push(n.id);
|
||||
} else if o.strokes_to_outlines && stroked(n) {
|
||||
r.strokes.push(n.id);
|
||||
}
|
||||
});
|
||||
for k in plan.work.iter().filter(|k| k.changes) {
|
||||
r.affected.push(k.id);
|
||||
r.text.extend(&k.shown_text);
|
||||
r.strokes.extend(&k.shown_strokes);
|
||||
}
|
||||
r.affected.sort_by_key(|id| doc.index_path(*id));
|
||||
Ok(r)
|
||||
|
||||
@@ -393,6 +393,16 @@ impl<'a> Plot<'a> {
|
||||
series_marks(self.g, i, series_fill, stroke, width)
|
||||
}
|
||||
|
||||
/// The stroke paint and width series `s`'s filled marks and its legend swatch get when the series keeps no stroke
|
||||
/// of its own: a white line between stacked segments, area bands and pie wedges, none on other marks.
|
||||
fn mark_stroke(&self, s: usize) -> (Paint, f64) {
|
||||
match self.kind(s) {
|
||||
GraphKind::StackedColumn | GraphKind::StackedBar | GraphKind::Area => (Paint::solid(Color::WHITE), 0.25),
|
||||
GraphKind::Pie => (Paint::solid(Color::WHITE), 0.5),
|
||||
_ => (Paint::None, 0.0),
|
||||
}
|
||||
}
|
||||
|
||||
fn series_label(&self, i: usize) -> String {
|
||||
self.g.series.get(i).cloned().unwrap_or_default()
|
||||
}
|
||||
@@ -471,7 +481,8 @@ impl<'a> Plot<'a> {
|
||||
}
|
||||
let sweep = v / total * std::f64::consts::TAU;
|
||||
let bp = wedge_path(ring, a0, sweep);
|
||||
let (fill, stroke, sw) = self.mark(s, true, Paint::solid(Color::WHITE), 0.5);
|
||||
let (stroke, width) = self.mark_stroke(s);
|
||||
let (fill, stroke, sw) = self.mark(s, true, stroke, width);
|
||||
let dark = is_dark(&fill);
|
||||
let n = self.b.path(PathData::from_bezpath(&bp), fill, stroke, sw);
|
||||
self.push_shadowed(s, n);
|
||||
@@ -887,7 +898,8 @@ impl<'a> Plot<'a> {
|
||||
let Some(base) = (if v >= 0.0 { pos.get_mut(ax) } else { neg.get_mut(ax) }) else { continue };
|
||||
let (v0, v1) = (geo.vpos(ax, *base), geo.vpos(ax, *base + v));
|
||||
*base += v;
|
||||
let paint = self.mark(s, true, Paint::solid(Color::WHITE), 0.25);
|
||||
let (stroke, width) = self.mark_stroke(s);
|
||||
let paint = self.mark(s, true, stroke, width);
|
||||
let rect = bar_rect(geo.horizontal, a, w, v0, v1);
|
||||
// A segment of 0 has no area to shade.
|
||||
let n = self.bar_node(Bar { s, rect, value: v, down: v1 < v0, per_unit: geo.per_unit(ax) }, paint, v != 0.0);
|
||||
@@ -907,7 +919,8 @@ impl<'a> Plot<'a> {
|
||||
let at = |c: usize, v: &[f64]| Point::new(geo.cat_mid(c), geo.vpos(a, v.get(c).copied().unwrap_or(0.0)));
|
||||
let mut pts: Vec<Point> = (0..ncat).map(|c| at(c, &above)).collect();
|
||||
pts.extend((0..ncat).rev().map(|c| at(c, below)));
|
||||
let (fill, stroke, w) = self.mark(s, true, Paint::solid(Color::WHITE), 0.25);
|
||||
let (stroke, width) = self.mark_stroke(s);
|
||||
let (fill, stroke, w) = self.mark(s, true, stroke, width);
|
||||
let n = self.b.path(polyline(&pts, true), fill, stroke, w);
|
||||
self.push_series(s, n);
|
||||
*below = above;
|
||||
@@ -951,10 +964,11 @@ impl<'a> Plot<'a> {
|
||||
}
|
||||
|
||||
/// The swatch of series `s` at `(x, y)`: series drawn with markers show their marker design in the legend, and
|
||||
/// series drawn with a column design that design.
|
||||
/// series drawn with a column design that design. A default swatch has the stroke of its series' marks.
|
||||
fn legend_swatch(&mut self, s: usize, (x, y): (f64, f64)) {
|
||||
let marked = matches!(self.g.kind, GraphKind::Scatter | GraphKind::Radar) || self.kind(s) == GraphKind::Line;
|
||||
let paint = self.mark(s, true, Paint::None, 0.0);
|
||||
let (stroke, width) = self.mark_stroke(s);
|
||||
let paint = self.mark(s, true, stroke, width);
|
||||
let column = nth(self.column_looks, s).filter(|_| self.columnar(s));
|
||||
let swatch = self.b.swatch(column, nth(&self.designs, s).filter(|_| marked), Rect::new(x, y, x + 8.0, y + 8.0), paint);
|
||||
self.push_series(s, swatch);
|
||||
|
||||
@@ -8449,7 +8449,102 @@ fn a_drawn_graph_saved_as_ai_opens_as_a_graph_unless_the_save_warns() {
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(live.contains(&"column v7.ai".to_string()) && live.contains(&"column pdf.ai".to_string()), "{live:?}");
|
||||
for ty in ["column", "stackedColumn", "area"] {
|
||||
assert!(live.contains(&format!("{ty} v7.ai")) && live.contains(&format!("{ty} pdf.ai")), "{ty}: {live:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A default legend swatch has the stroke paint and weight of its series' marks, beside the plot or across the top: the
|
||||
/// thin white line of stacked columns and bars, areas and pie wedges, and none on columns and bars. A stroke color kept
|
||||
/// on the series, with or without a weight of its own, is on the swatch too.
|
||||
#[test]
|
||||
fn a_legend_swatch_has_the_stroke_of_its_series_marks() {
|
||||
let white = |w: f64| (Paint::solid(vectorcraft_color::Color::WHITE), w);
|
||||
let cases = [
|
||||
("stackedColumn", white(0.25)),
|
||||
("stackedBar", white(0.25)),
|
||||
("area", white(0.25)),
|
||||
("pie", white(0.5)),
|
||||
("column", (Paint::None, 0.0)),
|
||||
("bar", (Paint::None, 0.0)),
|
||||
];
|
||||
for (ty, stroke) in cases {
|
||||
for across_top in [false, true] {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap();
|
||||
let csv = ",2024,2025\nQ1,3,2\nQ2,5,4\nQ3,1,6";
|
||||
let id = NodeId(
|
||||
s.execute("graph.create", &json!({"type": ty, "x": 100, "y": 100, "width": 300, "height": 200, "csv": csv})).unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap(),
|
||||
);
|
||||
s.execute("graph.setType", &json!({"id": id.0, "legendAcrossTop": across_top})).unwrap();
|
||||
for i in 0..2 {
|
||||
let marks = marks_of(&s, id, i);
|
||||
assert!(marks.len() > 1, "{ty} {i}: marks and a swatch");
|
||||
assert!(marks.iter().all(|m| (m.1.clone(), m.2) == stroke), "{ty} across top {across_top}, series {i}: {marks:?}");
|
||||
}
|
||||
// A stroke color kept on series 0 without a weight keeps the default weight, then with one.
|
||||
let bar = series(s.doc().unwrap().doc.node(id).unwrap(), 0).children().unwrap()[0].clone();
|
||||
let row = bar.appearance.items.iter().rposition(|it| !it.is_fill());
|
||||
let Some(row) = row else { continue };
|
||||
s.execute("appearance.setItem", &json!({"ids": [bar.id.0], "index": row, "color": "#ff0000"})).unwrap();
|
||||
s.execute("graph.setData", &json!({"id": id.0, "csv": csv})).unwrap();
|
||||
let marks = marks_of(&s, id, 0);
|
||||
assert!(marks.iter().all(|m| *m == marks[0]) && marks[0].1 != stroke.0, "{ty} across top {across_top}, red: {marks:?}");
|
||||
let bar = series(s.doc().unwrap().doc.node(id).unwrap(), 0).children().unwrap()[0].id;
|
||||
s.execute("appearance.setItem", &json!({"ids": [bar.0], "index": row, "weight": 3})).unwrap();
|
||||
s.execute("graph.setData", &json!({"id": id.0, "csv": csv})).unwrap();
|
||||
let marks = marks_of(&s, id, 0);
|
||||
assert!(marks.iter().all(|m| *m == marks[0]) && marks[0].2 == 3.0, "{ty} across top {across_top}, 3 pt: {marks:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A stacked column graph the graph tools draw, saved as `.ai` in either form, opens again as the same graph without a
|
||||
/// warning, and its data can be edited there.
|
||||
#[test]
|
||||
fn a_drawn_stacked_column_graph_saved_as_ai_opens_as_a_graph_that_takes_new_data() {
|
||||
let dir = vectorcraft_testkit::temp_dir("graph-ai-stacked");
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap();
|
||||
let csv = ",2024,2025\nQ1,3,2\nQ2,5,4\nQ3,1,6";
|
||||
let id = s.execute("graph.create", &json!({"type": "stackedColumn", "x": 100, "y": 100, "width": 300, "height": 200, "csv": csv})).unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
let written = spec(&s, NodeId(id));
|
||||
for (name, version) in [("v7.ai", Some("7")), ("pdf.ai", None)] {
|
||||
let path = dir.join(name);
|
||||
let mut p = json!({"path": path, "format": "ai"});
|
||||
if let Some(v) = version {
|
||||
p["aiVersion"] = json!(v);
|
||||
}
|
||||
let r = s.execute("file.saveAs", &p).unwrap();
|
||||
let notes = r["warnings"].as_array().cloned().unwrap_or_default();
|
||||
assert!(!notes.iter().any(|w| w.as_str().is_some_and(|w| w.starts_with("graphs are written as their art"))), "{name}: {r}");
|
||||
let mut again = Session::new();
|
||||
again.execute("document.open", &json!({"path": path})).unwrap();
|
||||
let mut found = vec![];
|
||||
again.doc().unwrap().doc.walk(|n| {
|
||||
if n.extras().graph.is_some() {
|
||||
found.push(n.id);
|
||||
}
|
||||
});
|
||||
assert_eq!(found.len(), 1, "{name}");
|
||||
let g = spec(&again, found[0]);
|
||||
assert_eq!((g.kind, g.cells()), (written.kind, written.cells()), "{name}");
|
||||
assert_eq!((g.series.as_slice(), g.categories.as_slice()), (&written.series[..], &written.categories[..]), "{name}");
|
||||
again.execute("select.set", &json!({"ids": [found[0].0]})).unwrap();
|
||||
again.execute("graph.setData", &json!({"id": found[0].0, "csv": ",2024,2025\nQ1,8,1\nQ2,2,7"})).unwrap();
|
||||
let after = spec(&again, found[0]);
|
||||
assert_eq!((after.kind, after.rows.as_slice()), (written.kind, &[vec![8.0, 1.0], vec![2.0, 7.0]][..]), "{name}");
|
||||
// Each series keeps one fill and the thin white stroke on its marks and its swatch.
|
||||
for i in 0..2 {
|
||||
let marks = marks_of(&again, found[0], i);
|
||||
let white = Paint::solid(vectorcraft_color::Color::WHITE);
|
||||
assert!(marks.len() > 1 && marks.iter().all(|m| *m == marks[0] && (&m.1, m.2) == (&white, 0.25)), "{name} series {i}: {marks:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A graph opened from a `.ai` keeps the bounds of its art without type, so moving one of its labels on its own
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -318,7 +318,7 @@ pub(crate) fn style_of(n: &Node) -> Style {
|
||||
|
||||
/// Leaf shapes (paths, compound paths, text) of a subtree in paint order; guides and clipping
|
||||
/// paths are skipped.
|
||||
fn leaves(n: &Node, out: &mut Vec<Node>) {
|
||||
pub(crate) fn leaves(n: &Node, out: &mut Vec<Node>) {
|
||||
each_leaf(n, &mut |l| out.push(l.clone()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1830,6 +1830,7 @@ fn create_in_path(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
para: super::create::new_type_para(),
|
||||
paras: Vec::new(),
|
||||
first_para_continues: false,
|
||||
first_para_lead: None,
|
||||
area: Default::default(),
|
||||
path_effect: Default::default(),
|
||||
path_align: Default::default(),
|
||||
@@ -2136,6 +2137,7 @@ fn headline_tracking(t: &TextObject, target: f64) -> Option<f64> {
|
||||
para: Default::default(),
|
||||
paras: Vec::new(),
|
||||
first_para_continues: false,
|
||||
first_para_lead: None,
|
||||
area: Default::default(),
|
||||
path_effect: Default::default(),
|
||||
path_align: Default::default(),
|
||||
|
||||
@@ -255,6 +255,7 @@ pub fn para_attrs(v: &ParaStyle) -> Map<String, Value> {
|
||||
("kinsoku", json!(v.kinsoku)),
|
||||
("kinsoku_type", json!(v.kinsoku_type)),
|
||||
("bunri_kinshi", json!(v.bunri_kinshi)),
|
||||
("kurikaeshi_moji_shori", json!(v.kurikaeshi_moji_shori)),
|
||||
("roman_hanging", json!(v.roman_hanging)),
|
||||
("kashida", json!(v.kashida)),
|
||||
("korean_line_break_anywhere", json!(v.korean_line_break_anywhere)),
|
||||
|
||||
@@ -225,7 +225,9 @@ pub(crate) fn reflow(before: &Document, doc: &mut Document) {
|
||||
.collect();
|
||||
let refs: Vec<&TextObject> = frames.iter().collect();
|
||||
let parts = vectorcraft_text::thread::distribute(vectorcraft_text::FontDb::global(), &refs, &story, ¶s);
|
||||
for (id, part) in live.iter().zip(parts) {
|
||||
let texts: Vec<String> = parts.iter().map(|p| p.runs.iter().map(|r| r.text.as_str()).collect()).collect();
|
||||
let leads = first_para_leads(&texts, &parts.iter().map(|p| p.continues).collect::<Vec<_>>());
|
||||
for ((id, part), lead) in live.iter().zip(parts).zip(leads) {
|
||||
if let Some(NodeKind::Text(t)) = doc.node_mut(*id).map(|n| &mut n.kind) {
|
||||
let mut next = (**t).clone();
|
||||
next.runs = part.runs;
|
||||
@@ -241,6 +243,7 @@ pub(crate) fn reflow(before: &Document, doc: &mut Document) {
|
||||
|| part.list_count != t.list_count
|
||||
|| part.list_level_counts != t.list_level_counts
|
||||
|| continues != t.first_para_continues
|
||||
|| lead != t.first_para_lead
|
||||
{
|
||||
t.runs = next.runs;
|
||||
t.para = next.para;
|
||||
@@ -250,6 +253,7 @@ pub(crate) fn reflow(before: &Document, doc: &mut Document) {
|
||||
t.list_count = part.list_count;
|
||||
t.list_level_counts = part.list_level_counts;
|
||||
t.first_para_continues = continues;
|
||||
t.first_para_lead = lead;
|
||||
refresh_bounds(t);
|
||||
}
|
||||
}
|
||||
@@ -384,17 +388,42 @@ pub(crate) fn mark_continued(doc: &mut Document) {
|
||||
let live: Vec<NodeId> = thread.into_iter().filter(|id| text_of(doc, *id).is_some()).collect();
|
||||
let frames: Vec<&TextObject> = live.iter().filter_map(|id| text_of(doc, *id)).collect();
|
||||
let marks = vectorcraft_text::thread::continued(&frames);
|
||||
for (id, on) in live.iter().zip(marks) {
|
||||
let texts: Vec<String> = frames.iter().map(|t| t.plain_text()).collect();
|
||||
let leads = first_para_leads(&texts, &marks);
|
||||
for ((id, on), lead) in live.iter().zip(marks).zip(leads) {
|
||||
if let Some(NodeKind::Text(t)) = doc.node_mut(*id).map(|n| &mut n.kind)
|
||||
&& t.first_para_continues != on
|
||||
&& (t.first_para_continues != on || t.first_para_lead != lead)
|
||||
{
|
||||
t.first_para_continues = on;
|
||||
t.first_para_lead = lead;
|
||||
refresh_bounds(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [`TextObject::first_para_lead`] for each frame of a thread, from the frames' plain `texts` and
|
||||
/// whether each one's first paragraph `continues` from the frame before: the last character of
|
||||
/// that paragraph in the frames before that a repeat mark could stand for, or None. One pass over
|
||||
/// the frames: each frame's lead is carried forward to the next.
|
||||
fn first_para_leads(texts: &[String], continues: &[bool]) -> Vec<Option<char>> {
|
||||
// The lead the next frame takes when its first paragraph continues from this one.
|
||||
let mut carry = None;
|
||||
texts
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(k, text)| {
|
||||
#[cfg(test)]
|
||||
LEAD_SCANS.with(|c| c.set(c.get() + 1));
|
||||
let lead = carry.filter(|_| continues.get(k) == Some(&true));
|
||||
let tail = text.rsplit('\n').next().unwrap_or(text);
|
||||
// A paragraph break in this frame ends the paragraph the lead came from.
|
||||
carry = vectorcraft_text::repeat_base(tail).or(lead.filter(|_| tail.len() == text.len()));
|
||||
lead
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
thread_local! {
|
||||
/// Tests: how many times [`story_of`] and [`ThreadIndex::of`] went through the document's
|
||||
@@ -402,6 +431,8 @@ thread_local! {
|
||||
static THREAD_SCANS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
/// Tests: how many times [`story_in`] went through a thread's frames on this thread.
|
||||
static STORY_BUILDS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
/// Tests: how many frame texts [`first_para_leads`] went through on this thread.
|
||||
static LEAD_SCANS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Tests: how many times [`story_of`] and [`ThreadIndex::of`] have gone through the document's
|
||||
@@ -417,6 +448,12 @@ pub(crate) fn story_builds() -> usize {
|
||||
STORY_BUILDS.with(std::cell::Cell::get)
|
||||
}
|
||||
|
||||
/// Tests: how many frame texts [`first_para_leads`] has gone through on this thread.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn lead_scans() -> usize {
|
||||
LEAD_SCANS.with(std::cell::Cell::get)
|
||||
}
|
||||
|
||||
/// The frames of the thread that `id` is a frame of, in thread order, each area type or type on a
|
||||
/// path; empty when `id` is in no thread or the thread has fewer than two such frames.
|
||||
pub(crate) fn story_of(d: &Document, id: NodeId) -> Vec<NodeId> {
|
||||
|
||||
@@ -2226,3 +2226,57 @@ fn paragraph_indents_check_every_entry_and_skip_a_change_that_changes_nothing()
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1);
|
||||
assert_eq!(text_of(&s.doc().unwrap().doc, NodeId(c)).unwrap().para_at(1).left_indent, 30.0);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: a frame whose first paragraph continues carries the last character of
|
||||
/// that paragraph in the frames before that a repeat mark can stand for, looking past frames that
|
||||
/// hold only repeat marks and stopping at the paragraph's start; a frame that starts a paragraph
|
||||
/// carries none. Flowing the story and opening a file both set it.
|
||||
#[test]
|
||||
fn a_continued_frame_carries_the_character_a_repeat_mark_stands_for() {
|
||||
let leads = |texts: &[&str], continues: &[bool]| first_para_leads(&texts.iter().map(|t| t.to_string()).collect::<Vec<_>>(), continues);
|
||||
assert_eq!(leads(&["時", "々す"], &[false, true]), [None, Some('時')]);
|
||||
assert_eq!(leads(&["時", "々", "々"], &[false, true, true]), [None, Some('時'), Some('時')]);
|
||||
assert_eq!(leads(&["時\nか\u{3099}", "ゝ"], &[false, true]), [None, Some('か')]);
|
||||
assert_eq!(leads(&["時\n々", "々"], &[false, true]), [None, None]);
|
||||
assert_eq!(leads(&["時\n", "々"], &[false, false]), [None, None]);
|
||||
assert_eq!(leads(&[], &[]), Vec::<Option<char>>::new());
|
||||
// Opening a file marks the frames as they were saved.
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 600, "height": 300})).unwrap();
|
||||
let mut ids = Vec::new();
|
||||
for (x, text) in [(10, "日時"), (200, "々す")] {
|
||||
let id =
|
||||
s.execute("text.create", &json!({"x": x, "y": 10, "text": text, "area": {"width": 150, "height": 60}})).unwrap()["id"].as_u64().unwrap();
|
||||
ids.push(NodeId(id));
|
||||
}
|
||||
let mut d = (*s.doc().unwrap().doc).clone();
|
||||
d.text_threads = vec![ids.clone()];
|
||||
mark_continued(&mut d);
|
||||
let tb = text_of(&d, ids[1]).unwrap();
|
||||
assert!(tb.first_para_continues);
|
||||
assert_eq!(tb.first_para_lead, Some('時'));
|
||||
// Flowing the story through the frames sets it from the text each frame now holds.
|
||||
reflow(&d.clone(), &mut d);
|
||||
let (ta, tb) = (text_of(&d, ids[0]).unwrap(), text_of(&d, ids[1]).unwrap());
|
||||
assert_eq!([ta.plain_text(), tb.plain_text()].concat(), "日時々す");
|
||||
assert!(tb.first_para_continues);
|
||||
assert_eq!(tb.first_para_lead, vectorcraft_text::repeat_base(&ta.plain_text()));
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the leads of a thread whose frames hold only repeat marks come from one
|
||||
/// pass over the frames, each frame's text gone through once, not once for every frame after it.
|
||||
#[test]
|
||||
fn continued_frame_leads_go_through_each_frame_once() {
|
||||
let n = 2000;
|
||||
let mut texts = vec!["時".to_string()];
|
||||
texts.extend(std::iter::repeat_n("々\u{2028}".to_string(), n - 1));
|
||||
let continues: Vec<bool> = (0..n).map(|k| k > 0).collect();
|
||||
let before = lead_scans();
|
||||
let leads = first_para_leads(&texts, &continues);
|
||||
assert!(lead_scans() - before <= n, "{} frame texts gone through for {n} frames", lead_scans() - before);
|
||||
assert_eq!(leads.first(), Some(&None));
|
||||
assert!(leads.iter().skip(1).all(|l| *l == Some('時')));
|
||||
// A paragraph break stops the carry, and a frame that starts a paragraph carries nothing.
|
||||
let leads = first_para_leads(&["時".into(), "々\nす".into(), "々".into(), "日".into(), "々".into()], &[false, true, true, false, true]);
|
||||
assert_eq!(leads, [None, Some('時'), Some('す'), None, Some('日')]);
|
||||
}
|
||||
|
||||
@@ -504,6 +504,62 @@ fn bunri_kinshi_is_set_per_paragraph_and_saved_only_when_on() {
|
||||
assert!(!text(&s).para_at(0).bunri_kinshi && !text(&s).para_at(1).bunri_kinshi);
|
||||
}
|
||||
|
||||
/// Paragraph panel menu › Kurikaeshi Moji Shori: off for new type and for a paragraph saved before
|
||||
/// it, and saved only when on; `text.setFormat {kurikaeshiMojiShori}` sets it per paragraph in one
|
||||
/// undo step, records nothing when the paragraphs already have the value, refuses a value that is
|
||||
/// not true or false, and paragraph styles carry it. The text keeps its repeat marks.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_is_set_per_paragraph_and_saved_only_when_on() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
|
||||
let id = s.execute("text.create", &json!({"x": 10, "y": 10, "size": 20, "text": "時々\nすゝ"})).unwrap()["id"].as_u64().unwrap();
|
||||
let text = |s: &Session| match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind {
|
||||
NodeKind::Text(t) => (**t).clone(),
|
||||
_ => panic!("text"),
|
||||
};
|
||||
assert!(!text(&s).para_at(0).kurikaeshi_moji_shori, "new type has it off");
|
||||
assert!(serde_json::to_value(text(&s).para_at(0)).unwrap().get("kurikaeshi_moji_shori").is_none());
|
||||
let old: vectorcraft_doc::ParaStyle = serde_json::from_value(json!({"justify": "Left"})).unwrap();
|
||||
assert!(!old.kurikaeshi_moji_shori, "saved before the option: off");
|
||||
s.execute("select.set", &json!({"ids": [id]})).unwrap();
|
||||
let steps = s.doc().unwrap().history.undo.len();
|
||||
// Only the second paragraph.
|
||||
let second = "時々\n".len();
|
||||
s.execute("text.setFormat", &json!({"kurikaeshiMojiShori": true, "start": second, "end": second})).unwrap();
|
||||
assert!(!text(&s).para_at(0).kurikaeshi_moji_shori && text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), steps + 1);
|
||||
assert_eq!(text(&s).plain_text(), "時々\nすゝ", "the text keeps its marks");
|
||||
// The same value again records nothing.
|
||||
s.execute("text.setFormat", &json!({"kurikaeshiMojiShori": true, "start": second, "end": second})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), steps + 1);
|
||||
let saved = serde_json::to_value(text(&s).para_at(1)).unwrap();
|
||||
assert_eq!(saved["kurikaeshi_moji_shori"], true);
|
||||
let back: vectorcraft_doc::ParaStyle = serde_json::from_value(saved).unwrap();
|
||||
assert!(back.kurikaeshi_moji_shori);
|
||||
let reopened = vectorcraft_format::load(&vectorcraft_format::save(&s.doc().unwrap().doc, false)).unwrap();
|
||||
let Some(NodeKind::Text(back)) = reopened.node(NodeId(id)).map(|n| &n.kind) else { panic!("text") };
|
||||
assert!(!back.para_at(0).kurikaeshi_moji_shori && back.para_at(1).kurikaeshi_moji_shori, "the file keeps it per paragraph");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(!text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert!(text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
for bad in [json!("yes"), json!(1)] {
|
||||
assert!(s.execute("text.setFormat", &json!({"ids": [id], "kurikaeshiMojiShori": bad, "kinsoku": "none"})).is_err(), "{bad}");
|
||||
}
|
||||
assert!(s.execute("text.setRangeStyle", &json!({"id": id, "kurikaeshiMojiShori": false})).is_err());
|
||||
assert!(
|
||||
text(&s).para_at(1).kurikaeshi_moji_shori && text(&s).para_at(1).kinsoku != vectorcraft_doc::Kinsoku::None,
|
||||
"a refused call changes nothing"
|
||||
);
|
||||
// A paragraph style carries it.
|
||||
s.execute("paraStyle.new", &json!({"name": "Repeats", "attrs": {"kurikaeshi_moji_shori": true}})).unwrap();
|
||||
s.execute("paraStyle.apply", &json!({"name": "Repeats", "id": id})).unwrap();
|
||||
assert!(text(&s).para_at(0).kurikaeshi_moji_shori && text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
s.execute("paraStyle.new", &json!({"name": "Marks", "attrs": {"kurikaeshi_moji_shori": false}})).unwrap();
|
||||
s.execute("paraStyle.apply", &json!({"name": "Marks", "id": id})).unwrap();
|
||||
assert!(!text(&s).para_at(0).kurikaeshi_moji_shori && !text(&s).para_at(1).kurikaeshi_moji_shori);
|
||||
}
|
||||
|
||||
/// Paragraph panel › Insert Kashidas: `text.setFormat {kashida}` sets it per paragraph in one
|
||||
/// undo step, the paragraph is saved with it only when it is not None and opens with it, an
|
||||
/// unknown value changes nothing, and paragraph styles carry it.
|
||||
|
||||
@@ -89,6 +89,45 @@ fn export_3d_object_refuses_objects_without_a_3d_effect_and_bad_formats() {
|
||||
assert_eq!(r["added"], 1);
|
||||
}
|
||||
|
||||
/// Without `ids`, the selected objects without a 3D effect, a group whose 3D effect is on its fill
|
||||
/// (it draws nothing to export) and a 3D object inside another selected one are left out; a
|
||||
/// selection with none left is refused.
|
||||
#[test]
|
||||
fn export_3d_object_leaves_flat_objects_in_the_selection_out() {
|
||||
let mut s = session();
|
||||
let plain = run(&mut s, "shape.rectangle", json!({"x": 10.0, "y": 100.0, "width": 40.0, "height": 30.0}))["id"].as_u64().unwrap();
|
||||
let filled = run(&mut s, "shape.rectangle", json!({"x": 10.0, "y": 200.0, "width": 40.0, "height": 30.0}))["id"].as_u64().unwrap();
|
||||
run(&mut s, "select.set", json!({"ids": [filled]}));
|
||||
let group = run(&mut s, "object.group", json!({}))["id"].as_u64().unwrap();
|
||||
run(&mut s, "select.set", json!({"ids": [group]}));
|
||||
run(&mut s, "appearance.addFill", json!({}));
|
||||
run(&mut s, "effect.apply", json!({"effect": "threeD.extrude"}));
|
||||
// `effect.apply` puts a group's 3D effect on the group itself; a file can hold one on its fill.
|
||||
s.edit("fill", |d, _| {
|
||||
let n = d.node_mut(vectorcraft_doc::NodeId(group)).unwrap();
|
||||
let fx = n.appearance.effects.remove(0);
|
||||
n.appearance.items[0].effects_mut().push(fx);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
run(&mut s, "select.set", json!({"ids": [plain, group]}));
|
||||
let before = undo_len(&s);
|
||||
assert!(s.execute("assets.add3D", &json!({})).is_err(), "no object with a 3D effect to export");
|
||||
assert_eq!(undo_len(&s), before);
|
||||
let inner = extruded(&mut s, 100.0, "Inner");
|
||||
let other = run(&mut s, "shape.rectangle", json!({"x": 200.0, "y": 10.0, "width": 40.0, "height": 30.0}))["id"].as_u64().unwrap();
|
||||
run(&mut s, "select.set", json!({"ids": [inner, other]}));
|
||||
let outer = run(&mut s, "object.group", json!({}))["id"].as_u64().unwrap();
|
||||
run(&mut s, "select.set", json!({"ids": [outer]}));
|
||||
run(&mut s, "effect.apply", json!({"effect": "threeD.extrude"}));
|
||||
run(&mut s, "select.set", json!({"ids": [plain, group, inner, outer]}));
|
||||
let r = run(&mut s, "assets.add3D", json!({}));
|
||||
assert_eq!(r["added"], 1, "{r}");
|
||||
let nodes: Vec<Value> = run(&mut s, "assets.list", json!({}))["assets"].as_array().unwrap().iter().map(|a| a["nodes"].clone()).collect();
|
||||
assert_eq!(nodes, [json!([outer])]);
|
||||
assert!(s.execute("assets.add3D", &json!({"ids": [plain, outer]})).is_err(), "ids are still refused");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_format_is_set_per_asset_and_only_a_change_is_an_undo_step() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -2117,6 +2117,35 @@ fn confined_clipboard_svg_refuses_a_linked_image_file_outside_the_read_roots() {
|
||||
assert!(svg.contains(&format!("xlink:href=\"{photo}\"")), "{svg}");
|
||||
}
|
||||
|
||||
/// `clipboard.flavours` and the session's flavors leave out the SVG, and its markup as text, that
|
||||
/// `clipboard.exportSvg` withholds from a confined caller; the PNG is still listed. The SVG is listed
|
||||
/// while its image's pixels are held, and for a caller with no read roots.
|
||||
#[test]
|
||||
fn confined_clipboard_flavours_leave_out_a_withheld_svg() {
|
||||
use crate::file_access::{AutomationRoots, confine};
|
||||
|
||||
let away = Folder::new("clip-flavours-away");
|
||||
let home = Folder::new("clip-flavours-home");
|
||||
let photo = away.file("photo.png");
|
||||
write(&photo, &png(60, 30, RED));
|
||||
let mut s = session();
|
||||
let a = place(&mut s, &photo);
|
||||
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
|
||||
s.execute("edit.copy", &json!({})).unwrap();
|
||||
let roots = AutomationRoots::new(&[home.0.as_path()], &[home.0.as_path()]).unwrap();
|
||||
let (text, svg, png) = ("text/plain", "image/svg+xml", "image/png");
|
||||
let listed = |s: &mut Session| confine(roots.as_ref(), || s.execute("clipboard.flavours", &json!({}))).unwrap()["flavours"].clone();
|
||||
assert_eq!(listed(&mut s), json!([text, svg, png]));
|
||||
|
||||
without_pixels(&mut s, a);
|
||||
s.execute("edit.copy", &json!({})).unwrap();
|
||||
assert_eq!(listed(&mut s), json!([png]));
|
||||
let made = confine(roots.as_ref(), || s.clipboard_flavours());
|
||||
assert!(made.iter().all(|f| f.mime != svg && f.mime != text), "{:?}", made.iter().map(|f| f.mime).collect::<Vec<_>>());
|
||||
assert_eq!(confine(roots.as_ref(), || s.clipboard_flavour_types()), [png]);
|
||||
assert_eq!(s.execute("clipboard.flavours", &json!({})).unwrap()["flavours"], json!([text, svg, png]));
|
||||
}
|
||||
|
||||
/// A confined caller's SVG with Preserve Editing Capabilities is refused while the stored brush
|
||||
/// library holds an entry that does not read as a brush, or is not a list: the native document
|
||||
/// carries it as it is, and its links cannot be checked. Without Preserve Editing the SVG is written.
|
||||
|
||||
@@ -276,3 +276,61 @@ fn overprint_black_covers_type_gradients_spots_and_groups() {
|
||||
s.execute("edit.colors.overprintBlack", &json!({"includeCmyBlacks": true, "includeSpotBlacks": true})).unwrap();
|
||||
assert!(fill(&s, g) && fill(&s, spot));
|
||||
}
|
||||
|
||||
/// The plate `plate` of `doc`, drawn as Separations Preview draws one plate, as one gray value per
|
||||
/// pixel (0 full ink, 255 none).
|
||||
fn plate(doc: &Document, plate: &str) -> Vec<u8> {
|
||||
let mut r = Renderer::new();
|
||||
r.threads = 0;
|
||||
let seps = vectorcraft_render::proof::ProofSetup { separations: Some(vec![plate.into()]), ..Default::default() };
|
||||
let opts = RenderOptions { background: Some([255, 255, 255, 255]), proof: Some(seps), ..Default::default() };
|
||||
let image = r.render(doc, 100, 100, Affine::IDENTITY, &opts);
|
||||
(0..100 * 100).map(|i| image.pixel(i % 100, i / 100)[0]).collect()
|
||||
}
|
||||
|
||||
/// 3D (Classic) with the shading color Black Overprint puts the shading on the black plate, shows
|
||||
/// it as the cyan darkened, and writes it to PDF as overprinting fills.
|
||||
#[test]
|
||||
fn classic_3d_black_overprint_shades_on_the_black_plate() {
|
||||
let doc = |params: Value| {
|
||||
let mut s = session();
|
||||
rect(&mut s, [30.0, 30.0, 40.0, 40.0], cyan_ink(), None, 0.0);
|
||||
s.execute("effect.apply", &json!({"effect": "threeD.classicExtrude", "item": null, "params": params})).unwrap();
|
||||
s
|
||||
};
|
||||
let over = doc(json!({"surface": "diffuse", "depth": 20, "shadingColor": "blackOverprint"}));
|
||||
let flat = doc(json!({"surface": "none", "depth": 20, "shadingColor": "blackOverprint"}));
|
||||
let black = doc(json!({"surface": "diffuse", "depth": 20}));
|
||||
let (over_doc, flat_doc) = (&over.doc().unwrap().doc, &flat.doc().unwrap().doc);
|
||||
let inked = |p: &[u8]| p.iter().filter(|v| **v < 250).count();
|
||||
assert!(inked(&plate(over_doc, "Cyan")) > 1000, "the solid is drawn");
|
||||
assert!(inked(&plate(over_doc, "Black")) > 100, "the shading is on the black plate");
|
||||
assert_eq!(inked(&plate(flat_doc, "Black")), 0, "No Shading adds no black");
|
||||
// On screen a shaded face is the cyan darkened, not gray: the black multiplies the cyan.
|
||||
let image = |d: &Document| {
|
||||
let mut r = Renderer::new();
|
||||
r.threads = 0;
|
||||
let opts = RenderOptions { background: Some([255, 255, 255, 255]), ..Default::default() };
|
||||
r.render(d, 100, 100, Affine::IDENTITY, &opts)
|
||||
};
|
||||
let (shaded, unshaded) = (image(over_doc), image(flat_doc));
|
||||
let mut darker = 0;
|
||||
for (x, y) in (0..100u32).flat_map(|y| (0..100u32).map(move |x| (x, y))) {
|
||||
let (s, u) = (shaded.pixel(x, y), unshaded.pixel(x, y));
|
||||
// Inside the solid (no white mixed in at an antialiased edge) where the shading darkens it.
|
||||
if u[0] < 30 && (s[1] as i32) + 20 < u[1] as i32 {
|
||||
darker += 1;
|
||||
assert!(s[2] as i32 > s[0] as i32 + 20, "a shaded face keeps its cyan at ({x}, {y}): {s:?}");
|
||||
}
|
||||
}
|
||||
assert!(darker > 100, "the faces turned from the light are darker");
|
||||
|
||||
let pdf_overprints = |s: &mut Session| {
|
||||
let v = s.execute("document.exportPdf", &json!({"compression": {"compressText": false}, "preserveEditing": false})).unwrap();
|
||||
let bytes = vectorcraft_format::base64_decode(v["dataBase64"].as_str().unwrap()).unwrap();
|
||||
String::from_utf8_lossy(&bytes).matches("/OP true/op true/OPM 1").count()
|
||||
};
|
||||
let (mut over, mut black) = (over, black);
|
||||
assert!(pdf_overprints(&mut over) > 0, "the black is written overprinting");
|
||||
assert_eq!(pdf_overprints(&mut black), 0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Untrusted files never crash the app: garbage, truncated, mutated and hostile SVG, PDF, DXF and HP-GL input,
|
||||
//! mutated raster images (Photoshop documents and JPEG XL images among them) placed with File → Place, and swatch (`.vcswatches`, `.gpl`, `.ase`), graphic style (`.vcstyles`), flattener preset
|
||||
//! mutated raster images (Photoshop documents and JPEG XL images among them) placed with File → Place, Photoshop documents' slices (damaged or cut short) opened and placed, and swatch (`.vcswatches`, `.gpl`, `.ase`), graphic style (`.vcstyles`), flattener preset
|
||||
//! (`.vcflattener`) and export preset (`.vcexportpresets`) libraries, shortcut sets and action sets other apps save as text (`.kys`, `.aia`), and native files (compressed, damaged, saved for older versions),
|
||||
//! must load as an error or as a document that then renders and exports, without a panic; nor may
|
||||
//! bitmaps, PDF and text pasted from other apps, nor EMF and WMF pictures (damaged files, records
|
||||
@@ -1939,6 +1939,271 @@ proptest! {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- PSD slices ----------
|
||||
|
||||
/// A Unicode string as a PSD file stores it: a count of UTF-16 units, then the units.
|
||||
fn psd_unicode(s: &str) -> Vec<u8> {
|
||||
let units: Vec<u16> = s.encode_utf16().collect();
|
||||
let mut b = (units.len() as u32).to_be_bytes().to_vec();
|
||||
b.extend(units.iter().flat_map(|u| u.to_be_bytes()));
|
||||
b
|
||||
}
|
||||
|
||||
/// A descriptor key or class ID: length 0 and its four characters, or its length and its characters.
|
||||
fn psd_key(k: &str) -> Vec<u8> {
|
||||
let mut b = if k.len() == 4 { 0u32 } else { k.len() as u32 }.to_be_bytes().to_vec();
|
||||
b.extend(k.as_bytes());
|
||||
b
|
||||
}
|
||||
|
||||
/// A descriptor's class (an empty name and the ID `null`), then the count of its items.
|
||||
fn psd_class(count: usize) -> Vec<u8> {
|
||||
let mut b = psd_unicode("");
|
||||
b.extend(psd_key("null"));
|
||||
b.extend((count as u32).to_be_bytes());
|
||||
b
|
||||
}
|
||||
|
||||
/// A descriptor of `items`, each a key and a typed value.
|
||||
fn psd_descriptor(items: &[(&str, Vec<u8>)]) -> Vec<u8> {
|
||||
let mut b = psd_class(items.len());
|
||||
for (k, v) in items {
|
||||
b.extend(psd_key(k));
|
||||
b.extend(v);
|
||||
}
|
||||
b
|
||||
}
|
||||
|
||||
/// A typed descriptor value: its four-character type, then `body`.
|
||||
fn psd_value(kind: &[u8; 4], body: &[u8]) -> Vec<u8> {
|
||||
[kind.as_slice(), body].concat()
|
||||
}
|
||||
|
||||
fn psd_long(v: i32) -> Vec<u8> {
|
||||
psd_value(b"long", &v.to_be_bytes())
|
||||
}
|
||||
|
||||
fn psd_text(t: &str) -> Vec<u8> {
|
||||
psd_value(b"TEXT", &psd_unicode(t))
|
||||
}
|
||||
|
||||
fn psd_enum(kind: &str, v: &str) -> Vec<u8> {
|
||||
psd_value(b"enum", &[psd_key(kind), psd_key(v)].concat())
|
||||
}
|
||||
|
||||
/// A bounds object: left, top, right and bottom (px), stored top, left, bottom, right.
|
||||
fn psd_bounds([l, t, r, b]: [i32; 4]) -> Vec<u8> {
|
||||
psd_value(b"Objc", &psd_descriptor(&[("Top ", psd_long(t)), ("Left", psd_long(l)), ("Btom", psd_long(b)), ("Rght", psd_long(r))]))
|
||||
}
|
||||
|
||||
/// The slices of the samples: origin (0: generated automatically, 1: follows a layer, 2: made by
|
||||
/// the user), name, and left, top, right and bottom on the 12 × 10 px canvas. Two come in; the
|
||||
/// automatic one between them is left out.
|
||||
const PSD_SLICES: [(u32, &str, [i32; 4]); 3] = [(2, "a", [1, 2, 5, 6]), (0, "auto", [0, 0, 12, 1]), (1, "b", [6, 3, 11, 9])];
|
||||
|
||||
/// The data of an image resource 1050 holding [`PSD_SLICES`].
|
||||
struct SliceSample {
|
||||
version: u32,
|
||||
data: Vec<u8>,
|
||||
/// Where the slice count starts in `data`.
|
||||
count_at: usize,
|
||||
}
|
||||
|
||||
/// Version 6: the bounds of all the slices, the group's name, the count and one record per slice.
|
||||
/// The first record is followed by a Photoshop 7 descriptor (version 16) with a nested object, which
|
||||
/// the reader reads past to the second record.
|
||||
fn psd_slices_v6() -> SliceSample {
|
||||
let mut b = 6u32.to_be_bytes().to_vec();
|
||||
b.extend([0i32, 0, 10, 12].iter().flat_map(|v| v.to_be_bytes()));
|
||||
b.extend(psd_unicode("group"));
|
||||
let count_at = b.len();
|
||||
b.extend((PSD_SLICES.len() as u32).to_be_bytes());
|
||||
for (i, (origin, name, rect)) in PSD_SLICES.iter().enumerate() {
|
||||
// The ID, the group ID and the origin; a slice that follows a layer gives the layer's ID.
|
||||
b.extend((i as u32 + 1).to_be_bytes());
|
||||
b.extend(0u32.to_be_bytes());
|
||||
b.extend(origin.to_be_bytes());
|
||||
if *origin == 1 {
|
||||
b.extend(4u32.to_be_bytes());
|
||||
}
|
||||
b.extend(psd_unicode(name));
|
||||
// An Image slice: its rectangle, link, target, message, alternative text, plain cell text,
|
||||
// alignment and background color (alpha, red, green, blue).
|
||||
b.extend(1u32.to_be_bytes());
|
||||
b.extend(rect.iter().flat_map(|v| v.to_be_bytes()));
|
||||
for t in ["https://example.com/", "_blank", "", "alt"] {
|
||||
b.extend(psd_unicode(t));
|
||||
}
|
||||
b.push(0);
|
||||
b.extend(psd_unicode(""));
|
||||
b.extend([0u8; 8]);
|
||||
b.extend([255, 10, 20, 30]);
|
||||
if i == 0 {
|
||||
b.extend(16u32.to_be_bytes());
|
||||
let color = psd_value(b"Objc", &psd_descriptor(&[("Rd ", psd_value(b"doub", &128f64.to_be_bytes()))]));
|
||||
b.extend(psd_descriptor(&[("topOutset", psd_long(0)), ("bgColor", color)]));
|
||||
}
|
||||
}
|
||||
SliceSample { version: 6, data: b, count_at }
|
||||
}
|
||||
|
||||
/// Versions 7 and 8: a version 16 descriptor with the slices' bounds, base name and `slices` list,
|
||||
/// each slice an object with a nested bounds and background color object.
|
||||
fn psd_slices_descriptor(version: u32) -> SliceSample {
|
||||
let mut b = version.to_be_bytes().to_vec();
|
||||
b.extend(16u32.to_be_bytes());
|
||||
b.extend(psd_class(3));
|
||||
b.extend(psd_key("bounds"));
|
||||
b.extend(psd_bounds([0, 0, 12, 10]));
|
||||
b.extend(psd_key("baseName"));
|
||||
b.extend(psd_text("sheet"));
|
||||
b.extend(psd_key("slices"));
|
||||
b.extend(b"VlLs");
|
||||
let count_at = b.len();
|
||||
b.extend((PSD_SLICES.len() as u32).to_be_bytes());
|
||||
for (i, (origin, name, rect)) in PSD_SLICES.iter().enumerate() {
|
||||
let origin = match origin {
|
||||
0 => "autoGenerated",
|
||||
1 => "layerGenerated",
|
||||
_ => "userGenerated",
|
||||
};
|
||||
let doub = |v: f64| psd_value(b"doub", &v.to_be_bytes());
|
||||
let color = psd_value(b"Objc", &psd_descriptor(&[("Rd ", doub(10.0)), ("Grn ", doub(20.0)), ("Bl ", doub(30.0))]));
|
||||
b.extend(psd_value(
|
||||
b"Objc",
|
||||
&psd_descriptor(&[
|
||||
("sliceID", psd_long(i as i32 + 1)),
|
||||
("groupID", psd_long(0)),
|
||||
("origin", psd_enum("ESliceOrigin", origin)),
|
||||
("Type", psd_enum("ESliceType", "Img ")),
|
||||
("bounds", psd_bounds(*rect)),
|
||||
("Nm ", psd_text(name)),
|
||||
("url", psd_text("https://example.com/")),
|
||||
("bgColorType", psd_enum("ESliceBGColorType", "Clr ")),
|
||||
("bgColor", color),
|
||||
]),
|
||||
));
|
||||
}
|
||||
SliceSample { version, data: b, count_at }
|
||||
}
|
||||
|
||||
/// Resource 1050 in versions 6, 7 and 8.
|
||||
fn psd_slice_samples() -> Vec<SliceSample> {
|
||||
vec![psd_slices_v6(), psd_slices_descriptor(7), psd_slices_descriptor(8)]
|
||||
}
|
||||
|
||||
/// A flat 12 × 10 px RGB PSD file whose one image resource is 1050 holding `data`, and where
|
||||
/// `data` lies in it.
|
||||
fn sliced_psd(data: &[u8]) -> (Vec<u8>, std::ops::Range<usize>) {
|
||||
// The signature, version 1, reserved bytes, 3 channels, 10 rows, 12 columns, 8 bits, RGB, and
|
||||
// no color mode data.
|
||||
let mut f = b"8BPS\0\x01\0\0\0\0\0\0\0\x03".to_vec();
|
||||
f.extend(10u32.to_be_bytes());
|
||||
f.extend(12u32.to_be_bytes());
|
||||
f.extend([0, 8, 0, 3]);
|
||||
f.extend([0; 4]);
|
||||
let mut block = b"8BIM".to_vec();
|
||||
block.extend(1050u16.to_be_bytes());
|
||||
block.extend([0, 0]);
|
||||
block.extend((data.len() as u32).to_be_bytes());
|
||||
let start = f.len() + 4 + block.len();
|
||||
block.extend(data);
|
||||
block.resize(block.len().next_multiple_of(2), 0);
|
||||
f.extend((block.len() as u32).to_be_bytes());
|
||||
f.extend(block);
|
||||
// No layer and mask information, then the merged image, raw.
|
||||
f.extend([0; 4]);
|
||||
f.extend([0, 0]);
|
||||
f.extend((0..360u32).map(|v| (v * 7) as u8));
|
||||
(f, start..start + data.len())
|
||||
}
|
||||
|
||||
/// PSD file `f` opened (the names of the document's slices, and the open's warnings), counted by
|
||||
/// `document.psdInfo`, and placed embedded in a new document (the count of the slices it brings in).
|
||||
fn sliced_psd_imports(f: &[u8]) -> (Vec<String>, Value, Value, usize) {
|
||||
let mut s = vectorcraft_engine::Session::new();
|
||||
let p = json!({"name": "sheet.psd", "dataBase64": vectorcraft_format::base64_encode(f)});
|
||||
let r = s.execute("document.open", &p).unwrap();
|
||||
let names = s.doc().unwrap().doc.slices.iter().map(|x| x.options.name.clone()).collect();
|
||||
let info = s.execute("document.psdInfo", &p).unwrap();
|
||||
s.execute("file.new", &json!({})).unwrap();
|
||||
let placed = s.execute("file.place", &json!({"name": "sheet.psd", "dataBase64": vectorcraft_format::base64_encode(f), "link": false})).unwrap();
|
||||
(names, r["warnings"].clone(), info["slices"].clone(), placed["slices"].as_array().map_or(0, Vec::len))
|
||||
}
|
||||
|
||||
/// Each sample reaches the slice reader: its two user slices open and place, without a warning,
|
||||
/// and `document.psdInfo` counts them; the automatic one is left out.
|
||||
#[test]
|
||||
fn the_sliced_psd_samples_bring_in_their_user_slices() {
|
||||
for sample in psd_slice_samples() {
|
||||
let (names, warnings, info, placed) = sliced_psd_imports(&sliced_psd(&sample.data).0);
|
||||
assert_eq!(names, ["a", "b"], "version {}: {warnings}", sample.version);
|
||||
assert_eq!(warnings.as_array().map_or(0, Vec::len), 0, "version {}: {warnings}", sample.version);
|
||||
assert_eq!((info, placed), (json!(2), 2), "version {}", sample.version);
|
||||
}
|
||||
}
|
||||
|
||||
/// A slice count past the 10,000 read, or one larger than the slices stored, and resource data cut
|
||||
/// short, open and place the file without its slices, with a warning, and `document.psdInfo`
|
||||
/// counts none.
|
||||
#[test]
|
||||
fn sliced_psd_samples_with_huge_counts_or_cut_short_come_in_without_their_slices() {
|
||||
for sample in psd_slice_samples() {
|
||||
let mut damaged = vec![];
|
||||
for count in [10_001u32, 0x7fff_ffff, u32::MAX] {
|
||||
let mut d = sample.data.clone();
|
||||
d[sample.count_at..sample.count_at + 4].copy_from_slice(&count.to_be_bytes());
|
||||
damaged.push((format!("count {count}"), d));
|
||||
}
|
||||
damaged.push(("one byte short".into(), sample.data[..sample.data.len() - 1].to_vec()));
|
||||
damaged.push(("cut in the count".into(), sample.data[..sample.count_at + 2].to_vec()));
|
||||
for (what, d) in damaged {
|
||||
let (names, warnings, info, placed) = sliced_psd_imports(&sliced_psd(&d).0);
|
||||
let warned = warnings.as_array().is_some_and(|w| w.iter().any(|w| w.as_str().is_some_and(|w| w.contains("the slices can't be read"))));
|
||||
assert!(warned, "version {}, {what}: {warnings}", sample.version);
|
||||
assert_eq!((names.len(), info, placed), (0, json!(0), 0), "version {}, {what}", sample.version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proptest! {
|
||||
#![proptest_config(config())]
|
||||
|
||||
/// Mutated copies of the slice samples never crash opening the file, `document.psdInfo` or
|
||||
/// placing it embedded: the resource's data mutated, then kept whole, cut short with the
|
||||
/// resource's length saying so, or with the file cut short in the resource's block.
|
||||
#[test]
|
||||
fn mutated_psd_slices_never_panic(which in 0usize..3, mode in 0u8..3, cut in any::<usize>(), edits in prop::collection::vec((any::<usize>(), any::<u8>()), 0..12)) {
|
||||
let SliceSample { version, mut data, .. } = psd_slice_samples().swap_remove(which);
|
||||
let len = data.len();
|
||||
for (at, b) in edits {
|
||||
data[at % len] = b;
|
||||
}
|
||||
let bytes = match mode {
|
||||
0 => sliced_psd(&data).0,
|
||||
1 => {
|
||||
data.truncate(cut % (len + 1));
|
||||
sliced_psd(&data).0
|
||||
}
|
||||
_ => {
|
||||
let (mut f, at) = sliced_psd(&data);
|
||||
f.truncate(at.start - 12 + cut % (len + 13));
|
||||
f
|
||||
}
|
||||
};
|
||||
let r = catch_quiet(|| {
|
||||
let mut s = vectorcraft_engine::Session::new();
|
||||
let p = json!({"name": "sheet.psd", "dataBase64": vectorcraft_format::base64_encode(&bytes)});
|
||||
let _ = no_panic(s.execute("document.open", &p));
|
||||
let _ = no_panic(s.execute("document.psdInfo", &p));
|
||||
let _ = no_panic(s.execute("file.new", &json!({})));
|
||||
let p = json!({"name": "sheet.psd", "dataBase64": vectorcraft_format::base64_encode(&bytes), "link": false});
|
||||
let _ = no_panic(s.execute("file.place", &p));
|
||||
});
|
||||
prop_assert!(r.is_ok(), "version {version}, mode {mode}: panicked: {:?}", r.err());
|
||||
}
|
||||
}
|
||||
|
||||
/// 1-bit TIFFs compressed with CCITT Group 3: modified Huffman (Compression 2) in three strips, T.4
|
||||
/// (Compression 3) with two-dimensional rows, fill bits, six EOLs at the end and each byte's lowest
|
||||
/// bit first, and T.4 two-dimensional rows in 16 × 16 tiles.
|
||||
|
||||
@@ -648,6 +648,107 @@ fn batched_colored_inflate_preserves_compound_holes_and_surface_opacity() {
|
||||
assert_eq!(image.pixels, render(doc(&s)).pixels);
|
||||
}
|
||||
|
||||
/// The alpha of `d` drawn at 1:1 against a 3x render averaged down. Inside the art, on each pixel
|
||||
/// whose 3x average and its eight neighbors' share one alpha, a pixel is off when it is below 255
|
||||
/// where that alpha is 255, otherwise more than 3 levels away from it. Outside the art, a pixel is
|
||||
/// painted past the outline when it has an alpha above 3 where it and its eight neighbors are empty
|
||||
/// at 3x. Returns (pixels measured inside, pixels off, the largest alpha off, pixels painted past the
|
||||
/// outline, the first few of either).
|
||||
fn alpha_against_supersampled(d: &Document) -> (usize, usize, u8, usize, Vec<String>) {
|
||||
let image = render(d);
|
||||
let fine = vectorcraft_render::Renderer::new().render(
|
||||
d,
|
||||
1200,
|
||||
1200,
|
||||
kurbo::Affine::scale(3.0),
|
||||
&vectorcraft_render::RenderOptions { background: None, artboards: false, ..Default::default() },
|
||||
);
|
||||
let average = fine.area_resized(400, 400).unwrap();
|
||||
let (mut measured, mut off, mut worst, mut past) = (0, 0, 0, 0);
|
||||
let mut first = vec![];
|
||||
for y in 1..399 {
|
||||
for x in 1..399 {
|
||||
let q = average.pixel(x, y)[3];
|
||||
if !(y - 1..=y + 1).all(|y| (x - 1..=x + 1).all(|x| average.pixel(x, y)[3] == q)) {
|
||||
continue;
|
||||
}
|
||||
let p = image.pixel(x, y)[3];
|
||||
let wrong = if q == 0 {
|
||||
let painted = p > 3;
|
||||
past += usize::from(painted);
|
||||
painted
|
||||
} else {
|
||||
measured += 1;
|
||||
let hole = if q == 255 { p < 255 } else { p.abs_diff(q) > 3 };
|
||||
off += usize::from(hole);
|
||||
worst = worst.max(p.abs_diff(q));
|
||||
hole
|
||||
};
|
||||
if wrong && first.len() < 4 {
|
||||
first.push(format!("({x},{y}) {p} vs {q}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
(measured, off, worst, past, first)
|
||||
}
|
||||
|
||||
/// Revolve under colored lights draws each face of a gradient-lit surface on its own, over an
|
||||
/// underlay of its faces clipped to the surface's outline: at 1:1, no pixel inside the art lets the
|
||||
/// background through where a 3x render averaged down is opaque, none paints past the outline, and
|
||||
/// a surface's opacity, its gradient's transparent stops and its blending mode apply once. The same
|
||||
/// holds for the art read back from SVG and PDF and for Expand Appearance.
|
||||
#[test]
|
||||
fn colored_revolve_faces_leave_no_alpha_holes_at_one_to_one() {
|
||||
let gradient = |opacity: f64| {
|
||||
json!({"gradient":{"kind":"linear","start":[100,150],"end":[200,150],"stops":[
|
||||
{"offset":0,"color":"#ffffff","opacity":opacity},{"offset":1,"color":"#808080","opacity":opacity}
|
||||
]}})
|
||||
};
|
||||
let lights = json!([
|
||||
{"color":"#ff0000","rotation":135,"height":35,"intensity":70},
|
||||
{"color":"#0000ff","rotation":-35,"height":25,"intensity":65}
|
||||
]);
|
||||
let cases = [
|
||||
("red light, gradient", gradient(1.0), json!({}), None),
|
||||
("red light, solid", json!({"color":"#ffcc66"}), json!({}), None),
|
||||
("two lights, gradient", gradient(1.0), json!({"ambient":10,"lights":lights}), None),
|
||||
("two lights, solid", json!({"color":"#ffcc66"}), json!({"ambient":10,"lights":lights}), None),
|
||||
("red light, edge-on faces", gradient(1.0), json!({"rotationX":-80}), None),
|
||||
("red light, gradient at 60%", gradient(0.6), json!({}), None),
|
||||
("red light, fill at 60%", gradient(1.0), json!({}), Some(json!({"item":0,"opacity":60}))),
|
||||
("red light, multiply", gradient(1.0), json!({}), Some(json!({"item":0,"blend":"Multiply"}))),
|
||||
];
|
||||
let mut failures = vec![];
|
||||
for (name, fill, params, transparency) in cases {
|
||||
let (mut s, _) = capped_profile();
|
||||
s.execute("effect.setParams", &json!({"index":0,"item":null,"params":params})).unwrap();
|
||||
s.execute("paint.setFill", &fill).unwrap();
|
||||
if let Some(t) = transparency {
|
||||
s.execute("transparency.set", &t).unwrap();
|
||||
}
|
||||
let svg = s.execute("document.serialize", &json!({"format":"svg"})).unwrap()["text"].as_str().unwrap().to_owned();
|
||||
assert!(!svg.contains("<image"), "{name}");
|
||||
let pdf = s.execute("document.serialize", &json!({"format":"pdf"})).unwrap();
|
||||
let pdf = vectorcraft_format::base64_decode(pdf["dataBase64"].as_str().unwrap()).unwrap();
|
||||
assert!(!pdf.windows(b"/Subtype /Image".len()).any(|w| w == b"/Subtype /Image"), "{name}");
|
||||
let live = doc(&s).clone();
|
||||
s.execute("effect.expandAppearance", &json!({})).unwrap();
|
||||
for (of, d) in [
|
||||
("live", live),
|
||||
("SVG", vectorcraft_svg::import(&svg).unwrap()),
|
||||
("PDF", vectorcraft_pdf::import(&pdf).unwrap()),
|
||||
("expanded", doc(&s).clone()),
|
||||
] {
|
||||
let (measured, off, worst, past, first) = alpha_against_supersampled(&d);
|
||||
assert!(measured > 10_000, "{name} {of}: {measured} pixels inside");
|
||||
if off > 0 || past > 0 {
|
||||
failures.push(format!("{name} {of}: of {measured} pixels, {off} off (at most {worst}), {past} past the outline: {first:?}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(failures.is_empty(), "{failures:#?}");
|
||||
}
|
||||
|
||||
/// Under colored lights, an Inflate fill and stroke in solid colors draw each face on its own, in
|
||||
/// one depth order: zoomed in, the fill's faces show the colors the one composite of the surface
|
||||
/// shows (drawn when the stroke is translucent), with no seam between faces; at 1x, where a pixel
|
||||
|
||||
@@ -232,8 +232,8 @@ pub fn export(doc: &Document, opts: &EpsOptions, preview: Option<&Raster>, thumb
|
||||
}
|
||||
// Type in the document's composite fonts is drawn in them, whether or not an app has the document open.
|
||||
let _lent = vectorcraft_text::FontDb::global().lend_composite_fonts(&doc.composite_fonts);
|
||||
let baked =
|
||||
vectorcraft_effects::bake_document_placing_symbols(doc, true, vectorcraft_effects::WrittenLayers { hidden: false, non_printing: true });
|
||||
let layers = vectorcraft_effects::WrittenLayers { hidden: false, non_printing: true, hidden_objects: false };
|
||||
let baked = vectorcraft_effects::bake_document_placing_symbols(doc, true, layers);
|
||||
let doc = baked.as_ref().unwrap_or(doc);
|
||||
let page = scene::Scene::new(doc, opts).run();
|
||||
let mut setting_notes = vec![];
|
||||
|
||||
@@ -74,15 +74,18 @@ pub struct Output {
|
||||
}
|
||||
|
||||
/// Write the visible art of `doc` over `region` (document space: its top-left corner is the
|
||||
/// picture's origin, its size the picture's) as `kind`. Live geometry effects are applied first;
|
||||
/// template layers, hidden objects and guides are left out. Raster effects should be turned into
|
||||
/// images before (the engine does); the ones left are reported and left out.
|
||||
/// picture's origin, its size the picture's) as `kind`. Live geometry effects are applied first,
|
||||
/// in symbols' art too, where each instance places that art (EMF clips 9-slice cells, WMF does
|
||||
/// not); template layers, hidden objects and guides are left out. Raster effects should be turned
|
||||
/// into images before (the engine does); the ones left are reported and left out.
|
||||
pub fn export(doc: &Document, region: Rect, kind: Kind) -> Result<Output, String> {
|
||||
let r = region.abs();
|
||||
if ![r.x0, r.y0, r.x1, r.y1].iter().all(|v| v.is_finite()) || r.width() <= 0.0 || r.height() <= 0.0 {
|
||||
return Err("the export region is empty".into());
|
||||
}
|
||||
let baked = vectorcraft_effects::bake_document(doc);
|
||||
// The scene writes layers that do not print and leaves hidden layers and objects out.
|
||||
let layers = vectorcraft_effects::WrittenLayers { hidden: false, non_printing: true, hidden_objects: false };
|
||||
let baked = vectorcraft_effects::bake_document_placing_symbols(doc, kind == Kind::Emf, layers);
|
||||
let doc = baked.as_ref().unwrap_or(doc);
|
||||
let (ops, mut warnings) = scene::Scene::new(doc, r, kind == Kind::Emf).run();
|
||||
let bytes = match kind {
|
||||
|
||||
@@ -85,6 +85,43 @@ fn wmf_output_round_trips() {
|
||||
assert!(near(ellipse.geometric_bounds().unwrap(), Rect::new(100.0, 20.0, 180.0, 80.0), 0.1));
|
||||
}
|
||||
|
||||
/// A symbol's square that a Transform effect moves 100 pt right is written where the canvas draws
|
||||
/// it, in EMF and in WMF, read back: art whose own place is off the artboard is written where the
|
||||
/// effect moves it onto it, and an instance that doubles the art's width places it first, so the
|
||||
/// effect still moves it 100 pt (to x = 120, not 220). A stained instance keeps its stain.
|
||||
#[test]
|
||||
fn symbol_art_effects_are_written_where_they_draw() {
|
||||
let moved = |rect: Rect| {
|
||||
let mut art = path(shapes::rectangle(rect), red(), Paint::None, 0.0);
|
||||
art.appearance.effects.push(vectorcraft_doc::Effect {
|
||||
id: "distort.transform".into(),
|
||||
params: [("moveH", 100.0)].into_iter().collect(),
|
||||
visible: true,
|
||||
});
|
||||
art
|
||||
};
|
||||
// The art's square, the instance's transform and fill, and the square and color it draws.
|
||||
let cases = [
|
||||
(Rect::new(-90.0, 10.0, -80.0, 20.0), Affine::IDENTITY, None, Rect::new(10.0, 10.0, 20.0, 20.0), [255, 0, 0]),
|
||||
(Rect::new(10.0, 30.0, 20.0, 40.0), Affine::scale_non_uniform(2.0, 1.0), Some(blue()), Rect::new(120.0, 30.0, 140.0, 40.0), [0, 0, 255]),
|
||||
];
|
||||
for (square, xf, stain, want, rgb) in cases {
|
||||
let mut inst = Node::new(vectorcraft_doc::NodeId(0), NodeKind::SymbolInstance { symbol: "Moved".into(), xf });
|
||||
if let Some(p) = stain {
|
||||
inst.appearance = vectorcraft_doc::Appearance::basic(p, Paint::None, 0.0).into();
|
||||
}
|
||||
let mut d = doc_with(200.0, 100.0, vec![inst]);
|
||||
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Moved".into(), art: std::sync::Arc::new(moved(square)) });
|
||||
for kind in [Kind::Emf, Kind::Wmf] {
|
||||
let back = import(&export(&d, d.artboards[0].rect, kind).unwrap().bytes).unwrap();
|
||||
let drawn: Vec<(Option<Rect>, Option<[u8; 3]>)> = paths(&back.document).iter().map(|n| (n.geometric_bounds(), fill_rgb(n))).collect();
|
||||
assert_eq!(drawn.len(), 1, "{kind:?} {xf:?}: {drawn:?}");
|
||||
assert!(drawn[0].0.is_some_and(|b| near(b, want, 0.1)), "{kind:?} {xf:?}: {drawn:?}");
|
||||
assert_eq!(drawn[0].1, Some(rgb), "{kind:?} {xf:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn freeform_points_that_share_a_model_are_written_as_their_mix() {
|
||||
use vectorcraft_color::{Color, Freeform, FreeformPoint, GradientKind};
|
||||
|
||||
@@ -57,6 +57,7 @@ fn export_with_report_inner(doc: &Document, opts: &PdfOptions, left_out: &mut Ha
|
||||
let layers = vectorcraft_effects::WrittenLayers {
|
||||
hidden: set.writes_layers() && !doc.page_knockout,
|
||||
non_printing: set.include_non_printing || set.create_layers,
|
||||
hidden_objects: false,
|
||||
};
|
||||
let baked = vectorcraft_effects::bake_document_placing_symbols(doc, true, layers);
|
||||
// Baking stops early when cancelled, leaving a half-baked copy that must not be written.
|
||||
|
||||
@@ -143,7 +143,9 @@ impl Exporter<'_> {
|
||||
let doc = self.doc;
|
||||
let out = self.out.clone();
|
||||
let profiles = out.source_profiles();
|
||||
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: self.sixteen_bit });
|
||||
let then = out.converts_tagged_pixels().then_some(&*out);
|
||||
let grey = out.converts_grey_images();
|
||||
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: self.sixteen_bit, then, grey });
|
||||
let mut unconverted = false;
|
||||
let img = doc.image_blob(im).filter(|_| !self.left_out.contains(key)).and_then(|blob| {
|
||||
let cmyk_image = blob.is_cmyk();
|
||||
|
||||
+33
-16
@@ -12,7 +12,9 @@
|
||||
//! conversion leaves unchanged (an sRGB profile) keeps its JPEG data. A black-and-white image whose
|
||||
//! converted levels are grey is compressed as greyscale. A colour image the Output settings also
|
||||
//! convert to their destination ([`Pixels`]) goes from its profile to sRGB, then to the
|
||||
//! destination; a grey one keeps its profile there, as grey pixels are not converted.
|
||||
//! destination, and so does one converted from its profile to an RGB destination whose untagged
|
||||
//! images keep their numbers (Preserve Numbers); a grey one keeps its profile there, as grey
|
||||
//! pixels are not converted.
|
||||
//!
|
||||
//! CMYK images ([`ImageBlob::cmyk`]) stay CMYK: a CMYK JPEG already as asked is embedded as it is
|
||||
//! when its numbers are kept; the others' ink amounts are resampled, converted when the Output
|
||||
@@ -325,15 +327,23 @@ pub(crate) struct Recoded {
|
||||
pub unconverted: bool,
|
||||
}
|
||||
|
||||
/// How [`recode`] converts a gray or RGB image that carries an ICC profile to sRGB (Convert to
|
||||
/// Destination, [`crate::output::ColorOut::image_srgb_intent`]): the destination when it is sRGB,
|
||||
/// else the step before the image's [`Pixels`] conversion.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) struct ToSrgb {
|
||||
/// How [`recode`] converts a gray or RGB image that carries an ICC profile to sRGB
|
||||
/// ([`crate::output::ColorOut::image_srgb_intent`]): the destination when it is sRGB, else the
|
||||
/// step before the image's [`Pixels`] conversion.
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct ToSrgb<'a> {
|
||||
/// The rendering intent of the conversion.
|
||||
pub intent: Intent,
|
||||
/// 16-bit samples may be written (PDF 1.5 and later).
|
||||
pub sixteen_bit: bool,
|
||||
/// The colour output whose [`crate::output::ColorOut::tagged_pixels`] then convert a colour
|
||||
/// image converted from its profile, when other colour images are not converted (`recode`'s
|
||||
/// `convert`): to an RGB destination whose untagged images keep their numbers (Preserve
|
||||
/// Numbers). Its table is built when the first such image needs it.
|
||||
pub then: Option<&'a crate::output::ColorOut>,
|
||||
/// Gray images are converted too: with an sRGB destination
|
||||
/// ([`crate::output::ColorOut::converts_grey_images`]). In the others they keep their profile.
|
||||
pub grey: bool,
|
||||
}
|
||||
|
||||
/// What happens to the ICC profile a gray or RGB image carries
|
||||
@@ -521,13 +531,15 @@ fn resample_channels(img: DynamicImage, r: &Rule, (w, h): (u32, u32)) -> Dynamic
|
||||
/// Encoded image `bytes` placed `size` points wide and high, as the Compression settings `c` ask:
|
||||
/// resampled when its resolution is above the threshold, compressed with ZIP or JPEG, its colours
|
||||
/// converted by `convert` (colour images). Pixels that keep their colours keep the ICC profile
|
||||
/// they carry when `profiles` keeps it ([`SourceProfiles::Keep`]); with `to_srgb`, pixels in a gray or RGB profile other than sRGB are converted from it to sRGB
|
||||
/// instead ([`ToSrgb`]), and colour ones then by `convert`; grey ones that `convert` leaves as
|
||||
/// they are keep their profile. `interpolate` lets viewers smooth it. An image that can't be
|
||||
/// decoded is kept as it is, with a warning when its pixels were to be converted to sRGB. When
|
||||
/// `convert` was to convert its colors, it is [`Recoded::unconverted`] if its header can't be read
|
||||
/// (it may be in color) or its pixels are beyond the decode allowance; a color image whose pixel
|
||||
/// data can't be read is not.
|
||||
/// they carry when `profiles` keeps it ([`SourceProfiles::Keep`]); with `to_srgb`, pixels in a
|
||||
/// gray or RGB profile other than sRGB are converted from it to sRGB instead ([`ToSrgb`]), and
|
||||
/// colour ones then by `convert`, or without it by the conversion `to_srgb` gives
|
||||
/// ([`ToSrgb::then`]); grey ones keep their profile unless the destination is sRGB
|
||||
/// ([`ToSrgb::grey`]). `interpolate` lets viewers smooth it. An image that can't be decoded is
|
||||
/// kept as it is, with a warning when its pixels were to be converted to sRGB. When `convert`
|
||||
/// was to convert its colors, it is [`Recoded::unconverted`] if its header can't be read (it may
|
||||
/// be in color) or its pixels are beyond the decode allowance; a color image whose pixel data
|
||||
/// can't be read is not.
|
||||
pub(crate) fn recode(
|
||||
bytes: &[u8],
|
||||
size: (f64, f64),
|
||||
@@ -545,8 +557,9 @@ pub(crate) fn recode(
|
||||
use ExtendedColorType as T;
|
||||
let grey = matches!(decoder.original_color_type(), T::L1 | T::La1 | T::L2 | T::La2 | T::L4 | T::La4 | T::L8 | T::La8 | T::L16 | T::La16);
|
||||
// Pixels in a profile they are converted from are decoded, whatever the Compression settings.
|
||||
// Grey pixels, which `convert` leaves as they are, keep their profile when it converts.
|
||||
let to_srgb = to_srgb.filter(|_| !(grey && convert.is_some()));
|
||||
// Grey pixels keep their profile unless the destination is sRGB ([`ToSrgb::grey`]).
|
||||
let then = to_srgb.and_then(|t| t.then);
|
||||
let to_srgb = to_srgb.filter(|t| !grey || t.grey);
|
||||
// Converted to the destination as sRGB, as before, when the profile can't be read.
|
||||
let mut note = None;
|
||||
let source = match to_srgb.and_then(|t| Some((source_profile(bytes, if grey { *b"GRAY" } else { *b"RGB " })?, t))) {
|
||||
@@ -589,6 +602,8 @@ pub(crate) fn recode(
|
||||
Ok(img) => img,
|
||||
Err(limited) => return Recoded { unconverted: limited && convert.is_some(), ..keep },
|
||||
};
|
||||
// Converted from its profile: then by `convert`, else by the conversion `to_srgb` gives.
|
||||
let mut from_profile = false;
|
||||
if let Some((p, t)) = &source {
|
||||
let srgb = match into_srgb(img, p, t.intent) {
|
||||
Some(s) => Some(s),
|
||||
@@ -606,8 +621,9 @@ pub(crate) fn recode(
|
||||
if kind == Kind::Mono && !bilevel(&srgb) {
|
||||
(kind, rule) = (Kind::Gray, self::rule(c, Kind::Gray));
|
||||
}
|
||||
from_profile = true;
|
||||
// Written as it is only when nothing converts it further.
|
||||
let as_is = kept(&rule, dims, size, jpeg) && convert.is_none();
|
||||
let as_is = kept(&rule, dims, size, jpeg) && convert.is_none() && then.is_none();
|
||||
// A JPEG kept as JPEG whose samples the conversion leaves unchanged (an sRGB
|
||||
// profile): its JPEG data, without the profile (and, with `Remove`, without its
|
||||
// segments: encoded again when those can't be taken out).
|
||||
@@ -632,6 +648,7 @@ pub(crate) fn recode(
|
||||
},
|
||||
};
|
||||
}
|
||||
let convert = if from_profile { convert.or_else(|| then.and_then(crate::output::ColorOut::tagged_pixels)) } else { convert };
|
||||
// Pixels that keep their colours keep the profile they are in; converted ones are in the
|
||||
// destination's.
|
||||
let want = if kind == Kind::Color { *b"RGB " } else { *b"GRAY" };
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
//! that carries an ICC profile is converted from it to sRGB with the same intent and written
|
||||
//! without it ([`ColorOut::image_srgb_intent`]); with `destination` and a destination its
|
||||
//! pixels are converted to (CMYK, another RGB space), a colour image is converted from its
|
||||
//! profile to sRGB and then to the destination. Without conversion it keeps its profile. The
|
||||
//! profile to sRGB and then to the destination. With `preserveNumbers` (and PDF/X-1a), which
|
||||
//! keeps the numbers of untagged colours only, such an image is converted from its profile
|
||||
//! whatever the destination: to sRGB, and then to a CMYK or other RGB destination
|
||||
//! ([`ColorOut::tagged_pixels`]). Without conversion it keeps its profile. The
|
||||
//! destination is a profile name; empty, the document's profile for its colour mode.
|
||||
//! - Profiles ([`ProfileInclusion`]): with `all`, with `destination`, and with `taggedSource` on a
|
||||
//! document that was assigned profiles, colours are written in ICC-based colour spaces: CMYK
|
||||
@@ -84,6 +87,9 @@ pub(crate) struct ColorOut {
|
||||
pub srgb_note: Option<String>,
|
||||
/// The image transform, built when the first image needs it.
|
||||
pixels: OnceLock<Option<Pixels>>,
|
||||
/// The transform of images converted from their profile, when it isn't `pixels`
|
||||
/// ([`Self::tagged_pixels`]).
|
||||
tagged_pixels: OnceLock<Option<Pixels>>,
|
||||
/// The CMYK image transform, built when the first CMYK image needs it.
|
||||
cmyk_pixels: OnceLock<Option<CmykPixels>>,
|
||||
intent: Intent,
|
||||
@@ -128,6 +134,7 @@ impl Default for ColorOut {
|
||||
cmyk_profile,
|
||||
srgb_note: None,
|
||||
pixels: OnceLock::new(),
|
||||
tagged_pixels: OnceLock::new(),
|
||||
cmyk_pixels: OnceLock::new(),
|
||||
intent,
|
||||
catalog: None,
|
||||
@@ -361,13 +368,49 @@ impl ColorOut {
|
||||
/// The intent a gray or RGB image that carries an ICC profile is converted from it to sRGB
|
||||
/// with ([`crate::images::recode`]): the colour settings' intent, with Convert to Destination
|
||||
/// and an sRGB destination, also when the document's RGB space is sRGB, or a destination
|
||||
/// colour images' pixels are then converted to ([`Self::pixels`]: CMYK, another RGB space).
|
||||
/// `None` otherwise, Preserve Numbers and an RGB destination that is the document's own RGB
|
||||
/// profile (which leaves RGB colours and RGB images as they are) included: such an image
|
||||
/// keeps its profile, or its numbers are converted as sRGB ones.
|
||||
/// colour images' pixels are then converted to ([`Self::pixels`]: CMYK, another RGB space);
|
||||
/// and with Preserve Numbers (and PDF/X-1a's own conversion), whatever the destination, as
|
||||
/// only untagged colours of the destination's model keep their numbers. The pixels are then
|
||||
/// converted by [`Self::tagged_pixels`]. `None` otherwise, an RGB destination that is the
|
||||
/// document's own RGB profile with Convert to Destination (which leaves RGB colours and RGB
|
||||
/// images as they are) included: such an image keeps its profile.
|
||||
pub(crate) fn image_srgb_intent(&self) -> Option<Intent> {
|
||||
let d = self.dest.as_ref().filter(|d| d.destination)?;
|
||||
((d.model == Model::Rgb && d.srgb) || self.pixels().is_some()).then_some(self.intent)
|
||||
let d = self.dest.as_ref()?;
|
||||
let rgb = d.model == Model::Rgb && (d.srgb || !d.destination);
|
||||
(rgb || self.pixels().is_some()).then_some(self.intent)
|
||||
}
|
||||
|
||||
/// Are gray images that carry an ICC profile converted from it to sRGB grays too
|
||||
/// ([`Self::image_srgb_intent`])? Only with an sRGB destination; in the others, RGB tagged as
|
||||
/// sRGB included, grey pixels are not converted and keep their profile.
|
||||
pub(crate) fn converts_grey_images(&self) -> bool {
|
||||
self.dest.as_ref().is_some_and(|d| d.model == Model::Rgb && d.srgb)
|
||||
}
|
||||
|
||||
/// The destination a colour image converted from its ICC profile to sRGB
|
||||
/// ([`Self::image_srgb_intent`]) is then converted to when other colour images are not
|
||||
/// ([`Self::pixels`]): with Preserve Numbers, an RGB destination other than sRGB, whose
|
||||
/// untagged RGB images keep their numbers (unless RGB is tagged as sRGB).
|
||||
fn tagged_rgb_dest(&self) -> Option<&Dest> {
|
||||
self.dest.as_ref().filter(|d| !d.destination && d.model == Model::Rgb && !d.srgb && !self.tagged)
|
||||
}
|
||||
|
||||
/// Are colour images converted from their ICC profile then converted by
|
||||
/// [`Self::tagged_pixels`]?
|
||||
pub(crate) fn converts_tagged_pixels(&self) -> bool {
|
||||
self.tagged_rgb_dest().is_some()
|
||||
}
|
||||
|
||||
/// How a colour image converted from its ICC profile to sRGB is then converted into that
|
||||
/// destination's RGB space ([`Self::converts_tagged_pixels`]), built when the first such image
|
||||
/// needs it; `None` when there is no such destination.
|
||||
pub(crate) fn tagged_pixels(&self) -> Option<&Pixels> {
|
||||
self.tagged_pixels
|
||||
.get_or_init(|| {
|
||||
let d = self.tagged_rgb_dest()?;
|
||||
Some(Pixels::Rgb(Box::new(ProofLut::build(|rgb| d.cms.srgb_to_rgb(rgb)))))
|
||||
})
|
||||
.as_ref()
|
||||
}
|
||||
|
||||
/// The CMYK profile CMYK image `blob` is tagged with ([`crate::images::cmyk_icc`]): the one it
|
||||
|
||||
@@ -187,7 +187,7 @@ pub fn printed_document<'a>(doc: &'a Document, set: &PrintSettings) -> Cow<'a, D
|
||||
// the art that prints; the layers kept are shown.
|
||||
let mut kept = doc.clone();
|
||||
keep_layers(&mut kept.layers, set.print_layers);
|
||||
let layers = vectorcraft_effects::WrittenLayers { hidden: false, non_printing: true };
|
||||
let layers = vectorcraft_effects::WrittenLayers { hidden: false, non_printing: true, hidden_objects: false };
|
||||
let mut d = vectorcraft_effects::bake_document_placing_symbols(&kept, true, layers).unwrap_or(kept);
|
||||
composite_overprints(&mut d, set);
|
||||
Cow::Owned(d)
|
||||
|
||||
@@ -282,7 +282,9 @@ fn a_color_image_beyond_the_allowance_for_a_conversion_is_unconverted() {
|
||||
let settings: PdfSettings = serde_json::from_value(json!({"output": {"conversion": "destination", "destination": GENERIC_CMYK}})).unwrap();
|
||||
let out = crate::output::ColorOut::new(&d, &settings).unwrap();
|
||||
assert!(out.pixels().is_some());
|
||||
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: false });
|
||||
let then = out.converts_tagged_pixels().then_some(&out);
|
||||
let grey = out.converts_grey_images();
|
||||
let to_srgb = out.image_srgb_intent().map(|intent| crate::images::ToSrgb { intent, sixteen_bit: false, then, grey });
|
||||
assert!(to_srgb.is_some());
|
||||
let c: CompressionSettings = serde_json::from_value(json!({})).unwrap();
|
||||
let half = |mut bytes: Vec<u8>| {
|
||||
@@ -898,7 +900,7 @@ fn convert_to_srgb_converts_tagged_images_from_their_profile() {
|
||||
png
|
||||
};
|
||||
let c: CompressionSettings = serde_json::from_value(json!({})).unwrap();
|
||||
let srgb_out = Some(crate::images::ToSrgb { intent: Intent::RelativeColorimetric, sixteen_bit: true });
|
||||
let srgb_out = Some(crate::images::ToSrgb { intent: Intent::RelativeColorimetric, sixteen_bit: true, then: None, grey: true });
|
||||
for (what, png) in [("RGB", declared(&colour(), &p3)), ("gray", declared(&colour().grayscale(), &gray))] {
|
||||
let keep = crate::images::SourceProfiles::Keep;
|
||||
let r = crate::images::recode(&png, (100.0, 100.0), &c, false, None, keep, srgb_out);
|
||||
@@ -1103,3 +1105,127 @@ fn convert_to_destination_converts_tagged_images_from_their_profile() {
|
||||
let as_srgb = converted_samples(&img, to_cmyk);
|
||||
assert!(image_samples(&r.bytes).first().is_some_and(|s| samples_close(s, &as_srgb, false, 1)), "unread profile: converted as sRGB");
|
||||
}
|
||||
|
||||
/// With Preserve Numbers, an RGB image that carries an ICC profile is converted from that profile
|
||||
/// whatever the destination, while an untagged one keeps its numbers in an RGB destination (and
|
||||
/// converts from sRGB to a CMYK one, as before): to Generic CMYK, sRGB, Wide Gamut RGB, and Wide
|
||||
/// Gamut RGB that is also the document's RGB profile, and in PDF/X-1a, which converts the same way.
|
||||
/// A gray image keeps its profile, except in an sRGB destination, where it is converted to sRGB
|
||||
/// grays. An RGB profile the CMS can't read leaves the image as it is in an RGB destination, and
|
||||
/// its numbers converted as sRGB ones to a CMYK destination, with a warning.
|
||||
#[test]
|
||||
fn preserve_numbers_converts_tagged_images_from_their_profile() {
|
||||
use vectorcraft_color::cms::{self, ColorSettings, DISPLAY_P3, GENERIC_CMYK, Intent, SRGB, WIDE_GAMUT_RGB, icc_bytes};
|
||||
let intent = Intent::RelativeColorimetric;
|
||||
let settings_with =
|
||||
|rgb: &str| std::sync::Arc::new(cms::Cms::new(&ColorSettings { intent, rgb: rgb.into(), ..ColorSettings::default() }).unwrap());
|
||||
let (active, own) = (settings_with(SRGB), settings_with(WIDE_GAMUT_RGB));
|
||||
let mut p3 = icc_bytes(DISPLAY_P3).unwrap().to_vec();
|
||||
p3[8..12].copy_from_slice(&[4, 0x20, 0, 0]);
|
||||
let p3_profile = cms::IccProfile::from_bytes(None, &p3).unwrap();
|
||||
let from_p3 = |rgb: [u8; 3]| p3_profile.to_srgb(&rgb.map(|v| f32::from(v) / 255.0), intent).unwrap().map(|v| (v * 255.0).round() as u8);
|
||||
let img = colour_blocks();
|
||||
let tagged_png = doc(tagged(&img, &p3, ImageFormat::Png), "image/png");
|
||||
let untagged_png = doc(encoded(img.clone(), ImageFormat::Png), "image/png");
|
||||
let device = |space: &str| vec![Written { space: space.into(), icc: None, bits: 8, filter: "FlateDecode".into(), smask: false }];
|
||||
let cmyk = cms::Cms::new(&ColorSettings { intent, cmyk: GENERIC_CMYK.into(), ..ColorSettings::default() }).unwrap();
|
||||
let cmy = cms::ProofLut::build(|rgb| {
|
||||
let v = cmyk.srgb_to_cmyk(rgb, intent);
|
||||
[v[0], v[1], v[2]]
|
||||
});
|
||||
let black = cms::ProofLut::build(|rgb| [cmyk.srgb_to_cmyk(rgb, intent)[3], 0.0, 0.0]);
|
||||
let wide_lut = cms::ProofLut::build(|rgb| own.srgb_to_rgb(rgb));
|
||||
let to_cmyk = |rgb: [u8; 3]| [cmy.apply8(rgb).as_slice(), &black.apply8(rgb)[..1]].concat();
|
||||
let to_wide = |rgb: [u8; 3]| wide_lut.apply8(rgb).to_vec();
|
||||
let to_srgb = |rgb: [u8; 3]| rgb.to_vec();
|
||||
type ToDest<'a> = &'a dyn Fn([u8; 3]) -> Vec<u8>;
|
||||
// Each case: what, the color settings, the export settings, the space images are written in,
|
||||
// how an sRGB pixel converts to the destination, and whether untagged images keep their numbers.
|
||||
type Case<'a> = (&'a str, &'a std::sync::Arc<cms::Cms>, Value, &'a str, ToDest<'a>, bool);
|
||||
let cases: [Case<'_>; 5] = [
|
||||
("CMYK", &active, json!({"output": {"conversion": "preserveNumbers", "destination": GENERIC_CMYK}}), "DeviceCMYK", &to_cmyk, false),
|
||||
("sRGB", &active, json!({"output": {"conversion": "preserveNumbers", "destination": SRGB}}), "DeviceRGB", &to_srgb, true),
|
||||
("Wide Gamut", &active, json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}}), "DeviceRGB", &to_wide, true),
|
||||
("own RGB", &own, json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}}), "DeviceRGB", &to_wide, true),
|
||||
(
|
||||
"PDF/X-1a",
|
||||
&active,
|
||||
json!({"standard": "pdfX1a", "compatibility": "1.3", "output": {"destination": GENERIC_CMYK}}),
|
||||
"DeviceCMYK",
|
||||
&to_cmyk,
|
||||
false,
|
||||
),
|
||||
];
|
||||
for (what, color, settings, space, to_dest, keeps) in cases {
|
||||
let export = |d: &Document| {
|
||||
let mut s: PdfSettings = serde_json::from_value(settings.clone()).unwrap();
|
||||
s.compression.compress_text = false;
|
||||
let r = cms::with_active((*color).clone(), || export_with_report(d, &PdfOptions { settings: s, ..Default::default() })).unwrap();
|
||||
assert!(r.warnings.is_empty(), "{what}: {:?}", r.warnings);
|
||||
if what == "PDF/X-1a" {
|
||||
crate::pdfx::verify(&r.bytes, Standard::PdfX1a).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
}
|
||||
(image_spaces(&r.bytes), image_samples(&r.bytes))
|
||||
};
|
||||
let (spaces, samples) = export(&tagged_png);
|
||||
assert_eq!(spaces, device(space), "{what}: tagged");
|
||||
let want = converted_samples(&img, |rgb| to_dest(from_p3(rgb)));
|
||||
let as_numbers = converted_samples(&img, to_dest);
|
||||
assert!(
|
||||
samples.len() == 1 && samples_close(&samples[0], &want, false, 1),
|
||||
"{what}: converted from the profile, {}",
|
||||
max_diff(&samples[0], &want)
|
||||
);
|
||||
assert!(!samples_close(&samples[0], &as_numbers, false, 8), "{what}: not converted as its numbers");
|
||||
let (spaces, samples) = export(&untagged_png);
|
||||
assert_eq!(spaces, device(space), "{what}: untagged");
|
||||
let untagged = if keeps { img.to_rgb8().into_raw() } else { as_numbers };
|
||||
assert!(samples.len() == 1 && samples_close(&samples[0], &untagged, false, 1), "{what}: untagged, {}", max_diff(&samples[0], &untagged));
|
||||
}
|
||||
// With RGB colours ICC-tagged as sRGB, the tagged image is written as its sRGB samples, in an
|
||||
// ICC-based colour space with the sRGB profile.
|
||||
let settings = json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB, "profiles": "all"}});
|
||||
let (spaces, pdf) = cms::with_active(active.clone(), || export_images(&tagged_png, settings));
|
||||
let is_srgb = |icc: &[u8]| {
|
||||
let p = cms::IccProfile::from_bytes(None, icc).unwrap();
|
||||
[[0.2, 0.5, 0.9], [0.9, 0.1, 0.4]].iter().all(|v| p.to_srgb(v, intent).unwrap().iter().zip(v).all(|(a, b)| (a - b).abs() < 0.01))
|
||||
};
|
||||
assert!(spaces.len() == 1 && spaces[0].space == "ICCBased" && spaces[0].icc.as_deref().is_some_and(is_srgb), "tagged as sRGB: {spaces:?}");
|
||||
let samples = image_samples(&pdf);
|
||||
let want = converted_samples(&img, |rgb| from_p3(rgb).to_vec());
|
||||
assert!(samples.len() == 1 && samples_close(&samples[0], &want, false, 1), "tagged as sRGB, {}", max_diff(&samples[0], &want));
|
||||
// A gray image keeps its gray profile, in a CMYK and in an RGB destination, and in an RGB one
|
||||
// with RGB colours ICC-tagged as sRGB (`all` profiles, PDF/A-2b).
|
||||
let gray = gray_profile(&[0x01CD]);
|
||||
let gray_doc = doc(tagged(&colour().grayscale(), &gray, ImageFormat::Tiff), "image/tiff");
|
||||
for (what, settings) in [
|
||||
(GENERIC_CMYK, json!({"output": {"conversion": "preserveNumbers", "destination": GENERIC_CMYK}})),
|
||||
(WIDE_GAMUT_RGB, json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}})),
|
||||
("all profiles", json!({"output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB, "profiles": "all"}})),
|
||||
("PDF/A-2b", json!({"standard": "pdfA2b", "output": {"conversion": "preserveNumbers", "destination": WIDE_GAMUT_RGB}})),
|
||||
] {
|
||||
let (spaces, _) = cms::with_active(active.clone(), || export_images(&gray_doc, settings));
|
||||
assert!(spaces.len() == 1 && spaces[0].space == "ICCBased" && spaces[0].icc.as_deref() == Some(gray.as_slice()), "gray, {what}: {spaces:?}");
|
||||
}
|
||||
// In an sRGB destination it is converted to sRGB grays and written without it.
|
||||
let settings = json!({"output": {"conversion": "preserveNumbers", "destination": SRGB}});
|
||||
let (spaces, _) = cms::with_active(active.clone(), || export_images(&gray_doc, settings));
|
||||
assert!(spaces.len() == 1 && spaces[0].space == "DeviceGray" && spaces[0].icc.is_none(), "gray, sRGB: {spaces:?}");
|
||||
// A profile the CMS can't read: the image keeps it and its numbers in an RGB destination, and
|
||||
// its numbers are converted as sRGB ones to a CMYK destination, with a warning each.
|
||||
let unread = icc_profile(b"RGB ", 600);
|
||||
let unread_doc = doc(tagged(&img, &unread, ImageFormat::Png), "image/png");
|
||||
let unread_export = |destination: &str| {
|
||||
let mut s: PdfSettings = serde_json::from_value(json!({"output": {"conversion": "preserveNumbers", "destination": destination}})).unwrap();
|
||||
s.compression.compress_text = false;
|
||||
cms::with_active(active.clone(), || export_with_report(&unread_doc, &PdfOptions { settings: s, ..Default::default() })).unwrap()
|
||||
};
|
||||
let r = unread_export(WIDE_GAMUT_RGB);
|
||||
assert!(r.warnings.iter().any(|w| w.contains("the image keeps it")), "{:?}", r.warnings);
|
||||
let spaces = image_spaces(&r.bytes);
|
||||
assert!(spaces.len() == 1 && spaces[0].space == "ICCBased" && spaces[0].icc.as_deref() == Some(unread.as_slice()), "unread profile: {spaces:?}");
|
||||
let r = unread_export(GENERIC_CMYK);
|
||||
assert!(r.warnings.iter().any(|w| w.contains("converted to the destination as sRGB")), "{:?}", r.warnings);
|
||||
let as_srgb = converted_samples(&img, to_cmyk);
|
||||
assert!(image_samples(&r.bytes).first().is_some_and(|s| samples_close(s, &as_srgb, false, 1)), "unread profile, CMYK: converted as sRGB");
|
||||
}
|
||||
|
||||
@@ -38,7 +38,13 @@ const UNIQUE_PLACEHOLDER: &str = "u_vc_unique_-";
|
||||
|
||||
pub(crate) fn export(doc: &Document, opts: &ExportOptions, native: Option<&[u8]>) -> Output {
|
||||
// Live geometry effects (Roughen, Warp, Offset Path, Effect → Pathfinder…) export as their result.
|
||||
let baked = vectorcraft_effects::bake_document(doc);
|
||||
// An instance of a symbol whose art has such effects is written as that art placed by the
|
||||
// instance and then baked, as the canvas draws it; other symbols keep one `<symbol>` def.
|
||||
// Hidden layers and objects are written when the options keep them; layers that do not print
|
||||
// always are. `native` (Preserve Editing) is the document as it is, with its live effects.
|
||||
let hidden = opts.hidden_layers;
|
||||
let layers = vectorcraft_effects::WrittenLayers { hidden, non_printing: true, hidden_objects: hidden };
|
||||
let baked = vectorcraft_effects::bake_document_placing_symbols(doc, true, layers);
|
||||
let doc = baked.as_ref().unwrap_or(doc);
|
||||
if opts.object_ids != ObjectIds::Unique {
|
||||
return write(doc, opts, native, "");
|
||||
|
||||
@@ -1061,8 +1061,8 @@ impl Writer<'_> {
|
||||
(self.xf, self.instance_xf) = saved;
|
||||
return;
|
||||
}
|
||||
if let Some(def) = self.symbol_use(sym, n, *xf) {
|
||||
let m = self.xf * *xf;
|
||||
let m = self.xf * *xf;
|
||||
if let Some(def) = self.symbol_use(sym, n, m) {
|
||||
let tr = if m == Affine::IDENTITY { String::new() } else { format!(" transform=\"{}\"", self.matrix(m)) };
|
||||
self.line(&format!("<use{id} xlink:href=\"#{def}\"{tr}{a}/>"));
|
||||
return;
|
||||
@@ -1103,7 +1103,8 @@ impl Writer<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The id of the `<symbol>` def instance `inst` (transform `xf`) can `<use>`, written on first
|
||||
/// The id of the `<symbol>` def instance `inst` can `<use>` with transform `xf` (the `<use>`'s
|
||||
/// own: the instance's transform after those of the instances it sits in), written on first
|
||||
/// use. `None` when the instance needs its own copy of the art: stained by its fill, or moved
|
||||
/// by a transform under which the def would not look as the canvas paints it ([`Reuse`]).
|
||||
fn symbol_use(&mut self, sym: &vectorcraft_doc::Symbol, inst: &Node, xf: Affine) -> Option<String> {
|
||||
|
||||
@@ -164,14 +164,22 @@ impl Writer<'_> {
|
||||
}
|
||||
|
||||
/// Reserve ids for every named object up front so generated def ids never collide with them.
|
||||
/// Symbols' art takes no ids, also where the drawing holds it placed by an instance (every
|
||||
/// instance of the symbol writes it).
|
||||
pub(super) fn assign_name_ids(&mut self) {
|
||||
if self.opts.object_ids == ObjectIds::Minimal {
|
||||
return;
|
||||
}
|
||||
let mut art = HashSet::new();
|
||||
for s in &self.doc.symbols {
|
||||
s.art.walk(&mut |n| {
|
||||
art.insert(n.id);
|
||||
});
|
||||
}
|
||||
let mut named: Vec<(NodeId, String)> = Vec::new();
|
||||
self.doc.walk(|n| {
|
||||
// Ruler guides are not written, so their names reserve no id.
|
||||
if n.is_ruler_guide() {
|
||||
if n.is_ruler_guide() || art.contains(&n.id) {
|
||||
return;
|
||||
}
|
||||
if let Some(name) = &n.name {
|
||||
|
||||
@@ -298,6 +298,11 @@ impl Writer<'_> {
|
||||
self.warn("type on a path with bullets or numbers is outlined to keep its look");
|
||||
return self.text_outlines(n, t);
|
||||
}
|
||||
// Nor the character a repeat mark is drawn as in the mark's width (Kurikaeshi Moji Shori).
|
||||
if !lay.repeat_marks.is_empty() {
|
||||
self.warn("type on a path that starts with a repeat mark drawn as the character it repeats is outlined to keep its look");
|
||||
return self.text_outlines(n, t);
|
||||
}
|
||||
return self.text_on_path(n, t, path, *start);
|
||||
}
|
||||
self.note_fonts(t, &lay);
|
||||
@@ -438,7 +443,8 @@ impl Writer<'_> {
|
||||
// reader would draw elsewhere, the next segment is placed.
|
||||
place = seg.brk || (!fewer && !base.anchored && positioned);
|
||||
if (st.h_scale - st.v_scale).abs() > 1e-9 || seg.scale != 1.0 {
|
||||
attrs.push_str(&format!(" textLength=\"{}\" lengthAdjust=\"spacingAndGlyphs\"", self.num(seg.advance * seg.scale)));
|
||||
let length = seg.advance * seg.scale + seg.repeat_widen;
|
||||
attrs.push_str(&format!(" textLength=\"{}\" lengthAdjust=\"spacingAndGlyphs\"", self.num(length)));
|
||||
}
|
||||
if st.rotation != 0.0 {
|
||||
attrs.push_str(&format!(" rotate=\"{}\"", self.num(-st.rotation)));
|
||||
@@ -495,7 +501,11 @@ impl Writer<'_> {
|
||||
});
|
||||
let Some(chars) = self.fonts.get_mut(at).map(|u| &mut u.chars) else { continue };
|
||||
// As written: a list marker's characters, a hyphen where a line breaks, capitals for All
|
||||
// Caps, the style's Digits.
|
||||
// Caps, the style's Digits, the character a repeat mark is drawn as.
|
||||
if let Some(c) = shown_repeat(lay, i, g) {
|
||||
chars.insert(c);
|
||||
continue;
|
||||
}
|
||||
let src = lay.marker_text(i).unwrap_or_else(|| if g.len == 0 { "-" } else { plain.get(g.byte..g.byte + g.len).unwrap_or("") });
|
||||
for c in src.chars().filter(|c| !c.is_control() && *c != '\u{ad}').map(|c| st.digits.map(c)) {
|
||||
if st.all_caps {
|
||||
@@ -711,6 +721,9 @@ struct Segment {
|
||||
/// Glyph Scaling of the segment's one glyph (Justification…), which a reader stretches it to
|
||||
/// (`textLength`); 1 for other segments.
|
||||
scale: f64,
|
||||
/// How much wider than the repeat mark the canvas draws the character the mark is drawn as
|
||||
/// (Kurikaeshi Moji Shori), which a reader stretches it to (`textLength`); 0 for other segments.
|
||||
repeat_widen: f64,
|
||||
/// A list marker's characters and tab, written in
|
||||
/// [`vectorcraft_doc::text::ParaList::marker_style`] of the run's style.
|
||||
marker: bool,
|
||||
@@ -720,6 +733,41 @@ struct Segment {
|
||||
/// given its own position (points).
|
||||
const PLACE_TOLERANCE: f64 = 1e-6;
|
||||
|
||||
/// Kurikaeshi Moji Shori: the character glyph `i` of `lay` shows when the layout drew a repeat mark
|
||||
/// as the character it repeats ([`vectorcraft_text::TextLayout::repeat_marks`]), or None.
|
||||
fn shown_repeat(lay: &vectorcraft_text::TextLayout, i: usize, g: &vectorcraft_text::PositionedGlyph) -> Option<char> {
|
||||
if lay.repeat_marks.is_empty() || g.len == 0 || lay.marker_text(i).is_some() {
|
||||
return None;
|
||||
}
|
||||
// The marks are in text order, one per line.
|
||||
let at = lay.repeat_marks.binary_search_by_key(&g.byte, |&(byte, _)| byte).ok()?;
|
||||
lay.repeat_marks.get(at).map(|&(_, c)| c)
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: how much wider than repeat mark `cluster` the canvas draws glyph `g`, the
|
||||
/// character the mark is drawn as in the mark's place (text space), or 0 when the face or the
|
||||
/// mark's glyph is not found.
|
||||
fn repeat_widen(g: &vectorcraft_text::PositionedGlyph, cluster: &str) -> f64 {
|
||||
let Some(face) = FontDb::global().face_by_id(g.font_id) else { return 0.0 };
|
||||
// ゝ or ヽ with a combining voicing mark is drawn as one glyph, the voiced mark's.
|
||||
let mark = match cluster {
|
||||
"ゝ\u{3099}" => 'ゞ',
|
||||
"ヽ\u{3099}" => 'ヾ',
|
||||
_ => match cluster.chars().next() {
|
||||
Some(c) => c,
|
||||
None => return 0.0,
|
||||
},
|
||||
};
|
||||
let mark_gid = face.glyph_for(mark);
|
||||
if mark_gid == 0 {
|
||||
return 0.0;
|
||||
}
|
||||
// Font units along the baseline → text space (size, Horizontal Scale and Glyph Scaling).
|
||||
let [a, b, ..] = g.xf.as_coeffs();
|
||||
let widen = (face.advance(g.gid) - face.advance(mark_gid)) * a.hypot(b);
|
||||
if widen.is_finite() { widen } else { 0.0 }
|
||||
}
|
||||
|
||||
/// The laid-out lines of `t` as segments: a new segment at every style change, after tabs and,
|
||||
/// on justified lines, after each word space (unless `fewer`). The text comes from the clusters
|
||||
/// the layout placed: soft hyphens draw nothing, a line broken by hyphenation ends in `-`, all
|
||||
@@ -808,9 +856,16 @@ fn text_lines(t: &TextObject, lay: &vectorcraft_text::TextLayout, fewer: bool) -
|
||||
}
|
||||
None => (g.advance, g.origin.x),
|
||||
};
|
||||
let src: String = source(line.glyph_start + k, g).chars().filter(|c| *c != '\u{ad}').map(|c| run.style.digits.map(c)).collect();
|
||||
let repeat = shown_repeat(lay, line.glyph_start + k, g);
|
||||
let src: String = match repeat {
|
||||
Some(c) => c.to_string(),
|
||||
None => source(line.glyph_start + k, g).chars().filter(|c| *c != '\u{ad}').map(|c| run.style.digits.map(c)).collect(),
|
||||
};
|
||||
let widen = if repeat.is_some() { repeat_widen(g, source(line.glyph_start + k, g)) } else { 0.0 };
|
||||
let piece = if run.style.all_caps { src.to_uppercase() } else { src };
|
||||
let brk = piece == "\t" || (split_words && !piece.is_empty() && piece.chars().all(char::is_whitespace));
|
||||
// The character a repeat mark is drawn as takes the mark's width on the canvas, which a
|
||||
// reader does not know: the text after it is placed anew.
|
||||
let brk = piece == "\t" || (split_words && !piece.is_empty() && piece.chars().all(char::is_whitespace)) || repeat.is_some();
|
||||
// A glyph Glyph Scaling widens or narrows is a segment of its own, stretched to its width.
|
||||
let scale = if reader.is_some() && (g.scale - 1.0).abs() > 1e-9 && g.scale.is_finite() { g.scale } else { 1.0 };
|
||||
let fresh = std::mem::take(&mut after_inline) || scale != 1.0 || segs.last().is_some_and(|last| last.scale != 1.0);
|
||||
@@ -824,7 +879,8 @@ fn text_lines(t: &TextObject, lay: &vectorcraft_text::TextLayout, fewer: bool) -
|
||||
let marker = lay.marker_of(line.glyph_start + k).is_some();
|
||||
let tab_apart = piece == "\t" && (run.style.h_scale - run.style.v_scale).abs() > 1e-9;
|
||||
match segs.last_mut() {
|
||||
Some(last) if last.run == g.run && !last.brk && !fresh && !moved && last.marker == marker && !tab_apart => {
|
||||
// The character a repeat mark is drawn as is a segment of its own, stretched to its width.
|
||||
Some(last) if last.run == g.run && !last.brk && !fresh && !moved && last.marker == marker && !tab_apart && repeat.is_none() => {
|
||||
last.text.push_str(&piece);
|
||||
last.advance += advance;
|
||||
last.brk = brk;
|
||||
@@ -834,7 +890,7 @@ fn text_lines(t: &TextObject, lay: &vectorcraft_text::TextLayout, fewer: bool) -
|
||||
last.brk |= moved || last.marker != marker;
|
||||
end_segment(last, tail, t, lay, &mut unkerned);
|
||||
}
|
||||
segs.push(Segment { run: g.run, x, y: g.origin.y, text: piece, advance, brk, scale, marker });
|
||||
segs.push(Segment { run: g.run, x, y: g.origin.y, text: piece, advance, brk, scale, repeat_widen: widen, marker });
|
||||
}
|
||||
}
|
||||
tail = set.map(|_| (g.byte, advance));
|
||||
|
||||
@@ -299,6 +299,109 @@ fn a_stained_instance_with_a_geometry_effect_keeps_its_stain() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Symbol "Moved": a red square whose Transform effect moves it `dx` pt right.
|
||||
fn add_moved_symbol(d: &mut Document, square: Rect, dx: f64) {
|
||||
let mut art = Node::path(d.alloc_id(), shapes::rectangle(square), Appearance::basic(Paint::solid(Color::rgb8(255, 0, 0)), Paint::None, 0.0));
|
||||
art.appearance.effects.push(vectorcraft_doc::Effect { id: "distort.transform".into(), params: serde_json::json!({"moveH": dx}), visible: true });
|
||||
d.symbols.push(Symbol { dynamic: false, name: "Moved".into(), art: Arc::new(art) });
|
||||
}
|
||||
|
||||
/// Instances of a symbol whose art has a geometry effect are written as their art placed by the
|
||||
/// instance and then baked, where the canvas draws it: moved by the instance, doubled in width
|
||||
/// (the effect still moves it 100 pt, not 200 pt) and turned. They use no `<symbol>`, while the
|
||||
/// instances of a symbol without effects still share one.
|
||||
#[test]
|
||||
fn symbol_art_effects_are_written_where_the_canvas_draws_them() {
|
||||
let mut d = symbol_doc(0.0, &[Affine::translate((30.0, 100.0)), Affine::translate((60.0, 100.0))]);
|
||||
add_moved_symbol(&mut d, Rect::new(10.0, 10.0, 20.0, 20.0), 100.0);
|
||||
instance(&mut d, "Moved", Affine::IDENTITY);
|
||||
instance(&mut d, "Moved", Affine::translate((0.0, 20.0)) * Affine::scale_non_uniform(2.0, 1.0));
|
||||
instance(&mut d, "Moved", Affine::translate((-60.0, 40.0)) * Affine::rotate(0.5));
|
||||
let svg = export(&d, &ExportOptions::default());
|
||||
assert_eq!((svg.matches("<symbol ").count(), svg.matches("<use ").count()), (1, 2), "{svg}");
|
||||
assert!(!svg.contains("#Moved"), "{svg}");
|
||||
let canvas = render_artboard(&d);
|
||||
// The doubled square draws from x = 120 to 140 (its art placed from 20 to 40, then moved).
|
||||
assert_eq!(canvas.pixel(130, 35), [255, 0, 0, 255], "the canvas draws the doubled square there");
|
||||
assert_similar(&canvas, &resvg_render(&svg, 200, 120), 24.0, 0.002);
|
||||
|
||||
// Without an artboard, the picture's box is that of the art as drawn: the square moved onto
|
||||
// x = 10 from x = -90.
|
||||
let mut d = Document::new(200.0, 120.0);
|
||||
add_moved_symbol(&mut d, Rect::new(-90.0, 10.0, -80.0, 20.0), 100.0);
|
||||
instance(&mut d, "Moved", Affine::IDENTITY);
|
||||
let svg = export(&d, &ExportOptions { artboard: None, ..Default::default() });
|
||||
assert!(svg.contains("viewBox=\"0 0 10 10\""), "{svg}");
|
||||
assert_eq!(resvg_render(&svg, 10, 10).pixel(5, 5), [255, 0, 0, 255], "{svg}");
|
||||
}
|
||||
|
||||
/// A hidden instance of a symbol with a geometry effect, kept by Hidden Layers, is written hidden
|
||||
/// as its art with the effect applied, as a visible one is.
|
||||
#[test]
|
||||
fn a_kept_hidden_instance_is_written_with_its_symbols_effects() {
|
||||
let mut d = Document::new(200.0, 120.0);
|
||||
add_moved_symbol(&mut d, Rect::new(10.0, 10.0, 20.0, 20.0), 100.0);
|
||||
let mut hidden = instance(&mut d, "Moved", Affine::IDENTITY);
|
||||
hidden.visible = false;
|
||||
let id = hidden.id;
|
||||
*d.node_mut(id).unwrap() = hidden;
|
||||
let svg = export(&d, &ExportOptions { hidden_layers: true, ..Default::default() });
|
||||
assert!(!svg.contains("<use"), "{svg}");
|
||||
let back = import(&svg).unwrap();
|
||||
let mut boxes = vec![];
|
||||
back.walk(|n| {
|
||||
if !n.visible {
|
||||
boxes.push(n.geometric_bounds());
|
||||
}
|
||||
});
|
||||
assert_eq!(boxes.len(), 1, "{svg}");
|
||||
assert!(boxes[0].is_some_and(|b| (b.x0 - 110.0).abs() < 1e-3 && (b.x1 - 120.0).abs() < 1e-3), "{boxes:?}: {svg}");
|
||||
}
|
||||
|
||||
/// Named art in a symbol with a geometry effect takes no id in the instances written as their
|
||||
/// art, as in an instance that has its own copy of a symbol's art, so two instances do not write
|
||||
/// the same id. The instances keep their own names as ids.
|
||||
#[test]
|
||||
fn instances_written_as_their_art_give_its_names_no_id() {
|
||||
let mut d = Document::new(200.0, 120.0);
|
||||
add_moved_symbol(&mut d, Rect::new(10.0, 10.0, 20.0, 20.0), 100.0);
|
||||
let mut art = (*d.symbols[0].art).clone();
|
||||
art.name = Some("Spot".into());
|
||||
d.symbols[0].art = Arc::new(art);
|
||||
for (name, xf) in [("First", Affine::IDENTITY), ("Second", Affine::translate((0.0, 40.0)))] {
|
||||
let mut n = instance(&mut d, "Moved", xf);
|
||||
n.name = Some(name.into());
|
||||
let id = n.id;
|
||||
*d.node_mut(id).unwrap() = n;
|
||||
}
|
||||
let svg = export(&d, &ExportOptions::default());
|
||||
let ids: Vec<&str> = svg.split(" id=\"").skip(1).filter_map(|s| s.split('"').next()).collect();
|
||||
let unique: std::collections::HashSet<&str> = ids.iter().copied().collect();
|
||||
assert_eq!(unique.len(), ids.len(), "{ids:?}: {svg}");
|
||||
assert!(!svg.contains("Spot"), "{svg}");
|
||||
assert!(ids.contains(&"First") && ids.contains(&"Second"), "{ids:?}: {svg}");
|
||||
}
|
||||
|
||||
/// An instance nested in the art of a scaled instance that has its own copy of the art is
|
||||
/// written as its art too when the def can't stand for it under the outer scale: its stroke
|
||||
/// keeps its weight, as on the canvas, rather than doubling with a scaled `<use>`.
|
||||
#[test]
|
||||
fn a_nested_instance_is_shared_only_under_the_transform_it_is_drawn_with() {
|
||||
let mut d = Document::new(200.0, 120.0);
|
||||
let ring = Node::path(
|
||||
d.alloc_id(),
|
||||
shapes::rectangle(Rect::new(-10.0, -10.0, 10.0, 10.0)),
|
||||
Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 4.0),
|
||||
);
|
||||
d.symbols.push(Symbol { dynamic: false, name: "Ring".into(), art: Arc::new(ring) });
|
||||
let inner = Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: "Ring".into(), xf: Affine::IDENTITY });
|
||||
d.symbols.push(Symbol { dynamic: false, name: "Holder".into(), art: Arc::new(inner) });
|
||||
instance(&mut d, "Holder", Affine::translate((100.0, 60.0)) * Affine::scale(2.0));
|
||||
let svg = export(&d, &ExportOptions::default());
|
||||
assert_similar(&render_artboard(&d), &resvg_render(&svg, 200, 120), 24.0, 0.002);
|
||||
assert!(!svg.contains("<use"), "{svg}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pattern_paints_in_symbols_stay_on_the_page() {
|
||||
let mut d = Document::new(200.0, 120.0);
|
||||
|
||||
@@ -923,3 +923,95 @@ fn paragraphs_aligned_differently_keep_their_alignment() {
|
||||
assert_similar(&render_artboard(&d), &render_artboard(&back), 40.0, 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
/// With Kurikaeshi Moji Shori on, live type writes a repeat mark that starts a line as the
|
||||
/// character it is drawn as and places the text after it anew, with and without embedded fonts; a
|
||||
/// mark inside a line stays.
|
||||
#[test]
|
||||
fn a_repeat_mark_at_a_line_start_is_written_as_the_character_it_draws() {
|
||||
use vectorcraft_text::test_fonts::{RARE_REPEAT_MARK_FAMILY, rare_repeat_mark_font};
|
||||
vectorcraft_text::FontDb::global().add_font(rare_repeat_mark_font().unwrap());
|
||||
let st = CharStyle { font_family: RARE_REPEAT_MARK_FAMILY.into(), ..style(12.0) };
|
||||
for on in [false, true] {
|
||||
let mut t = TextObject::point(Point::new(20.0, 40.0), "龘\u{2028}々龘龘々", st.clone());
|
||||
t.para.kurikaeshi_moji_shori = on;
|
||||
let mut d = Document::new(300.0, 200.0);
|
||||
let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t)));
|
||||
let l = d.layers[0].id;
|
||||
d.insert(Some(l), 0, n).unwrap();
|
||||
for embed_fonts in [false, true] {
|
||||
let svg = export(&d, &ExportOptions { embed_fonts, ..Default::default() });
|
||||
if !on {
|
||||
assert!(svg.contains(">々龘龘々<"), "{svg}");
|
||||
continue;
|
||||
}
|
||||
// The drawn character takes the mark's width on the canvas, so the text after it is
|
||||
// placed where the canvas draws it.
|
||||
let rest = svg.find(">龘龘々<").unwrap_or_else(|| panic!("{svg}"));
|
||||
let tag = &svg[svg[..rest].rfind('<').unwrap_or(0)..rest];
|
||||
assert!(tag.contains(" x=\""), "{tag}: {svg}");
|
||||
assert_eq!(svg.matches('々').count(), 1, "only the mark inside the line stays: {svg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori in horizontally scaled type: the character a repeat mark is drawn as is
|
||||
/// stretched (`textLength`) to the width the canvas draws that character at, not to the mark's
|
||||
/// advance, so a reader does not distort it when the two characters' widths differ.
|
||||
#[test]
|
||||
fn a_drawn_repeat_mark_in_scaled_type_keeps_the_width_of_its_character() {
|
||||
use vectorcraft_text::test_fonts::{RARE_REPEAT_MARK_FAMILY, rare_repeat_mark_font};
|
||||
vectorcraft_text::FontDb::global().add_font(rare_repeat_mark_font().unwrap());
|
||||
// The test font draws 龘 and 々 with glyphs of different widths.
|
||||
let st = CharStyle { font_family: RARE_REPEAT_MARK_FAMILY.into(), h_scale: 50.0, ..style(12.0) };
|
||||
let mut t = TextObject::point(Point::new(20.0, 40.0), "龘\u{2028}々", st);
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
let mut d = Document::new(300.0, 200.0);
|
||||
let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t)));
|
||||
let l = d.layers[0].id;
|
||||
d.insert(Some(l), 0, n).unwrap();
|
||||
let svg = export(&d, &ExportOptions::default());
|
||||
// The textLength of each `<tspan>` that holds 龘 alone: the one on the first line and the one
|
||||
// the mark is drawn as on the second.
|
||||
let lengths: Vec<&str> = svg
|
||||
.match_indices(">龘<")
|
||||
.map(|(at, _)| {
|
||||
let tag = &svg[svg[..at].rfind('<').unwrap_or(0)..at];
|
||||
let from = tag.find("textLength=\"").unwrap_or_else(|| panic!("{tag}: {svg}")) + "textLength=\"".len();
|
||||
&tag[from..from + tag[from..].find('"').unwrap_or(0)]
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(lengths.len(), 2, "{svg}");
|
||||
assert_eq!(lengths[0], lengths[1], "{svg}");
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: a `<textPath>` cannot draw a character in another character's width, so
|
||||
/// type on a path whose threaded frame starts with a repeat mark drawn as the character it repeats
|
||||
/// is outlined, with a warning; with the setting off it stays live text.
|
||||
#[test]
|
||||
fn a_repeat_mark_starting_a_frame_on_a_path_is_outlined() {
|
||||
use vectorcraft_text::test_fonts::{RARE_REPEAT_MARK_FAMILY, rare_repeat_mark_font};
|
||||
vectorcraft_text::FontDb::global().add_font(rare_repeat_mark_font().unwrap());
|
||||
let st = CharStyle { font_family: RARE_REPEAT_MARK_FAMILY.into(), ..style(12.0) };
|
||||
let mut line = BezPath::new();
|
||||
line.move_to((20.0, 40.0));
|
||||
line.line_to((280.0, 40.0));
|
||||
for on in [false, true] {
|
||||
let mut t = TextObject::point(Point::ZERO, "々龘々", st.clone());
|
||||
t.kind = TextKind::OnPath { path: PathData::from_bezpath(&line), start: 0.0, end: None };
|
||||
t.para.kurikaeshi_moji_shori = on;
|
||||
t.first_para_continues = true;
|
||||
t.first_para_lead = Some('龘');
|
||||
let mut d = Document::new(300.0, 200.0);
|
||||
let n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t)));
|
||||
let l = d.layers[0].id;
|
||||
d.insert(Some(l), 0, n).unwrap();
|
||||
let out = vectorcraft_svg::export_full(&d, &ExportOptions::default(), None);
|
||||
let warned = out.warnings.iter().any(|w| w.contains("repeat mark"));
|
||||
if on {
|
||||
assert!(!out.svg.contains("<textPath") && warned, "{:?}: {}", out.warnings, out.svg);
|
||||
} else {
|
||||
assert!(out.svg.contains(">々龘々<") && !warned, "{:?}: {}", out.warnings, out.svg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ use super::{
|
||||
is_cjk, is_word_space, kashida, mark_word_ends, no_line_end, no_line_start, style_metrics,
|
||||
};
|
||||
use crate::justify::is_format_control;
|
||||
use crate::shape::{keep_inseparable_pairs, keep_korean_words};
|
||||
use crate::shape::{keep_inseparable_pairs, keep_korean_words, repeat_base, repeated_char, shape_range};
|
||||
use std::cell::Cell;
|
||||
|
||||
/// Does paragraph `para` push characters in (Kinsoku Shori Type Push In First or Push Out First,
|
||||
/// with kinsoku on)?
|
||||
@@ -213,6 +214,12 @@ struct ParagraphData<'a, 'text> {
|
||||
bidi: Option<BidiInfo<'text>>,
|
||||
rtl: bool,
|
||||
continued: bool,
|
||||
/// Kurikaeshi Moji Shori: the character before a `continued` paragraph in the frames before
|
||||
/// ([`TextObject::first_para_lead`]).
|
||||
lead: Option<char>,
|
||||
/// Kurikaeshi Moji Shori: the byte the paragraph's text has been scanned to for the character a
|
||||
/// repeat mark could stand for, and that character so far ([`ParagraphData::repeat_base_before`]).
|
||||
repeat_scan: Cell<(usize, Option<char>)>,
|
||||
sg: Vec<SGlyph>,
|
||||
compressed: Vec<bool>,
|
||||
wakan: Vec<f64>,
|
||||
@@ -231,6 +238,21 @@ struct ParagraphData<'a, 'text> {
|
||||
regions: Option<&'a [Region]>,
|
||||
}
|
||||
|
||||
impl ParagraphData<'_, '_> {
|
||||
/// Kurikaeshi Moji Shori: the character a repeat mark at byte `at` of `text` could stand for,
|
||||
/// the last one before it in the paragraph that [`repeat_base`] takes, or else the paragraph's
|
||||
/// `lead`. Lines are laid out in order, so each call scans on from where the call before it
|
||||
/// stopped; a byte before that starts the scan again at the paragraph's start. None when `at`
|
||||
/// does not fall on a character boundary after the paragraph's start.
|
||||
fn repeat_base_before(&self, text: &str, at: usize) -> Option<Option<char>> {
|
||||
let (from, base) = self.repeat_scan.get();
|
||||
let (from, base) = if from <= at { (from, base) } else { (self.pr.start, self.lead) };
|
||||
let base = repeat_base(text.get(from..at)?).or(base);
|
||||
self.repeat_scan.set((at, base));
|
||||
Some(base)
|
||||
}
|
||||
}
|
||||
|
||||
fn prepare_paragraph<'a, 'text>(
|
||||
cx: &mut Ctx<'text>,
|
||||
pen: &mut Pen<'_>,
|
||||
@@ -324,13 +346,16 @@ fn prepare_paragraph<'a, 'text>(
|
||||
let zone = if cx.opts.composer.unwrap_or(para.composer).is_single_line() { para.hyphenation.zone } else { 0.0 };
|
||||
let hyphen_limit = usize::try_from(para.hyphenation.hyphen_limit).unwrap_or(usize::MAX);
|
||||
let mirror = mirrors_indents(para, rtl, cx.vertical);
|
||||
let lead = t.first_para_lead.filter(|_| continued);
|
||||
ParagraphData {
|
||||
para,
|
||||
repeat_scan: Cell::new((pr.start, lead)),
|
||||
pr,
|
||||
marker_text,
|
||||
bidi,
|
||||
rtl,
|
||||
continued,
|
||||
lead,
|
||||
sg,
|
||||
compressed,
|
||||
wakan,
|
||||
@@ -1272,6 +1297,58 @@ fn emit_line_glyph(
|
||||
cx.emit(glyph, Affine::translate(at.to_vec2()), at, 0.0, w.advance, line_index);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori (Paragraph panel menu): the glyph drawn in place of `g`, the first glyph of
|
||||
/// a line, when `g` is a repeat mark, and the character it shows: the character [`repeated_char`]
|
||||
/// gives for the character `base` finds before the mark, shaped in the mark's style with the type's
|
||||
/// features (so vertical type gets the font's vertical forms), from the same face, with the mark's
|
||||
/// advance and place, so the line breaks stay as they are. ゝ or ヽ followed by a combining voicing
|
||||
/// mark (U+3099) in one glyph counts as ゞ or ヾ. None when `g` is no repeat mark, belongs to a
|
||||
/// tate-chu-yoko or warichu block, holds other characters with the mark, shares its cluster with the
|
||||
/// glyph after it (`next`), `base` gives None, nothing before it fits, or the face draws the
|
||||
/// character with no glyph or with more than one. `base` runs only for a repeat mark.
|
||||
pub(super) fn repeat_mark_glyph(
|
||||
cx: &Ctx<'_>,
|
||||
g: &SGlyph,
|
||||
next: Option<&SGlyph>,
|
||||
base: impl FnOnce() -> Option<Option<char>>,
|
||||
) -> Option<(SGlyph, char)> {
|
||||
if g.tcy.is_some() || g.wari.is_some() || g.inline.is_some() || !matches!(g.ch, '々' | 'ゝ' | 'ゞ' | 'ヽ' | 'ヾ') {
|
||||
return None;
|
||||
}
|
||||
if next.is_some_and(|n| n.byte == g.byte) {
|
||||
return None;
|
||||
}
|
||||
let mark = match cx.text.get(g.byte..g.byte + g.len)? {
|
||||
"ゝ\u{3099}" => 'ゞ',
|
||||
"ヽ\u{3099}" => 'ヾ',
|
||||
cluster if cluster.len() == g.ch.len_utf8() => g.ch,
|
||||
_ => return None,
|
||||
};
|
||||
let c = repeated_char(base()?, "", mark)?;
|
||||
let mut buf = [0; 4];
|
||||
let s: &str = c.encode_utf8(&mut buf);
|
||||
let mut shaped = Vec::with_capacity(1);
|
||||
shape_range(cx.db, s, 0..s.len(), &[(0..s.len(), cx.style_at(g.byte))], &[], &cx.opts.features, &[], &mut shaped);
|
||||
let [one] = shaped.as_slice() else { return None };
|
||||
(one.gid != 0 && one.face.id() == g.face.id()).then(|| (SGlyph { gid: one.gid, ..g.clone() }, c))
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the glyph drawn in place of glyph `first` of `paragraph`, the first
|
||||
/// character of a line that ends before glyph `end`, when the paragraph has the setting on and
|
||||
/// [`repeat_mark_glyph`] gives one for the character before it in the paragraph, or the paragraph's
|
||||
/// `lead` before a paragraph that continues from the frame before ([`TextObject::first_para_lead`]);
|
||||
/// it is recorded in [`crate::TextLayout::repeat_marks`].
|
||||
fn line_start_repeat(cx: &mut Ctx<'_>, paragraph: &ParagraphData<'_, '_>, first: usize, end: usize) -> Option<SGlyph> {
|
||||
if !paragraph.para.kurikaeshi_moji_shori || first >= end {
|
||||
return None;
|
||||
}
|
||||
let g = paragraph.sg.get(first)?;
|
||||
let text = cx.text;
|
||||
let (glyph, c) = repeat_mark_glyph(cx, g, paragraph.sg.get(first + 1), || paragraph.repeat_base_before(text, g.byte))?;
|
||||
cx.out.repeat_marks.push((g.byte, c));
|
||||
Some(glyph)
|
||||
}
|
||||
|
||||
/// Lay out `line` of `paragraph` as `justification` aligns it: each glyph placed along the
|
||||
/// baseline (tabs as [`tab_glyph`] sets them), its hyphen, and the line's record, then the pen
|
||||
/// moved on past it.
|
||||
@@ -1306,9 +1383,14 @@ fn emit_flow_line(cx: &mut Ctx<'_>, pen: &mut Pen<'_>, paragraph: &ParagraphData
|
||||
let mut marker_tab = 0;
|
||||
// The warichu blocks drawn on the line: the byte that names each and where it starts.
|
||||
let mut wari_blocks: Vec<(usize, f64)> = Vec::new();
|
||||
// Kurikaeshi Moji Shori: the line's first character after any list marker, drawn as the
|
||||
// character it repeats when it is a repeat mark.
|
||||
let first = index.max(paragraph.marker);
|
||||
let repeat = line_start_repeat(cx, paragraph, first, position.end);
|
||||
for (order_index, &offset) in order.iter().enumerate() {
|
||||
let glyph_index = index + offset;
|
||||
let Some(glyph) = sg.get(glyph_index) else { continue };
|
||||
let glyph = if glyph_index == first { repeat.as_ref().unwrap_or(glyph) } else { glyph };
|
||||
let mut advance = glyph.adv;
|
||||
if glyph_index + 1 == trimmed {
|
||||
advance -= line.end_trim;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::bidi::{is_rtl, para_bidi_with, visual_order};
|
||||
use super::breaking::{Metrics, optical_hangs, optical_hangs_rtl, optical_share, roman_share};
|
||||
use super::flow::list_markers;
|
||||
use super::flow::{list_markers, repeat_mark_glyph};
|
||||
use super::region::in_range;
|
||||
use super::{
|
||||
Affine, ArcPath, BezPath, Ctx, GlyphBend, Justify, LineInfo, ListMarker, ParamCurve, PathAlign, PathData, PathEffect, PathEl, Point, Range,
|
||||
@@ -409,6 +409,22 @@ fn hide_before_open_path(cx: &mut Ctx<'_>, ap: &ArcPath, lead: bool, at: usize,
|
||||
true
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: type on a path is one line, which starts with the first character of its
|
||||
/// first paragraph `pr` (shaped as `glyphs`). When that paragraph continues from the frame before
|
||||
/// and has the setting on, a repeat mark there is drawn as the character before it in the frames
|
||||
/// before ([`TextObject::first_para_lead`]): its glyph in `glyphs` is replaced, and the mark's byte
|
||||
/// and the character drawn are returned.
|
||||
fn line_start_repeat(cx: &Ctx<'_>, t: &TextObject, pr: &Range<usize>, glyphs: &mut [SGlyph]) -> Option<(usize, char)> {
|
||||
if !t.first_para_continues || !t.para_at(0).kurikaeshi_moji_shori {
|
||||
return None;
|
||||
}
|
||||
let at = glyphs.iter().position(|g| g.len > 0 && g.byte == pr.start)?;
|
||||
let (glyph, c) = repeat_mark_glyph(cx, glyphs.get(at)?, glyphs.get(at + 1), || Some(t.first_para_lead))?;
|
||||
let g = glyphs.get_mut(at)?;
|
||||
*g = glyph;
|
||||
Some((g.byte, c))
|
||||
}
|
||||
|
||||
/// Lay type on a path out along `path` (text space), between its brackets.
|
||||
pub(super) fn on_path(cx: &mut Ctx<'_>, paras: &[Range<usize>], t: &TextObject, path: &PathData) {
|
||||
cx.out.on_path = true;
|
||||
@@ -431,6 +447,8 @@ pub(super) fn on_path(cx: &mut Ctx<'_>, paras: &[Range<usize>], t: &TextObject,
|
||||
}
|
||||
shaped.push((pr.clone(), bidi.filter(|b| b.has_rtl() && !cx.vertical), glyphs));
|
||||
}
|
||||
// Kurikaeshi Moji Shori: the repeat mark that starts the line, recorded when its glyph is drawn.
|
||||
let mut repeat = shaped.first_mut().and_then(|(pr, _, glyphs)| line_start_repeat(cx, t, pr, glyphs));
|
||||
let rtl = rtl.unwrap_or(false);
|
||||
// The text before byte `cut` in visual order, as area type reorders each line it breaks.
|
||||
let visual = |cut: usize| {
|
||||
@@ -710,6 +728,9 @@ pub(super) fn on_path(cx: &mut Ctx<'_>, paras: &[Range<usize>], t: &TextObject,
|
||||
let at = cx.out.glyphs.len();
|
||||
cx.emit(g, pre, origin, angle, g.adv, 0);
|
||||
let hidden = hide_before_open_path(cx, &ap, lead, at, s + step * 0.5, rise);
|
||||
if !hidden && let Some(mark) = repeat.take_if(|&mut (byte, _)| g.len > 0 && g.byte == byte) {
|
||||
cx.out.repeat_marks.push(mark);
|
||||
}
|
||||
// A glyph of a script whose letters join is bent along a curved path (Rainbow), so its
|
||||
// joining strokes meet its neighbours' instead of standing off the curve.
|
||||
if !hidden && t.path_effect == PathEffect::Rainbow && g.cursive && !cx.vertical && g.inline.is_none() {
|
||||
|
||||
@@ -529,13 +529,14 @@ pub(super) fn align_vertically(cx: &mut Ctx<'_>, paras: &[Range<usize>], t: &Tex
|
||||
std::mem::take(&mut cx.out.lines),
|
||||
std::mem::take(&mut cx.out.inlines),
|
||||
std::mem::take(&mut cx.out.markers),
|
||||
std::mem::take(&mut cx.out.repeat_marks),
|
||||
std::mem::replace(&mut cx.out.overflow, false),
|
||||
);
|
||||
flow(cx, paras, t, Some(regions));
|
||||
if laid_out(&cx.out) < before {
|
||||
// Text no longer fits (lines got narrower, or flow around a wrap object): undo the
|
||||
// pass and try a smaller step.
|
||||
(cx.out.glyphs, cx.out.lines, cx.out.inlines, cx.out.markers, cx.out.overflow) = prev;
|
||||
(cx.out.glyphs, cx.out.lines, cx.out.inlines, cx.out.markers, cx.out.repeat_marks, cx.out.overflow) = prev;
|
||||
for (r, (shift, gap)) in regions.iter_mut().zip(saved) {
|
||||
r.shift = shift;
|
||||
r.gap = gap;
|
||||
|
||||
@@ -54,7 +54,7 @@ pub use svg_glyph::{SvgGlyphReader, set_svg_glyph_reader};
|
||||
pub use kept::{KeptLayoutsFrame, LayoutStamp, keep_layout, take_kept_layout};
|
||||
use kurbo::{Affine, BezPath, Point, Rect, Shape, Vec2};
|
||||
pub use layout::{decorations, drawn, fit_first_line, fit_source_lines, layout, layout_with, scaled};
|
||||
pub use shape::{aki_space, inseparable, line_start_space, spacing_scale};
|
||||
pub use shape::{aki_space, inseparable, line_start_space, repeat_base, spacing_scale};
|
||||
pub use vectorcraft_doc::TextObject;
|
||||
|
||||
pub use vectorcraft_doc::{AreaFit, FirstBaseline, TextFlow, VerticalAlign};
|
||||
@@ -401,6 +401,10 @@ pub struct TextLayout {
|
||||
pub inlines: Vec<InlineGlyph>,
|
||||
/// List markers, in text order.
|
||||
pub markers: Vec<ListMarker>,
|
||||
/// Kurikaeshi Moji Shori: the repeat marks drawn as the character they stand for, as (the
|
||||
/// mark's byte offset in the plain text, the character drawn), in text order. Writers that put
|
||||
/// characters in place of glyphs (live SVG text) write that character.
|
||||
pub repeat_marks: Vec<(usize, char)>,
|
||||
}
|
||||
|
||||
impl Default for TextLayout {
|
||||
@@ -419,6 +423,7 @@ impl Default for TextLayout {
|
||||
path_fill: None,
|
||||
inlines: Vec::new(),
|
||||
markers: Vec::new(),
|
||||
repeat_marks: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,6 +450,79 @@ pub fn inseparable(a: char, b: char) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the last character of `text` that a repeat mark after it could stand for:
|
||||
/// the last one that is neither a repeat mark, a soft return (U+2028) nor a combining voicing mark
|
||||
/// (U+3099, U+309A), or None when there is none. The engine gives a threaded frame whose first
|
||||
/// paragraph continues from the frame before the result for the text before it
|
||||
/// (`TextObject::first_para_lead`).
|
||||
pub fn repeat_base(text: &str) -> Option<char> {
|
||||
#[cfg(test)]
|
||||
REPEAT_SCANNED.with(|c| c.set(c.get() + text.len()));
|
||||
text.chars().rev().find(|&c| !matches!(c, '々' | 'ゝ' | 'ゞ' | 'ヽ' | 'ヾ' | '\u{2028}' | '\u{3099}' | '\u{309A}'))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
thread_local! {
|
||||
/// Tests: how many bytes of text [`repeat_base`] was given on this thread.
|
||||
static REPEAT_SCANNED: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Tests: how many bytes of text [`repeat_base`] has been given on this thread.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn repeat_scanned() -> usize {
|
||||
REPEAT_SCANNED.get()
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the character the repeat mark `mark` stands for after the text `before`
|
||||
/// it, or None when `mark` is not a repeat mark or nothing before it fits. `lead` stands before
|
||||
/// `before` (the text of a threaded paragraph in the frames before). VectorCraft's rules: the
|
||||
/// repeated character is the last one before the mark that is neither a repeat mark, a soft return
|
||||
/// (U+2028) nor a combining voicing mark ([`repeat_base`]); 々 repeats a Han ideograph, ゝ and ゞ a
|
||||
/// hiragana and ヽ and ヾ a katakana. ゝ and ヽ give the kana without its voicing marks, and ゞ and
|
||||
/// ヾ its voiced form, or the plain kana when it has none.
|
||||
pub(crate) fn repeated_char(lead: Option<char>, before: &str, mark: char) -> Option<char> {
|
||||
let script = match mark {
|
||||
'々' => Script::Han,
|
||||
'ゝ' | 'ゞ' => Script::Hiragana,
|
||||
'ヽ' | 'ヾ' => Script::Katakana,
|
||||
_ => return None,
|
||||
};
|
||||
let base = repeat_base(before).or(lead)?;
|
||||
if base.script() != script || (script != Script::Han && !matches!(base as u32, 0x3041..=0x3096 | 0x30A1..=0x30F6)) {
|
||||
return None;
|
||||
}
|
||||
if script == Script::Han {
|
||||
return Some(base);
|
||||
}
|
||||
// Katakana from U+30A1 to U+30F6 lie 0x60 past their hiragana, so one table serves both.
|
||||
let shift = if script == Script::Katakana { 0x60 } else { 0 };
|
||||
let plain = unvoiced(base as u32 - shift);
|
||||
let kana = if matches!(mark, 'ゞ' | 'ヾ') { voiced(plain).unwrap_or(plain) } else { plain };
|
||||
char::from_u32(kana + shift)
|
||||
}
|
||||
|
||||
/// The hiragana `h` (a code point) without its dakuten or handakuten.
|
||||
fn unvoiced(h: u32) -> u32 {
|
||||
match h {
|
||||
0x304C..=0x3062 if h.is_multiple_of(2) => h - 1,
|
||||
0x3065 | 0x3067 | 0x3069 => h - 1,
|
||||
0x3070..=0x307D => h - (h - 0x306F) % 3,
|
||||
0x3094 => 0x3046,
|
||||
_ => h,
|
||||
}
|
||||
}
|
||||
|
||||
/// The voiced form (with dakuten) of the plain hiragana `h`, if it has one.
|
||||
fn voiced(h: u32) -> Option<u32> {
|
||||
match h {
|
||||
0x304B..=0x3061 if !h.is_multiple_of(2) => Some(h + 1),
|
||||
0x3064 | 0x3066 | 0x3068 => Some(h + 1),
|
||||
0x306F..=0x307B if (h - 0x306F).is_multiple_of(3) => Some(h + 1),
|
||||
0x3046 => Some(0x3094),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Is `c` Hangul: a syllable, a jamo or a compatibility jamo (full or half width)?
|
||||
pub(crate) fn is_hangul(c: char) -> bool {
|
||||
c.script() == Script::Hangul
|
||||
|
||||
@@ -484,6 +484,73 @@ pub fn full_width_font() -> Option<Vec<u8>> {
|
||||
Some(builder.build())
|
||||
}
|
||||
|
||||
/// The family of [`repeat_mark_font`].
|
||||
pub const REPEAT_MARK_FAMILY: &str = "Repeattest Sans";
|
||||
|
||||
/// The Japanese characters [`repeat_mark_font`] maps, each to the glyph of the Latin capital beside
|
||||
/// it: an ideograph, the repeat marks, kana with and without their voicing marks, and the combining
|
||||
/// voicing mark (U+3099), so that a repeat mark followed by it is shaped in this font and not in a
|
||||
/// fallback font that also has both characters (craft-fonts' Japanese faces).
|
||||
pub const REPEAT_MARK_CHARS: [(char, char); 12] = [
|
||||
('時', 'A'),
|
||||
('々', 'B'),
|
||||
('す', 'C'),
|
||||
('ず', 'D'),
|
||||
('ゝ', 'E'),
|
||||
('ゞ', 'F'),
|
||||
('サ', 'G'),
|
||||
('ザ', 'H'),
|
||||
('ヽ', 'I'),
|
||||
('ヾ', 'J'),
|
||||
('あ', 'K'),
|
||||
('\u{3099}', 'L'),
|
||||
];
|
||||
|
||||
/// A test-only cmap over bundled Source Sans 3: each of [`REPEAT_MARK_CHARS`] uses the glyph of its
|
||||
/// Latin capital, so the glyph drawn for a repeat mark tells which character was drawn; the space
|
||||
/// keeps its own glyph.
|
||||
pub fn repeat_mark_font() -> Option<Vec<u8>> {
|
||||
repeat_font(REPEAT_MARK_FAMILY, &REPEAT_MARK_CHARS)
|
||||
}
|
||||
|
||||
/// The family of [`rare_repeat_mark_font`].
|
||||
pub const RARE_REPEAT_MARK_FAMILY: &str = "Raretest Sans";
|
||||
|
||||
/// [`repeat_mark_font`] for tests that add it to the shared [`crate::FontDb::global`]: it maps
|
||||
/// only 龘 (to the glyph of A) and 々 (to the glyph of B), characters no other text in those tests
|
||||
/// uses, so other tests' Japanese text does not fall back to it.
|
||||
pub fn rare_repeat_mark_font() -> Option<Vec<u8>> {
|
||||
repeat_font(RARE_REPEAT_MARK_FAMILY, &[('龘', 'A'), ('々', 'B')])
|
||||
}
|
||||
|
||||
/// A font named `family` over bundled Source Sans 3 whose cmap maps each of `chars` to the glyph of
|
||||
/// the Latin capital beside it, and the space to its own glyph.
|
||||
fn repeat_font(family: &str, chars: &[(char, char)]) -> Option<Vec<u8>> {
|
||||
use write_fonts::tables::cmap::Cmap;
|
||||
|
||||
const BASE: &[u8] = include_bytes!("../../../assets/fonts/SourceSans3-Regular.ttf");
|
||||
let font = skrifa::FontRef::new(BASE).ok()?;
|
||||
let charmap = font.charmap();
|
||||
let mut mappings: Vec<(char, write_fonts::types::GlyphId)> = Vec::new();
|
||||
for &(c, latin) in chars.iter().chain(&[(' ', ' ')]) {
|
||||
mappings.push((c, write_fonts::types::GlyphId::new(charmap.map(latin)?.to_u32())));
|
||||
}
|
||||
let cmap = Cmap::from_mappings(mappings).ok()?;
|
||||
let full = format!("{family} Regular");
|
||||
let postscript = format!("{}-Regular", family.replace(' ', ""));
|
||||
let name = name_table(&[(1, family), (2, "Regular"), (4, &full), (6, &postscript)])?;
|
||||
let mut builder = FontBuilder::new();
|
||||
builder.add_table(&cmap).ok()?;
|
||||
builder.add_raw(Tag::new(b"name"), name);
|
||||
for r in font.table_directory.table_records() {
|
||||
let tag = Tag::new(&r.tag().to_be_bytes());
|
||||
if tag != Tag::new(b"GSUB") && !builder.contains(tag) {
|
||||
builder.add_raw(tag, font.table_data(r.tag())?.as_bytes());
|
||||
}
|
||||
}
|
||||
Some(builder.build())
|
||||
}
|
||||
|
||||
/// The family of [`half_form_font`].
|
||||
pub const HALF_FORM_FAMILY: &str = "Halftest Sans";
|
||||
|
||||
|
||||
@@ -2693,6 +2693,209 @@ fn bunri_kinshi_keeps_two_em_dashes_on_one_line() {
|
||||
assert_eq!(ends(&t), [kept, text.len(), second + split, second + text.len()]);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: the character a repeat mark stands for is the last one before it that is
|
||||
/// not a repeat mark, in the mark's script; ゝ and ヽ give it without voicing marks, ゞ and ヾ give
|
||||
/// its voiced form when it has one.
|
||||
#[test]
|
||||
fn repeat_marks_stand_for_the_character_before_them() {
|
||||
use crate::shape::repeated_char;
|
||||
for (before, mark, want) in [
|
||||
("時", '々', Some('時')),
|
||||
("時々", '々', Some('時')),
|
||||
("時\u{2028}", '々', Some('時')),
|
||||
("す", 'ゝ', Some('す')),
|
||||
("ず", 'ゝ', Some('す')),
|
||||
("す", 'ゞ', Some('ず')),
|
||||
("ず", 'ゞ', Some('ず')),
|
||||
("ぱ", 'ゝ', Some('は')),
|
||||
("は", 'ゞ', Some('ば')),
|
||||
("ぽ", 'ゞ', Some('ぼ')),
|
||||
("つ", 'ゞ', Some('づ')),
|
||||
("う", 'ゞ', Some('ゔ')),
|
||||
("あ", 'ゞ', Some('あ')),
|
||||
("サ", 'ヽ', Some('サ')),
|
||||
("ザ", 'ヽ', Some('サ')),
|
||||
("サ", 'ヾ', Some('ザ')),
|
||||
("ウ", 'ヾ', Some('ヴ')),
|
||||
("ピ", 'ヾ', Some('ビ')),
|
||||
("サ", 'ゝ', None),
|
||||
("す", 'ヽ', None),
|
||||
("す", '々', None),
|
||||
("時", 'ゝ', None),
|
||||
("A", '々', None),
|
||||
("", '々', None),
|
||||
("々ゝ", '々', None),
|
||||
("時", 'x', None),
|
||||
// A kana followed by a combining voicing mark is that kana.
|
||||
("か\u{3099}\u{2028}", 'ゝ', Some('か')),
|
||||
("か\u{3099}", 'ゞ', Some('が')),
|
||||
("ハ\u{309A}", 'ヽ', Some('ハ')),
|
||||
] {
|
||||
assert_eq!(repeated_char(None, before, mark), want, "{before:?} {mark}");
|
||||
}
|
||||
// The character before a paragraph that continues from the frame before stands in when the text
|
||||
// before the mark in this frame has none.
|
||||
assert_eq!(repeated_char(Some('時'), "", '々'), Some('時'));
|
||||
assert_eq!(repeated_char(Some('時'), "\u{2028}々", '々'), Some('時'));
|
||||
assert_eq!(repeated_char(Some('時'), "日", '々'), Some('日'));
|
||||
assert_eq!(repeated_char(Some('す'), "", '々'), None);
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori (a paragraph attribute): on, a repeat mark that starts a line is drawn as
|
||||
/// the character it repeats, in point and area type, horizontal and vertical, at a soft return or
|
||||
/// where a line wraps; a mark inside a line, one starting a paragraph and every mark with the
|
||||
/// setting off keep their own glyph. The line breaks and the glyphs' bytes do not change. Uses a test
|
||||
/// font that draws each character with a different Latin glyph.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_draws_the_repeated_character_at_a_line_start() {
|
||||
use crate::test_fonts::{REPEAT_MARK_FAMILY, repeat_mark_font};
|
||||
let db = FontDb::with_font_dirs(vec![]);
|
||||
db.add_font(repeat_mark_font().expect("test font"));
|
||||
let st = CharStyle { size: 20.0, font_family: REPEAT_MARK_FAMILY.into(), font_style: "Regular".into(), ..CharStyle::default() };
|
||||
let face = db.style_face(&st).expect("face");
|
||||
let glyph = |c: char| Some(face.glyph_for(c));
|
||||
let gid_of = |l: &TextLayout, b: usize| l.glyphs.iter().find(|g| g.byte == b).map(|g| g.gid);
|
||||
let ends = |l: &TextLayout| l.lines.iter().map(|line| line.end).collect::<Vec<_>>();
|
||||
// 時 | 々す | ゞ時々ザ | ヽ, then a paragraph that starts with 々.
|
||||
let text = "時\u{2028}々す\u{2028}ゞ時々ザ\u{2028}ヽ\n々";
|
||||
let at = |s: &str| text.find(s).unwrap();
|
||||
let (first_mark, voiced, inner, katakana, para_start) = (at("々す"), at("ゞ"), at("時々ザ") + "時".len(), at("ヽ"), text.len() - "々".len());
|
||||
for vertical in [false, true] {
|
||||
let mut t = TextObject::point(Point::ZERO, text, st.clone());
|
||||
t.vertical = vertical;
|
||||
let off = layout(&db, &t);
|
||||
t.set_paragraph_styles(vec![
|
||||
vectorcraft_doc::ParaStyle { kurikaeshi_moji_shori: true, ..t.para.clone() },
|
||||
vectorcraft_doc::ParaStyle { kurikaeshi_moji_shori: true, ..t.para.clone() },
|
||||
]);
|
||||
let on = layout(&db, &t);
|
||||
assert_eq!(ends(&on), ends(&off), "vertical {vertical}");
|
||||
let bytes = |l: &TextLayout| l.glyphs.iter().map(|g| g.byte).collect::<Vec<_>>();
|
||||
assert_eq!(bytes(&on), bytes(&off), "vertical {vertical}");
|
||||
// Off, each mark has its own glyph.
|
||||
for (b, mark) in [(first_mark, '々'), (voiced, 'ゞ'), (inner, '々'), (katakana, 'ヽ'), (para_start, '々')] {
|
||||
assert_eq!(gid_of(&off, b), glyph(mark), "vertical {vertical}: off, {mark} at {b}");
|
||||
}
|
||||
assert_eq!(gid_of(&on, first_mark), glyph('時'), "vertical {vertical}: 々 drawn as 時");
|
||||
assert_eq!(gid_of(&on, voiced), glyph('ず'), "vertical {vertical}: ゞ after す drawn as ず");
|
||||
assert_eq!(gid_of(&on, katakana), glyph('サ'), "vertical {vertical}: ヽ after ザ drawn as サ");
|
||||
assert_eq!(gid_of(&on, inner), glyph('々'), "vertical {vertical}: a mark inside a line keeps its glyph");
|
||||
assert_eq!(gid_of(&on, para_start), glyph('々'), "vertical {vertical}: a paragraph's first mark keeps its glyph");
|
||||
assert!(off.repeat_marks.is_empty());
|
||||
assert_eq!(on.repeat_marks, [(first_mark, '時'), (voiced, 'ず'), (katakana, 'サ')], "vertical {vertical}");
|
||||
}
|
||||
// Where area type wraps: each line holds one character, so 々 starts the second line.
|
||||
let mut t = TextObject::point(Point::ZERO, "時々", st.clone());
|
||||
let both: f64 = layout(&db, &t).glyphs.iter().map(|g| g.advance).sum();
|
||||
t.xf = Affine::IDENTITY;
|
||||
// The Soft set lets 々 start a line.
|
||||
t.para.kinsoku = vectorcraft_doc::Kinsoku::Soft;
|
||||
t.kind = TextKind::Area { frame: PathData::from_bezpath(&Rect::new(0.0, 0.0, both - 1.0, 200.0).to_path(0.1)) };
|
||||
let off = layout(&db, &t);
|
||||
assert_eq!(ends(&off), ["時".len(), "時々".len()]);
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
let on = layout(&db, &t);
|
||||
assert_eq!(ends(&on), ends(&off));
|
||||
assert_eq!(gid_of(&off, "時".len()), glyph('々'));
|
||||
assert_eq!(gid_of(&on, "時".len()), glyph('時'), "a wrapped line's 々 is drawn as 時");
|
||||
// A threaded frame whose first paragraph continues: a mark that starts the frame is drawn as the
|
||||
// character before it in the frame before, only while the paragraph continues.
|
||||
let mut t = TextObject::point(Point::ZERO, "々す\n々", st.clone());
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
t.first_para_lead = Some('時');
|
||||
assert_eq!(gid_of(&layout(&db, &t), 0), glyph('々'), "a frame that does not continue");
|
||||
t.first_para_continues = true;
|
||||
let on = layout(&db, &t);
|
||||
assert_eq!(gid_of(&on, 0), glyph('時'), "the frame's first 々 is drawn as 時");
|
||||
assert_eq!(gid_of(&on, "々す\n".len()), glyph('々'), "the next paragraph's first mark keeps its glyph");
|
||||
assert_eq!(on.repeat_marks, [(0, '時')]);
|
||||
// Type on a path is one line: a threaded frame on a path starts it the same way.
|
||||
let mut line = BezPath::new();
|
||||
line.move_to((0.0, 50.0));
|
||||
line.line_to((500.0, 50.0));
|
||||
t.kind = TextKind::OnPath { path: PathData::from_bezpath(&line), start: 0.0, end: None };
|
||||
let on = layout(&db, &t);
|
||||
assert!(on.on_path);
|
||||
assert_eq!(gid_of(&on, 0), glyph('時'), "type on a path: the frame's first 々 is drawn as 時");
|
||||
assert_eq!(gid_of(&on, "々す\n".len()), glyph('々'), "type on a path: the next paragraph's first mark keeps its glyph");
|
||||
assert_eq!(on.repeat_marks, [(0, '時')]);
|
||||
t.para.kurikaeshi_moji_shori = false;
|
||||
let off = layout(&db, &t);
|
||||
assert_eq!(gid_of(&off, 0), glyph('々'), "type on a path with the setting off");
|
||||
assert!(off.repeat_marks.is_empty());
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
t.first_para_continues = false;
|
||||
assert_eq!(gid_of(&layout(&db, &t), 0), glyph('々'), "type on a path in a frame that does not continue");
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: ゝ or ヽ typed with a combining voicing mark (U+3099) after it, which the
|
||||
/// font draws as one glyph, is drawn as the voiced character at a line start, as ゞ and ヾ are.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_draws_a_decomposed_voiced_mark_voiced() {
|
||||
use crate::test_fonts::{REPEAT_MARK_FAMILY, repeat_mark_font};
|
||||
let db = FontDb::with_font_dirs(vec![]);
|
||||
db.add_font(repeat_mark_font().expect("test font"));
|
||||
let st = CharStyle { size: 20.0, font_family: REPEAT_MARK_FAMILY.into(), font_style: "Regular".into(), ..CharStyle::default() };
|
||||
let face = db.style_face(&st).expect("face");
|
||||
let glyph = |c: char| Some(face.glyph_for(c));
|
||||
let gid_of = |l: &TextLayout, b: usize| l.glyphs.iter().find(|g| g.byte == b).map(|g| g.gid);
|
||||
for (text, mark, want) in [("す\u{2028}ゝ\u{3099}", 'ゞ', 'ず'), ("サ\u{2028}ヽ\u{3099}", 'ヾ', 'ザ')] {
|
||||
let at = text.find(['ゝ', 'ヽ']).expect("mark");
|
||||
let mut t = TextObject::point(Point::ZERO, text, st.clone());
|
||||
let off = layout(&db, &t);
|
||||
assert_eq!(gid_of(&off, at), glyph(mark), "{text:?}: off, the font draws the voiced mark");
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
let on = layout(&db, &t);
|
||||
assert_eq!(gid_of(&on, at), glyph(want), "{text:?}");
|
||||
assert_eq!(on.repeat_marks, [(at, want)], "{text:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: a paragraph with a repeat mark at the start of each of many lines is laid
|
||||
/// out in one scan of its text, not one scan of everything before each line.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_scans_a_paragraph_once() {
|
||||
use crate::shape::repeat_scanned;
|
||||
use crate::test_fonts::{REPEAT_MARK_FAMILY, repeat_mark_font};
|
||||
let db = FontDb::with_font_dirs(vec![]);
|
||||
db.add_font(repeat_mark_font().expect("test font"));
|
||||
let st = CharStyle { size: 20.0, font_family: REPEAT_MARK_FAMILY.into(), font_style: "Regular".into(), ..CharStyle::default() };
|
||||
let face = db.style_face(&st).expect("face");
|
||||
let text = format!("時{}", "\u{2028}々".repeat(2000));
|
||||
let mut t = TextObject::point(Point::ZERO, &text, st);
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
let before = repeat_scanned();
|
||||
let l = layout(&db, &t);
|
||||
let scanned = repeat_scanned() - before;
|
||||
assert!(scanned <= 2 * text.len(), "{scanned} bytes scanned for a paragraph of {}", text.len());
|
||||
// Every line's 々 is still drawn as 時.
|
||||
assert_eq!(l.repeat_marks.len(), 2000);
|
||||
assert!(l.glyphs.iter().filter(|g| g.byte > 0 && text.get(g.byte..).is_some_and(|s| s.starts_with('々'))).all(|g| g.gid == face.glyph_for('時')));
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: area type in a frame that isn't a rectangle, centered vertically, flows
|
||||
/// again until it settles, and keeps one record for each repeat mark it draws as another character.
|
||||
#[test]
|
||||
fn vertically_centered_repeat_marks_in_a_round_frame_are_recorded_once() {
|
||||
use crate::test_fonts::{REPEAT_MARK_FAMILY, repeat_mark_font};
|
||||
use vectorcraft_doc::VerticalAlign;
|
||||
let db = FontDb::with_font_dirs(vec![]);
|
||||
db.add_font(repeat_mark_font().expect("test font"));
|
||||
let st = CharStyle { size: 20.0, font_family: REPEAT_MARK_FAMILY.into(), font_style: "Regular".into(), ..CharStyle::default() };
|
||||
let text = format!("時{}", "\u{2028}々".repeat(5));
|
||||
let frame = kurbo::Ellipse::new((150.0, 150.0), (150.0, 150.0), 0.0).to_path(0.1);
|
||||
let mut t = area(&text, st, Rect::new(0.0, 0.0, 300.0, 300.0), Justify::Left);
|
||||
t.kind = TextKind::Area { frame: PathData::from_bezpath(&frame) };
|
||||
t.para.kurikaeshi_moji_shori = true;
|
||||
let top = layout(&db, &t);
|
||||
let marks: Vec<(usize, char)> = text.match_indices('々').map(|(b, _)| (b, '時')).collect();
|
||||
assert_eq!(top.repeat_marks, marks);
|
||||
t.area.vertical_align = VerticalAlign::Center;
|
||||
let lay = layout(&db, &t);
|
||||
assert!(lay.lines[0].baseline > top.lines[0].baseline + 1.0, "the text moves down");
|
||||
assert_eq!(lay.repeat_marks, marks);
|
||||
}
|
||||
|
||||
/// Bunri-Kinshi: a justified line spreads its room over the gaps between its CJK characters but not
|
||||
/// over the gap inside a vertical kana repeat mark, and still fills its width.
|
||||
#[test]
|
||||
|
||||
@@ -545,7 +545,7 @@ pub(super) fn own_choices(effect: &str, key: &str, cmyk: bool) -> Option<Vec<(&'
|
||||
}
|
||||
(vectorcraft_effects::CLASSIC_ROTATE, "surface") => vec![(tl!("No Shading"), "none"), (tl!("Diffuse"), "diffuse")],
|
||||
(vectorcraft_effects::CLASSIC_EXTRUDE | vectorcraft_effects::CLASSIC_REVOLVE | vectorcraft_effects::CLASSIC_ROTATE, "shadingColor") => {
|
||||
vec![(tl!("Black"), "black"), (tl!("Custom"), "custom"), (tl!("None"), "none")]
|
||||
vec![(tl!("Black"), "black"), (tl!("Custom"), "custom"), (tl!("None"), "none"), (tl!("Black Overprint"), "blackOverprint")]
|
||||
}
|
||||
(vectorcraft_effects::EXTRUDE | vectorcraft_effects::CLASSIC_EXTRUDE, "bevel") => vec![
|
||||
(tl!("None"), "none"),
|
||||
|
||||
@@ -1167,6 +1167,7 @@ font-technology Variable Променливи
|
||||
Highlight Size Размер на отблясъка
|
||||
Blend Steps Стъпки на преливане
|
||||
Shading Color Цвят на засенчването
|
||||
Black Overprint Черно с напечатване
|
||||
Draw Hidden Faces Изчертаване на скритите страни
|
||||
Eyedropper Пипета
|
||||
Eyedropper Applies: Пипетата прилага:
|
||||
@@ -2955,6 +2956,12 @@ digits Malayalam Малаялам
|
||||
Responsive Адаптивен
|
||||
Restore Възстановяване
|
||||
Restore every preference to its default (applied on OK) Възстановяване на всички настройки по подразбиране (прилага се при ОПК)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Единицата за новите документи от вградените размери, освен тези в пиксели, и за отворените файлове без записана единица; ако я изберете тук и натиснете ОК, тя става и единица на активния документ.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Дебелините на щрихите, тиретата и междините се показват в тази единица и въведените за тях числа се четат в нея.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Размерите на текста, междуредието и отстъпът на базовата линия се показват в тази единица и въведените за тях числа се четат в нея.
|
||||
The unit for East Asian type measurements, which no field uses yet. Единицата за мерките на източноазиатски текст, която засега не се използва от нито едно поле.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Когато е включено, число, въведено без единица в поле в пики, се чете в точки.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. При XML ID имената на обектите се показват като XML ID в Слоеве, Променливи и Опции за слоя.
|
||||
Reset all preferences to their defaults? Да се нулират ли всички настройки до стойностите по подразбиране?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Стойностите по подразбиране се прилагат, когато щракнете върху ОК в Настройки. Отказ там запазва текущите ви настройки.
|
||||
Restore Recovered Documents Възстановяване на възстановените документи
|
||||
@@ -2988,6 +2995,7 @@ digits Malayalam Малаялам
|
||||
Roman Hanging Punctuation Латинска висяща пунктуация
|
||||
Korean Line Break Anywhere Пренасяне на корейски текст навсякъде
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Настройки за източноазиатска композиция
|
||||
Korean Composition Settings Настройки за корейска композиция
|
||||
Rotate Завъртане
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -520,6 +520,7 @@
|
||||
Highlight Size Veličina odsjaja
|
||||
Blend Steps Koraci prelaza
|
||||
Shading Color Boja sjenčenja
|
||||
Black Overprint Crni pretisak
|
||||
Draw Hidden Faces Crtaj skrivene strane
|
||||
Revolve… Rotaciono tijelo…
|
||||
Inflate… Napuhni…
|
||||
@@ -2084,6 +2085,7 @@ digits Malayalam Malajalam
|
||||
Roman Hanging Punctuation Latinična viseća interpunkcija
|
||||
Korean Line Break Anywhere Prelom korejskog reda bilo gdje
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Postavke istočnoazijske kompozicije
|
||||
Korean Composition Settings Postavke korejske kompozicije
|
||||
Select a text object to edit its paragraph attributes. Odaberite tekstualni objekat da uredite njegove atribute pasusa.
|
||||
@@ -4378,6 +4380,12 @@ font-technology Variable Varijabilni
|
||||
Preferences Postavke
|
||||
Previous Prethodno
|
||||
Restore every preference to its default (applied on OK) Vrati svaku postavku na zadanu vrijednost (primjenjuje se na U redu)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Jedinica za nove dokumente ugrađenih veličina, osim onih u pikselima, i za otvorene datoteke bez zapisane jedinice; ako je odaberete ovdje i kliknete U redu, postaje i jedinica aktivnog dokumenta.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Debljine poteza, crtice i razmaci prikazuju se u ovoj jedinici, a brojevi uneseni za njih čitaju se u njoj.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Veličine teksta, prored i pomak osnovne linije prikazuju se u ovoj jedinici, a brojevi uneseni za njih čitaju se u njoj.
|
||||
The unit for East Asian type measurements, which no field uses yet. Jedinica za mjere istočnoazijskog teksta, koju još nijedno polje ne koristi.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Kad je uključeno, broj unesen bez jedinice u polje u picama čita se u tačkama.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Uz XML ID nazivi objekata prikazuju se kao XML ID u Slojevima, Varijablama i Opcijama sloja.
|
||||
Reset all preferences to their defaults? Vratiti sve postavke na zadane vrijednosti?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Zadane vrijednosti primjenjuju se kada kliknete U redu u Postavkama. Otkaži tamo zadržava vaše trenutne postavke.
|
||||
Smaller ↔ Larger Manje ↔ veće
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1657,6 +1657,7 @@ antiAlias Sharp Nítid
|
||||
Highlight Size Mida de la brillantor
|
||||
Blend Steps Passos de fusió
|
||||
Shading Color Color de l’ombra
|
||||
Black Overprint Negre en sobreimpressió
|
||||
Draw Hidden Faces Dibuixa les cares ocultes
|
||||
Eyedropper Comptagotes
|
||||
Eyedropper Applies: El comptagotes aplica:
|
||||
@@ -3783,6 +3784,12 @@ digits Malayalam Malaiàlam
|
||||
Responsive Adaptatiu
|
||||
Restore Restaura
|
||||
Restore every preference to its default (applied on OK) Restaura cada preferència al seu valor predeterminat (s’aplica en prémer D’acord)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. La unitat dels documents nous de mides predefinides, excepte les mides en píxels, i dels fitxers oberts que no registren cap unitat; si la trieu aquí i feu clic a D’acord, també passa a ser la unitat del document actiu.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Els gruixos de traç, els guions i els espais es mostren en aquesta unitat, i els nombres que s’hi escriuen es llegeixen en aquesta unitat.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Les mides del text, l’interlineat i el desplaçament de la línia de base es mostren en aquesta unitat, i els nombres que s’hi escriuen es llegeixen en aquesta unitat.
|
||||
The unit for East Asian type measurements, which no field uses yet. La unitat per a les mesures del text d’Àsia oriental, que encara no fa servir cap camp.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Quan està activat, un nombre escrit sense unitat en un camp en piques es llegeix en punts.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Amb ID XML, els noms dels objectes es mostren com a ID XML a Capes, Variables i Opcions de la capa.
|
||||
Reset all preferences to their defaults? Voleu restablir totes les preferències als valors predeterminats?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Els valors predeterminats s’apliquen quan feu clic a D’acord a Preferències. Cancel·la allà conserva les preferències actuals.
|
||||
Restore Recovered Documents Restaura els documents recuperats
|
||||
@@ -3831,6 +3838,7 @@ digits Malayalam Malaiàlam
|
||||
Roman Hanging Punctuation Puntuació penjant romana
|
||||
Korean Line Break Anywhere Salt de línia coreà a qualsevol lloc
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Configuració de composició de l’Àsia oriental
|
||||
Korean Composition Settings Configuració de composició coreana
|
||||
Rotate Gira
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -533,6 +533,7 @@
|
||||
Highlight Size Velikost odlesku
|
||||
Blend Steps Kroky prolnutí
|
||||
Shading Color Barva stínování
|
||||
Black Overprint Přetisk černou
|
||||
Draw Hidden Faces Kreslit skryté stěny
|
||||
Revolve… Rotační těleso…
|
||||
Inflate… Nafouknutí…
|
||||
@@ -2155,6 +2156,7 @@ digits Malayalam Malajálamské
|
||||
Roman Hanging Punctuation Visící latinková interpunkce
|
||||
Korean Line Break Anywhere Zalomení korejského řádku kdekoli
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Nastavení východoasijské sazby
|
||||
Korean Composition Settings Nastavení korejské sazby
|
||||
Select a text object to edit its paragraph attributes. Vyberte textový objekt, abyste mohli upravit atributy jeho odstavce.
|
||||
@@ -4483,6 +4485,12 @@ font-technology Variable Variabilní
|
||||
Preferences Předvolby
|
||||
Previous Předchozí
|
||||
Restore every preference to its default (applied on OK) Obnovit všechny předvolby na výchozí hodnoty (použije se po OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Jednotka nových dokumentů z vestavěných velikostí kromě velikostí v obrazových bodech a otevřených souborů bez uložené jednotky; když ji zde zvolíte a kliknete na OK, nastaví se i jako jednotka aktivního dokumentu.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Tloušťky tahů, čárky a mezery se zobrazují v této jednotce a čísla pro ně zadaná se v ní čtou.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Velikosti písma, proklad a posun účaří se zobrazují v této jednotce a čísla pro ně zadaná se v ní čtou.
|
||||
The unit for East Asian type measurements, which no field uses yet. Jednotka pro míry východoasijského písma, kterou zatím žádné pole nepoužívá.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Když je zapnuto, číslo zadané bez jednotky do pole v pica se čte v bodech.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. S volbou XML ID se názvy objektů zobrazují jako XML ID ve Vrstvách, Proměnných a Možnostech vrstvy.
|
||||
Reset all preferences to their defaults? Obnovit všechny předvolby na výchozí hodnoty?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Výchozí hodnoty se použijí po klepnutí na OK v Předvolbách. Zrušit tam zachová vaše současné předvolby.
|
||||
Smaller ↔ Larger Menší ↔ Větší
|
||||
|
||||
|
Can't render this file because it is too large.
|
File diff suppressed because it is too large
Load Diff
@@ -1185,6 +1185,7 @@ font-technology Variable Variabel
|
||||
Highlight Size Glanzpunktgröße
|
||||
Blend Steps Angleichungsstufen
|
||||
Shading Color Schattierungsfarbe
|
||||
Black Overprint Überdruckendes Schwarz
|
||||
Draw Hidden Faces Verdeckte Flächen zeichnen
|
||||
Eyedropper Pipette
|
||||
Sample Color from Screen Farbe vom Bildschirm aufnehmen
|
||||
@@ -3005,6 +3006,12 @@ digits Malayalam Malayalam
|
||||
Responsive Responsiv
|
||||
Restore Wiederherstellen
|
||||
Restore every preference to its default (applied on OK) Alle Voreinstellungen auf ihre Standardwerte zurücksetzen (wird bei OK angewendet)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Die Einheit für neue Dokumente in den integrierten Größen außer Pixelgrößen und für geöffnete Dateien ohne gespeicherte Einheit; wenn Sie sie hier wählen und auf OK klicken, erhält auch das aktive Dokument diese Einheit.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Konturstärken, Striche und Lücken werden in dieser Einheit angezeigt, und dafür eingegebene Zahlen werden in ihr gelesen.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Schriftgrade, Zeilenabstand und Grundlinienversatz werden in dieser Einheit angezeigt, und dafür eingegebene Zahlen werden in ihr gelesen.
|
||||
The unit for East Asian type measurements, which no field uses yet. Die Einheit für Maße in ostasiatischem Text, die noch kein Feld verwendet.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Wenn aktiviert, wird eine ohne Einheit eingegebene Zahl in einem Feld in Pica als Punkt gelesen.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Mit XML-ID werden Objektnamen in „Ebenen“, „Variablen“ und „Ebenenoptionen“ als XML-IDs angezeigt.
|
||||
Reset all preferences to their defaults? Alle Voreinstellungen auf ihre Standardwerte zurücksetzen?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Die Standardwerte werden angewendet, wenn Sie in den Voreinstellungen auf OK klicken. Abbrechen dort behält Ihre aktuellen Voreinstellungen.
|
||||
Restore Recovered Documents Wiederhergestellte Dokumente öffnen
|
||||
@@ -3038,6 +3045,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Hängende Interpunktion (lateinisch)
|
||||
Korean Line Break Anywhere Koreanischer Zeilenumbruch überall
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Einstellungen für ostasiatischen Satz
|
||||
Korean Composition Settings Einstellungen für koreanischen Satz
|
||||
Rotate Drehen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1152,6 +1152,7 @@ font-technology Variable Μεταβλητές
|
||||
Highlight Size Μέγεθος ανταύγειας
|
||||
Blend Steps Βήματα ανάμειξης
|
||||
Shading Color Χρώμα σκίασης
|
||||
Black Overprint Μαύρο με υπερεκτύπωση
|
||||
Draw Hidden Faces Σχεδίαση κρυφών εδρών
|
||||
Eyedropper Σταγονόμετρο (Eyedropper Tool)
|
||||
Eyedropper Applies: Το σταγονόμετρο εφαρμόζει:
|
||||
@@ -2088,6 +2089,7 @@ font-technology Variable Μεταβλητές
|
||||
Roman Hanging Punctuation Κρεμαστή στίξη όρθιας γραφής
|
||||
Korean Line Break Anywhere Αλλαγή γραμμής κορεατικών οπουδήποτε
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Ρυθμίσεις σύνθεσης ανατολικής Ασίας
|
||||
Korean Composition Settings Ρυθμίσεις κορεατικής σύνθεσης
|
||||
Rotate Περιστροφή
|
||||
@@ -3780,6 +3782,12 @@ digits Malayalam Μαλαγιάλαμ
|
||||
Reshape Type Area Αναδιαμόρφωση περιοχής κειμένου
|
||||
Responsive Αποκρινόμενο
|
||||
Restore every preference to its default (applied on OK) Επαναφορά όλων των προτιμήσεων στις προεπιλογές τους (εφαρμογή με το Εντάξει)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Η μονάδα για τα νέα έγγραφα από ενσωματωμένα μεγέθη, εκτός από μεγέθη σε εικονοστοιχεία, και για τα ανοιγμένα αρχεία χωρίς καταγεγραμμένη μονάδα· αν την επιλέξετε εδώ και πατήσετε Εντάξει, γίνεται και μονάδα του ενεργού εγγράφου.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Τα πάχη περιγράμματος, οι παύλες και τα διάκενα εμφανίζονται σε αυτή τη μονάδα και οι αριθμοί που πληκτρολογούνται γι’ αυτά διαβάζονται σε αυτή.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Τα μεγέθη κειμένου, το διάστιχο και η μετατόπιση γραμμής βάσης εμφανίζονται σε αυτή τη μονάδα και οι αριθμοί που πληκτρολογούνται γι’ αυτά διαβάζονται σε αυτή.
|
||||
The unit for East Asian type measurements, which no field uses yet. Η μονάδα για τις μετρήσεις κειμένου Ανατολικής Ασίας, την οποία δεν χρησιμοποιεί ακόμη κανένα πεδίο.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Όταν είναι ενεργό, ένας αριθμός που πληκτρολογείται χωρίς μονάδα σε πεδίο σε πίκες διαβάζεται σε σημεία.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Με το Αναγνωριστικό XML, τα ονόματα αντικειμένων εμφανίζονται ως αναγνωριστικά XML στα Επίπεδα, στις Μεταβλητές και στις Επιλογές επιπέδου.
|
||||
Reset all preferences to their defaults? Επαναφορά όλων των προτιμήσεων στις προεπιλογές τους;
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Οι προεπιλογές εφαρμόζονται όταν κάνετε κλικ στο Εντάξει στις Προτιμήσεις. Το Ακύρωση εκεί διατηρεί τις τρέχουσες προτιμήσεις σας.
|
||||
Restore Recovered Documents Επαναφορά ανακτημένων εγγράφων
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1208,6 +1208,7 @@ font-technology Variable Variables
|
||||
Highlight Size Tamaño del brillo
|
||||
Blend Steps Pasos de fusión
|
||||
Shading Color Color de sombreado
|
||||
Black Overprint Negro sobreimpreso
|
||||
Draw Hidden Faces Dibujar caras ocultas
|
||||
Eyedropper Cuentagotas
|
||||
Sample Color from Screen Tomar color de la pantalla
|
||||
@@ -3041,6 +3042,12 @@ digits Malayalam Malayálam
|
||||
Responsive Adaptable
|
||||
Restore Restaurar
|
||||
Restore every preference to its default (applied on OK) Restaurar todas las preferencias a sus valores predeterminados (se aplica al Aceptar)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. La unidad de los documentos nuevos de tamaños predefinidos, salvo los tamaños en píxeles, y de los archivos abiertos que no registran ninguna unidad; si la elige aquí y hace clic en Aceptar, también pasa a ser la unidad del documento activo.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Los grosores de trazo, los guiones y los huecos se muestran en esta unidad, y los números que se escriben para ellos se leen en ella.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Los tamaños de texto, el interlineado y el desplazamiento de línea de base se muestran en esta unidad, y los números que se escriben para ellos se leen en ella.
|
||||
The unit for East Asian type measurements, which no field uses yet. La unidad para las medidas del texto de Asia oriental, que todavía no usa ningún campo.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Si está activado, un número escrito sin unidad en un campo en picas se lee en puntos.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Con ID XML, los nombres de los objetos se muestran como ID XML en Capas, Variables y Opciones de capa.
|
||||
Reset all preferences to their defaults? ¿Restablecer todas las preferencias a sus valores predeterminados?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Los valores predeterminados se aplican al hacer clic en Aceptar en Preferencias. Cancelar ahí conserva sus preferencias actuales.
|
||||
Restore Recovered Documents Restaurar documentos recuperados
|
||||
@@ -3074,6 +3081,7 @@ digits Malayalam Malayálam
|
||||
Roman Hanging Punctuation Puntuación colgante romana
|
||||
Korean Line Break Anywhere Salto de línea coreano en cualquier lugar
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Ajustes de composición de Asia oriental
|
||||
Korean Composition Settings Ajustes de composición coreana
|
||||
Rotate Rotar
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -530,6 +530,7 @@
|
||||
Highlight Size Kiillon koko
|
||||
Blend Steps Sulautusvaiheet
|
||||
Shading Color Varjostusväri
|
||||
Black Overprint Päällepainettu musta
|
||||
Draw Hidden Faces Piirrä piilotetut pinnat
|
||||
Revolve… Pyöräytä…
|
||||
Inflate… Täytä ilmalla…
|
||||
@@ -2118,6 +2119,7 @@ digits Malayalam Malajalam
|
||||
Roman Hanging Punctuation Latinalaiset riippuvat välimerkit
|
||||
Korean Line Break Anywhere Korean rivinvaihto missä tahansa
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Itäaasialaisen ladonnan asetukset
|
||||
Korean Composition Settings Korean ladonnan asetukset
|
||||
Select a text object to edit its paragraph attributes. Valitse tekstiobjekti, jonka kappalemääritteitä haluat muokata.
|
||||
@@ -4402,6 +4404,12 @@ font-technology Variable Muuttuvat
|
||||
Preferences Asetukset
|
||||
Previous Edellinen
|
||||
Restore every preference to its default (applied on OK) Palauta kaikki asetukset oletuksiin (käytetään, kun valitaan OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Yksikkö uusille asiakirjoille valmiissa kooissa pikselikokoja lukuun ottamatta ja avatuille tiedostoille, joihin ei ole tallennettu yksikköä; kun valitset sen tässä ja napsautat OK, siitä tulee myös aktiivisen asiakirjan yksikkö.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Viivan paksuudet, katkoviivat ja välit näytetään tässä yksikössä, ja niille kirjoitetut luvut luetaan siinä.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Tekstin koot, riviväli ja perusviivan siirto näytetään tässä yksikössä, ja niille kirjoitetut luvut luetaan siinä.
|
||||
The unit for East Asian type measurements, which no field uses yet. Itä-Aasian tekstin mittojen yksikkö, jota mikään kenttä ei vielä käytä.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Kun asetus on käytössä, picoina näytettävään kenttään ilman yksikköä kirjoitettu luku luetaan pisteinä.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML-tunnus-asetuksella objektien nimet näytetään XML-tunnuksina kohteissa Tasot, Muuttujat ja Tason asetukset.
|
||||
Reset all preferences to their defaults? Palautetaanko kaikki asetukset oletuksiin?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Oletukset otetaan käyttöön, kun valitset Asetuksissa OK. Peruuta siellä säilyttää nykyiset asetuksesi.
|
||||
Smaller ↔ Larger Pienempi ↔ Suurempi
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1203,6 +1203,7 @@ font-technology Variable Variables
|
||||
Highlight Size Taille de la brillance
|
||||
Blend Steps Étapes de transition
|
||||
Shading Color Couleur d’ombrage
|
||||
Black Overprint Noir en surimpression
|
||||
Draw Hidden Faces Dessiner les faces cachées
|
||||
Eyedropper Pipette
|
||||
Sample Color from Screen Prélever une couleur à l’écran
|
||||
@@ -3033,6 +3034,12 @@ digits Malayalam Malayalam
|
||||
Responsive Adaptatif
|
||||
Restore Restaurer
|
||||
Restore every preference to its default (applied on OK) Rétablir toutes les préférences à leur valeur par défaut (appliqué avec OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. L’unité des nouveaux documents de tailles prédéfinies, sauf les tailles en pixels, et des fichiers ouverts qui n’enregistrent aucune unité, et si vous la choisissez ici puis cliquez sur OK, elle devient aussi l’unité du document actif.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Les épaisseurs de contour, les tirets et les espaces s’affichent dans cette unité, et les nombres saisis pour eux sont lus dans cette unité.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Les tailles de texte, l’interlignage et le décalage de la ligne de base s’affichent dans cette unité, et les nombres saisis pour eux sont lus dans cette unité.
|
||||
The unit for East Asian type measurements, which no field uses yet. L’unité des mesures du texte d’Asie orientale, qu’aucun champ n’utilise encore.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Si cette option est activée, un nombre saisi sans unité dans un champ en picas est lu en points.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Avec ID XML, les noms des objets s’affichent sous forme d’ID XML dans Calques, Variables et Options de calque.
|
||||
Reset all preferences to their defaults? Rétablir toutes les préférences à leur valeur par défaut ?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Les valeurs par défaut sont appliquées lorsque vous cliquez sur OK dans Préférences. Annuler y conserve vos préférences actuelles.
|
||||
Restore Recovered Documents Restaurer les documents récupérés
|
||||
@@ -3066,6 +3073,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Ponctuation romaine hors justification
|
||||
Korean Line Break Anywhere Saut de ligne coréen n’importe où
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Paramètres de composition d’Asie orientale
|
||||
Korean Composition Settings Paramètres de composition coréenne
|
||||
Rotate Rotation
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3096,6 +3096,12 @@
|
||||
Restore પુનઃસ્થાપિત કરો
|
||||
Restore Recovered Documents પુનઃપ્રાપ્ત દસ્તાવેજો પુનઃસ્થાપિત કરો
|
||||
Restore every preference to its default (applied on OK) દરેક પસંદગી તેના ડિફોલ્ટ પર પુનઃસ્થાપિત કરો (ઠીક પર લાગુ થશે)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. પિક્સેલ સિવાયના બિલ્ટ-ઇન કદના નવા દસ્તાવેજો અને કોઈ એકમ ન નોંધતી ખોલેલી ફાઇલો માટેનો એકમ; અહીં તેને પસંદ કરીને ઠીક ક્લિક કરવાથી સક્રિય દસ્તાવેજનો એકમ પણ તે બને છે.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. સ્ટ્રોકની જાડાઈ, ડૅશ અને અંતર આ એકમમાં દેખાય છે, અને તેમના માટે ટાઇપ કરેલી સંખ્યાઓ આ એકમમાં વંચાય છે.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. ટાઇપના કદ, લીડિંગ અને બેઝલાઇન શિફ્ટ આ એકમમાં દેખાય છે, અને તેમના માટે ટાઇપ કરેલી સંખ્યાઓ આ એકમમાં વંચાય છે.
|
||||
The unit for East Asian type measurements, which no field uses yet. પૂર્વ એશિયાઈ ટાઇપના માપ માટેનો એકમ, જેનો હજી કોઈ ફીલ્ડ ઉપયોગ કરતું નથી.
|
||||
When on, a number typed without a unit into a field in picas is read in points. ચાલુ હોય ત્યારે, પાઇકામાં હોય તેવા ફીલ્ડમાં એકમ વિના ટાઇપ કરેલી સંખ્યા પોઇન્ટ્સમાં વંચાય છે.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML ID પસંદ હોય ત્યારે ઑબ્જેક્ટનાં નામ લેયર્સ, વેરિએબલ્સ અને લેયર વિકલ્પોમાં XML ID તરીકે દેખાય છે.
|
||||
Restored documents open unsaved: save them to keep them. પુનઃસ્થાપિત દસ્તાવેજો અસાચવેલા ખુલશે: તેમને રાખવા માટે સાચવો.
|
||||
Restrict printing, editing and other tasks છાપકામ, સંપાદન અને અન્ય કાર્યો પર પ્રતિબંધ મૂકો
|
||||
Reticulation… રેટિક્યુલેશન…
|
||||
@@ -3473,6 +3479,7 @@
|
||||
Setup… સેટઅપ…
|
||||
Shading શેડિંગ
|
||||
Shading Color શેડિંગ રંગ
|
||||
Black Overprint કાળો ઓવરપ્રિન્ટ
|
||||
Shadows and Glows પડછાયા અને ગ્લો
|
||||
Shape શેપ
|
||||
Shape Builder શેપ બિલ્ડર
|
||||
@@ -4482,6 +4489,7 @@ antiAlias Sharp શાર્પ
|
||||
Save Prominent Colors મુખ્ય રંગો સાચવો
|
||||
Korean Line Break Anywhere કોરિયન લાઇન ગમે ત્યાં તોડો
|
||||
Bunri-Kinshi બુનરી-કિન્શી
|
||||
Kurikaeshi Moji Shori કુરિકાએશી મોજી શોરી
|
||||
East Asian Composition Settings પૂર્વ એશિયાઈ કમ્પોઝિશન સેટિંગ્સ
|
||||
Korean Composition Settings કોરિયન કમ્પોઝિશન સેટિંગ્સ
|
||||
Show Bounding Box While Moving and Drawing ખસેડતી અને દોરતી વખતે બાઉન્ડિંગ બોક્સ બતાવો
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -1855,6 +1855,7 @@ antiAlias Sharp शार्प
|
||||
Highlight Size हाइलाइट आकार
|
||||
Blend Steps ब्लेंड चरण
|
||||
Shading Color शेडिंग रंग
|
||||
Black Overprint काला ओवरप्रिंट
|
||||
Draw Hidden Faces छिपे हुए फलक बनाएँ
|
||||
Eyedropper आईड्रॉपर
|
||||
Eyedropper Applies: आईड्रॉपपर लागू होता है:
|
||||
@@ -4154,6 +4155,12 @@ antiAlias Sharp शार्प
|
||||
Responsive उत्तरदायी
|
||||
Restore पुनर्स्थापित करें
|
||||
Restore every preference to its default (applied on OK) प्रत्येक वरीयता को उसके डिफ़ॉल्ट में पुनर्स्थापित करें ( OK पर लागू)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. पिक्सेल को छोड़कर बिल्ट-इन साइज़ वाले नए डॉक्यूमेंट और कोई इकाई दर्ज न करने वाली खोली गई फ़ाइलों की इकाई; इसे यहाँ चुनकर ठीक है पर क्लिक करने से यह सक्रिय डॉक्यूमेंट की इकाई भी बन जाती है।
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. स्ट्रोक की मोटाई, डैश और गैप इस इकाई में दिखते हैं, और उनके लिए टाइप की गई संख्याएँ इसी इकाई में पढ़ी जाती हैं।
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. टाइप साइज़, लीडिंग और बेसलाइन शिफ़्ट इस इकाई में दिखते हैं, और उनके लिए टाइप की गई संख्याएँ इसी इकाई में पढ़ी जाती हैं।
|
||||
The unit for East Asian type measurements, which no field uses yet. पूर्वी एशियाई टाइप के माप की इकाई, जिसका अभी कोई फ़ील्ड उपयोग नहीं करता।
|
||||
When on, a number typed without a unit into a field in picas is read in points. चालू होने पर, पाइका वाले फ़ील्ड में बिना इकाई के टाइप की गई संख्या पॉइंट्स में पढ़ी जाती है।
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML ID चुनने पर ऑब्जेक्ट के नाम लेयर्स, वेरिएबल्स और लेयर ऑप्शन्स में XML ID के रूप में दिखते हैं।
|
||||
Reset all preferences to their defaults? सभी प्रेफ़रेंसेज़ को उनके डिफ़ॉल्ट पर रीसेट करें?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. डिफ़ॉल्ट तब लागू होते हैं जब आप प्रेफ़रेंसेज़ में ठीक है पर क्लिक करते हैं। वहाँ रद्द करें आपकी मौजूदा प्रेफ़रेंसेज़ बनाए रखता है।
|
||||
Restore Recovered Documents पुनर्स्थापना डॉक्यूमेंट
|
||||
@@ -4206,6 +4213,7 @@ antiAlias Sharp शार्प
|
||||
Roman Hanging Punctuation रोमन हैंगिंग विराम चिह्न
|
||||
Korean Line Break Anywhere कोरियाई लाइन ब्रेक कहीं भी
|
||||
Bunri-Kinshi बुनरी-किंशी
|
||||
Kurikaeshi Moji Shori कुरिकाएशी मोजी शोरी
|
||||
East Asian Composition Settings पूर्वी एशियाई संरचना सेटिंग्स
|
||||
Korean Composition Settings कोरियाई संरचना सेटिंग्स
|
||||
Rotate घुमाएँ
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1510,6 +1510,7 @@ font-technology Variable Változó
|
||||
Highlight Size Csillanás mérete
|
||||
Blend Steps Átmenetlépések
|
||||
Shading Color Árnyékolás színe
|
||||
Black Overprint Felülnyomó fekete
|
||||
Draw Hidden Faces Rejtett lapok rajzolása
|
||||
Eyedropper Pipetta
|
||||
Sample Color from Screen Szín mintavétele a képernyőről
|
||||
@@ -3621,6 +3622,12 @@ mark-style Japanese Japán
|
||||
Responsive Reszponzív
|
||||
Restore Visszaállít
|
||||
Restore every preference to its default (applied on OK) Minden beállítás visszaállítása az alapértékre (az OK gombbal lép életbe)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. A beépített, nem pixelben megadott méretű új dokumentumok és a mértékegységet nem rögzítő megnyitott fájlok mértékegysége; ha itt kiválasztja, és az OK gombra kattint, az aktív dokumentum mértékegysége is ez lesz.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. A körvonalvastagságok, a vonalak és a hézagok ebben a mértékegységben jelennek meg, és a hozzájuk beírt számokat is ebben értelmezi a program.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. A betűméretek, a sorköz és az alapvonal-eltolás ebben a mértékegységben jelennek meg, és a hozzájuk beírt számokat is ebben értelmezi a program.
|
||||
The unit for East Asian type measurements, which no field uses yet. A kelet-ázsiai szöveg méreteinek mértékegysége, amelyet egyelőre egyetlen mező sem használ.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Bekapcsolva egy pica mértékegységű mezőbe mértékegység nélkül beírt számot pontként értelmez a program.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML-azonosító esetén az objektumnevek XML-azonosítóként jelennek meg a Rétegek, a Változók és a Rétegbeállítások ablakban.
|
||||
Reset all preferences to their defaults? Visszaállítja az összes beállítást az alapértékre?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Az alapértékek akkor lépnek életbe, amikor a Beállításokban az OK gombra kattint. Az ottani Mégse megtartja a jelenlegi beállításokat.
|
||||
Restore Recovered Documents Helyreállított dokumentumok visszaállítása
|
||||
@@ -3665,6 +3672,7 @@ mark-style Japanese Japán
|
||||
Roman Hanging Punctuation Latin függő írásjelek
|
||||
Korean Line Break Anywhere Koreai sortörés bárhol
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Kelet-ázsiai szedési beállítások
|
||||
Korean Composition Settings Koreai szedési beállítások
|
||||
Rotate Elforgatás
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -487,6 +487,7 @@
|
||||
Highlight Size Ukuran kilau
|
||||
Blend Steps Langkah campuran
|
||||
Shading Color Warna pengarsiran
|
||||
Black Overprint Hitam overprint
|
||||
Draw Hidden Faces Gambar sisi tersembunyi
|
||||
Revolve… Revolusi…
|
||||
Inflate… Gelembungkan…
|
||||
@@ -1907,6 +1908,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Tanda baca gantung Romawi
|
||||
Korean Line Break Anywhere Putus baris Korea di mana saja
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Pengaturan komposisi Asia Timur
|
||||
Korean Composition Settings Pengaturan komposisi Korea
|
||||
Select a text object to edit its paragraph attributes. Pilih objek teks untuk mengedit atribut paragrafnya.
|
||||
@@ -4134,6 +4136,12 @@ font-technology Variable Variabel
|
||||
Preferences Preferensi
|
||||
Previous Sebelumnya
|
||||
Restore every preference to its default (applied on OK) Kembalikan semua preferensi ke defaultnya (diterapkan saat OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Satuan untuk dokumen baru dari ukuran bawaan selain ukuran piksel dan untuk file yang dibuka tanpa satuan tercatat; jika Anda memilihnya di sini lalu mengklik OK, satuan dokumen aktif juga menjadi satuan ini.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Ketebalan stroke, putus-putus, dan jarak ditampilkan dalam satuan ini, dan angka yang diketik untuknya dibaca dalam satuan ini.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Ukuran teks, leading, dan pergeseran garis dasar ditampilkan dalam satuan ini, dan angka yang diketik untuknya dibaca dalam satuan ini.
|
||||
The unit for East Asian type measurements, which no field uses yet. Satuan untuk ukuran teks Asia Timur, yang belum digunakan bidang mana pun.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Jika aktif, angka yang diketik tanpa satuan di bidang dalam pica dibaca dalam titik.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Dengan ID XML, nama objek ditampilkan sebagai ID XML di Lapisan, Variabel, dan Opsi lapisan.
|
||||
Reset all preferences to their defaults? Atur ulang semua preferensi ke defaultnya?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Nilai default diterapkan saat Anda mengklik OK di Preferensi. Batal di sana mempertahankan preferensi Anda saat ini.
|
||||
Smaller ↔ Larger Lebih kecil ↔ Lebih besar
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2484 and column 5.
|
@@ -1215,6 +1215,7 @@ font-technology Variable Variabili
|
||||
Highlight Size Dimensione lucentezza
|
||||
Blend Steps Passaggi di fusione
|
||||
Shading Color Colore ombreggiatura
|
||||
Black Overprint Nero in sovrastampa
|
||||
Draw Hidden Faces Disegna facce nascoste
|
||||
Eyedropper Contagocce
|
||||
Sample Color from Screen Campiona colore dallo schermo
|
||||
@@ -3082,6 +3083,12 @@ digits Malayalam Malayalam
|
||||
Responsive Adattivo
|
||||
Restore Ripristina
|
||||
Restore every preference to its default (applied on OK) Ripristina tutte le preferenze ai valori predefiniti (applicato con OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. L'unità dei nuovi documenti nelle dimensioni predefinite, tranne quelle in pixel, e dei file aperti che non registrano alcuna unità; sceglierla qui e fare clic su OK la imposta anche per il documento attivo.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Gli spessori della traccia, i trattini e gli spazi sono mostrati in questa unità, e i numeri digitati per essi sono letti in questa unità.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Dimensioni del testo, interlinea e spostamento della linea di base sono mostrati in questa unità, e i numeri digitati per essi sono letti in questa unità.
|
||||
The unit for East Asian type measurements, which no field uses yet. L'unità per le misure del testo dell'Asia orientale, che nessun campo usa ancora.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Se attiva, un numero digitato senza unità in un campo in pica viene letto in punti.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Con ID XML, i nomi degli oggetti sono mostrati come ID XML in Livelli, Variabili e Opzioni livello.
|
||||
Reset all preferences to their defaults? Ripristinare tutte le preferenze ai valori predefiniti?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. I valori predefiniti vengono applicati quando fai clic su OK in Preferenze. Annulla lì mantiene le preferenze attuali.
|
||||
Restore Recovered Documents Ripristina documenti recuperati
|
||||
@@ -3115,6 +3122,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Punteggiatura sporgente romana
|
||||
Korean Line Break Anywhere Interruzione di riga coreana ovunque
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Impostazioni di composizione dell’Asia orientale
|
||||
Korean Composition Settings Impostazioni di composizione coreana
|
||||
Rotate Ruota
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -579,6 +579,7 @@ digits Malayalam マラヤーラム数字
|
||||
Highlight Size ハイライトのサイズ
|
||||
Blend Steps ブレンドの階調
|
||||
Shading Color 陰影のカラー
|
||||
Black Overprint ブラックオーバープリント
|
||||
Draw Hidden Faces 隠れた面を描画
|
||||
Revolve… 回転体…
|
||||
Inflate… 膨張…
|
||||
@@ -3059,6 +3060,12 @@ mark-style Japanese 日本式
|
||||
Restore 復元
|
||||
Restore Recovered Documents 復帰したドキュメントを復元
|
||||
Restore every preference to its default (applied on OK) すべての環境設定を初期値に戻す (OK で適用)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. ピクセル以外の組み込みサイズの新規ドキュメントと、単位を記録していない開いたファイルに使う単位で、ここで選んで OK をクリックすると作業中のドキュメントの単位も変わります。
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. 線幅、線分、間隔はこの単位で表示され、入力した数値もこの単位で読み取られます。
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. フォントサイズ、行送り、ベースラインシフトはこの単位で表示され、入力した数値もこの単位で読み取られます。
|
||||
The unit for East Asian type measurements, which no field uses yet. 東アジア言語の文字の測定に使う単位で、まだどのフィールドも使っていません。
|
||||
When on, a number typed without a unit into a field in picas is read in points. オンのとき、パイカのフィールドに単位なしで入力した数値はポイントとして読み取られます。
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML ID を選ぶと、レイヤー、変数、レイヤーオプションでオブジェクト名が XML ID として表示されます。
|
||||
Reset all preferences to their defaults? すべての環境設定を初期値に戻しますか?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. 初期値は環境設定で OK をクリックすると適用されます。そこでキャンセルすると現在の環境設定が保たれます。
|
||||
Restored documents open unsaved: save them to keep them. 復元したドキュメントは未保存の状態で開きます。保存して残してください。
|
||||
@@ -3079,6 +3086,7 @@ mark-style Japanese 日本式
|
||||
Roman Hanging Punctuation 欧文ぶら下がり
|
||||
Korean Line Break Anywhere 韓国語の任意位置での改行
|
||||
Bunri-Kinshi 分離禁止
|
||||
Kurikaeshi Moji Shori 繰り返し文字処理
|
||||
East Asian Composition Settings 東アジア言語の組版設定
|
||||
Korean Composition Settings 韓国語の組版設定
|
||||
Rotate 回転
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2544,6 +2544,7 @@
|
||||
Highlight Size ელვარების ზომა
|
||||
Blend Steps შერევის საფეხურები
|
||||
Shading Color დაჩრდილვის ფერი
|
||||
Black Overprint ზედდაბეჭდილი შავი
|
||||
Draw Hidden Faces დამალული წახნაგების დახატვა
|
||||
Revolve… ბრუნვა…
|
||||
Inflate… გაბერვა…
|
||||
@@ -3963,6 +3964,7 @@ digits Malayalam მალაიალამური
|
||||
Roman Hanging Punctuation რომაული გამოწეული პუნქტუაცია
|
||||
Korean Line Break Anywhere კორეული სტრიქონის გადატანა ნებისმიერ ადგილას
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings აღმოსავლეთ აზიური აწყობის პარამეტრები
|
||||
Korean Composition Settings კორეული აწყობის პარამეტრები
|
||||
Select a text object to edit its paragraph attributes. აბზაცის ატრიბუტების რედაქტირებისთვის მონიშნეთ ტექსტური ობიექტი.
|
||||
@@ -6086,6 +6088,12 @@ font-technology Variable ცვლადი
|
||||
Preferences პარამეტრები
|
||||
Previous წინა
|
||||
Restore every preference to its default (applied on OK) ყველა პარამეტრის ნაგულისხმევ მნიშვნელობაზე დაბრუნება (გამოიყენება OK-ზე დაჭერისას)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. ახალი დოკუმენტების ერთეული ჩაშენებული ზომებით, პიქსელური ზომების გარდა, და გახსნილი ფაილებისა, რომლებიც ერთეულს არ ინახავს; თუ აქ აირჩევთ და OK-ს დააწკაპუნებთ, ის აქტიური დოკუმენტის ერთეულიც გახდება.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. კონტურის სისქე, ტირეები და შუალედები ამ ერთეულში ჩანს, და მათთვის აკრეფილი რიცხვები ამ ერთეულში იკითხება.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. ტექსტის ზომა, სტრიქონთა დაშორება და საბაზისო ხაზის წანაცვლება ამ ერთეულში ჩანს, და მათთვის აკრეფილი რიცხვები ამ ერთეულში იკითხება.
|
||||
The unit for East Asian type measurements, which no field uses yet. აღმოსავლეთაზიური ტექსტის ზომების ერთეული, რომელსაც ჯერჯერობით არცერთი ველი არ იყენებს.
|
||||
When on, a number typed without a unit into a field in picas is read in points. ჩართვისას პიკებში მოცემულ ველში ერთეულის გარეშე აკრეფილი რიცხვი პუნქტებში იკითხება.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML ID-ის არჩევისას ობიექტების სახელები შრეებში, ცვლადებსა და შრის პარამეტრებში XML ID-ად ჩანს.
|
||||
Reset all preferences to their defaults? დავაბრუნოთ ყველა პარამეტრი ნაგულისხმევ მნიშვნელობებზე?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. ნაგულისხმევი მნიშვნელობები გამოიყენება, როცა პარამეტრებში OK-ს დააჭერთ. იქ გაუქმება ინარჩუნებს თქვენს მიმდინარე პარამეტრებს.
|
||||
Smaller ↔ Larger უფრო პატარა ↔ უფრო დიდი
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -572,6 +572,7 @@ digits Malayalam 말라얄람어
|
||||
Highlight Size 하이라이트 크기
|
||||
Blend Steps 혼합 단계
|
||||
Shading Color 셰이딩 색상
|
||||
Black Overprint 검정 겹쳐찍기
|
||||
Draw Hidden Faces 숨겨진 면 그리기
|
||||
Revolve… 회전체…
|
||||
Inflate… 부풀리기…
|
||||
@@ -3048,6 +3049,12 @@ mark-style Japanese 일본식
|
||||
Restore 복원
|
||||
Restore Recovered Documents 복구된 문서 복원
|
||||
Restore every preference to its default (applied on OK) 모든 환경 설정을 기본값으로 복원(확인 시 적용)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. 픽셀 크기가 아닌 기본 제공 크기의 새 문서와 단위가 기록되지 않은 열린 파일에 쓰는 단위이며, 여기서 고르고 확인을 누르면 활성 문서의 단위도 바뀝니다.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. 선 두께, 대시, 간격이 이 단위로 표시되며, 입력한 숫자도 이 단위로 읽습니다.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. 글자 크기, 행간, 기준선 이동이 이 단위로 표시되며, 입력한 숫자도 이 단위로 읽습니다.
|
||||
The unit for East Asian type measurements, which no field uses yet. 동아시아 문자 측정에 쓰는 단위로, 아직 이 단위를 쓰는 필드는 없습니다.
|
||||
When on, a number typed without a unit into a field in picas is read in points. 켜면 파이카 필드에 단위 없이 입력한 숫자를 포인트로 읽습니다.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML ID를 고르면 레이어, 변수, 레이어 옵션에서 개체 이름이 XML ID로 표시됩니다.
|
||||
Reset all preferences to their defaults? 모든 환경 설정을 기본값으로 재설정하시겠습니까?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. 기본값은 환경 설정에서 확인을 클릭하면 적용됩니다. 그곳에서 취소를 누르면 현재 환경 설정이 유지됩니다.
|
||||
Restored documents open unsaved: save them to keep them. 복원된 문서는 저장되지 않은 상태로 열립니다. 보존하려면 저장하세요.
|
||||
@@ -3068,6 +3075,7 @@ mark-style Japanese 일본식
|
||||
Roman Hanging Punctuation 로마자 걸림 문장 부호
|
||||
Korean Line Break Anywhere 한글 어디서나 줄 바꿈
|
||||
Bunri-Kinshi 분리 금지
|
||||
Kurikaeshi Moji Shori 반복 문자 처리
|
||||
East Asian Composition Settings 동아시아 조판 설정
|
||||
Korean Composition Settings 한글 조판 설정
|
||||
Rotate 회전
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1028,6 +1028,7 @@ liquify-list-end {0}, {1} {0} en {1}
|
||||
Highlight Size Glansgrootte
|
||||
Blend Steps Overvloeistappen
|
||||
Shading Color Arceringskleur
|
||||
Black Overprint Zwart overprinten
|
||||
Draw Hidden Faces Verborgen vlakken tekenen
|
||||
Revolve… Draaien…
|
||||
Inflate… Opblazen…
|
||||
@@ -2490,6 +2491,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Romeinse hangende leestekens
|
||||
Korean Line Break Anywhere Koreaans regeleinde overal
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Instellingen voor Oost-Aziatische zetting
|
||||
Korean Composition Settings Instellingen voor Koreaanse zetting
|
||||
Select a text object to edit its paragraph attributes. Selecteer een tekstobject om de alineakenmerken ervan te bewerken.
|
||||
@@ -4724,6 +4726,12 @@ font-technology Variable Variabel
|
||||
Preferences Voorkeuren
|
||||
Previous Vorige
|
||||
Restore every preference to its default (applied on OK) Elke voorkeur terugzetten naar de standaard (toegepast bij OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. De eenheid voor nieuwe documenten in de ingebouwde formaten, behalve formaten in pixels, en voor geopende bestanden die geen eenheid vastleggen; kiest u die hier en klikt u op OK, dan krijgt ook het actieve document deze eenheid.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Contourdiktes, streepjes en tussenruimtes worden in deze eenheid getoond, en getallen die ervoor worden getypt, worden erin gelezen.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Tekstgroottes, regelafstand en basislijnverschuiving worden in deze eenheid getoond, en getallen die ervoor worden getypt, worden erin gelezen.
|
||||
The unit for East Asian type measurements, which no field uses yet. De eenheid voor maten van Oost-Aziatische tekst, die nog geen enkel veld gebruikt.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Wanneer dit aan staat, wordt een getal dat zonder eenheid in een veld in pica's wordt getypt, in punten gelezen.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Met XML-id worden objectnamen als XML-id's getoond in Lagen, Variabelen en Laagopties.
|
||||
Reset all preferences to their defaults? Alle voorkeuren terugzetten naar de standaardwaarden?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. De standaardwaarden worden toegepast wanneer u in Voorkeuren op OK klikt. Annuleren daar behoudt uw huidige voorkeuren.
|
||||
Smaller ↔ Larger Kleiner ↔ Groter
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -492,6 +492,7 @@
|
||||
Highlight Size Rozmiar połysku
|
||||
Blend Steps Kroki przejścia
|
||||
Shading Color Kolor cieniowania
|
||||
Black Overprint Czarny nadruk
|
||||
Draw Hidden Faces Rysuj ukryte ściany
|
||||
Revolve… Obrót…
|
||||
Inflate… Nadmuchanie…
|
||||
@@ -2073,6 +2074,7 @@ digits Malayalam Malajalam
|
||||
Roman Hanging Punctuation Wysunięta interpunkcja łacińska
|
||||
Korean Line Break Anywhere Koreański podział wiersza w dowolnym miejscu
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Ustawienia składu wschodnioazjatyckiego
|
||||
Korean Composition Settings Ustawienia składu koreańskiego
|
||||
Select a text object to edit its paragraph attributes. Zaznacz obiekt tekstowy, aby edytować atrybuty akapitu.
|
||||
@@ -4324,6 +4326,12 @@ font-technology Variable Zmienne
|
||||
Preferences Preferencje
|
||||
Previous Wstecz
|
||||
Restore every preference to its default (applied on OK) Przywróć domyślne wartości wszystkich preferencji (zastosowane po OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Jednostka nowych dokumentów o wbudowanych rozmiarach, z wyjątkiem rozmiarów w pikselach, oraz otwartych plików bez zapisanej jednostki; wybranie jej tutaj i kliknięcie OK ustawia ją też w aktywnym dokumencie.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Grubości obrysu, kreski i odstępy są wyświetlane w tej jednostce, a liczby wpisane dla nich są w niej odczytywane.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Rozmiary tekstu, interlinia i przesunięcie linii bazowej są wyświetlane w tej jednostce, a liczby wpisane dla nich są w niej odczytywane.
|
||||
The unit for East Asian type measurements, which no field uses yet. Jednostka miar tekstu wschodnioazjatyckiego, której żadne pole jeszcze nie używa.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Gdy opcja jest włączona, liczba wpisana bez jednostki w polu w pica jest odczytywana w punktach.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Przy ID XML nazwy obiektów są wyświetlane jako ID XML w Warstwach, Zmiennych i Opcjach warstwy.
|
||||
Reset all preferences to their defaults? Przywrócić domyślne wartości wszystkich preferencji?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Wartości domyślne zostaną zastosowane po kliknięciu OK w Preferencjach. Anuluj w tym oknie zachowuje bieżące preferencje.
|
||||
Smaller ↔ Larger Mniejszy ↔ większy
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1098,6 +1098,7 @@ antiAlias Sharp Nítido
|
||||
Highlight Size Tamanho do Realce
|
||||
Blend Steps Etapas de Mesclagem
|
||||
Shading Color Cor do Sombreamento
|
||||
Black Overprint Preto em Sobreimpressão
|
||||
Draw Hidden Faces Desenhar Faces Ocultas
|
||||
Eyedropper Conta-gotas
|
||||
Eyedropper Applies: O Conta-gotas Aplica:
|
||||
@@ -2533,6 +2534,12 @@ digits Malayalam Malaiala
|
||||
Restore Restaurar
|
||||
Restore Recovered Documents Restaurar Documentos Recuperados
|
||||
Restore every preference to its default (applied on OK) Restaurar toda preferência ao padrão (aplicado em OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. A unidade dos novos documentos de tamanhos predefinidos, exceto os tamanhos em pixels, e dos arquivos abertos que não registram nenhuma unidade; escolhê-la aqui e clicar em OK também a define no documento ativo.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. As espessuras de traçado, os traços e as lacunas aparecem nesta unidade, e os números digitados para eles são lidos nela.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Tamanhos de texto, entrelinhamento e deslocamento da linha de base aparecem nesta unidade, e os números digitados para eles são lidos nela.
|
||||
The unit for East Asian type measurements, which no field uses yet. A unidade das medidas de texto do Leste Asiático, que nenhum campo usa ainda.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Quando ativado, um número digitado sem unidade em um campo em picas é lido em pontos.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Com ID XML, os nomes dos objetos aparecem como IDs XML em Camadas, Variáveis e Opções de Camada.
|
||||
Reset all preferences to their defaults? Redefinir todas as preferências para o padrão?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Os padrões são aplicados quando você clica em OK em Preferências. Cancelar ali mantém suas preferências atuais.
|
||||
Restored documents open unsaved: save them to keep them. Os documentos restaurados abrem sem salvar: salve-os para mantê-los.
|
||||
@@ -2560,6 +2567,7 @@ digits Malayalam Malaiala
|
||||
Roman Hanging Punctuation Pontuação Pendurada Romana
|
||||
Korean Line Break Anywhere Quebra de Linha Coreana em Qualquer Lugar
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Configurações de Composição do Leste Asiático
|
||||
Korean Composition Settings Configurações de Composição Coreana
|
||||
Rotate Girar
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1206,6 +1206,7 @@ font-technology Variable Вариативные
|
||||
Highlight Size Размер блика
|
||||
Blend Steps Шаги перехода
|
||||
Shading Color Цвет затенения
|
||||
Black Overprint Чёрный с наложением
|
||||
Draw Hidden Faces Рисовать скрытые грани
|
||||
Eyedropper Пипетка
|
||||
Sample Color from Screen Взять цвет с экрана
|
||||
@@ -3071,6 +3072,12 @@ digits Malayalam Малаялам
|
||||
Responsive Адаптивный
|
||||
Restore Восстановить
|
||||
Restore every preference to its default (applied on OK) Восстановить все настройки по умолчанию (применяется при нажатии ОК)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Единица новых документов встроенных размеров, кроме размеров в пикселях, и открытых файлов без записанной единицы; если выбрать её здесь и нажать ОК, она станет и единицей активного документа.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Толщина обводки, штрихи и зазоры показываются в этой единице, и введённые для них числа читаются в ней.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Размеры текста, интерлиньяж и смещение базовой линии показываются в этой единице, и введённые для них числа читаются в ней.
|
||||
The unit for East Asian type measurements, which no field uses yet. Единица для размеров восточноазиатского текста, которую пока не использует ни одно поле.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Если включено, число, введённое без единицы в поле в пиках, читается в пунктах.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. При XML ID имена объектов показываются как XML ID в «Слоях», «Переменных» и «Параметрах слоя».
|
||||
Reset all preferences to their defaults? Сбросить все настройки до значений по умолчанию?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Значения по умолчанию применяются, когда вы нажимаете ОК в окне «Настройки». Отмена там сохраняет текущие настройки.
|
||||
Restore Recovered Documents Восстановить восстановленные документы
|
||||
@@ -3104,6 +3111,7 @@ digits Malayalam Малаялам
|
||||
Roman Hanging Punctuation Римская висячая пунктуация
|
||||
Korean Line Break Anywhere Перенос корейского текста в любом месте
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Параметры восточноазиатского набора
|
||||
Korean Composition Settings Параметры корейского набора
|
||||
Rotate Повернуть
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1185,6 +1185,7 @@ font-technology Variable Variabla
|
||||
Highlight Size Högdagerstorlek
|
||||
Blend Steps Övergångssteg
|
||||
Shading Color Skuggningsfärg
|
||||
Black Overprint Svart övertryck
|
||||
Draw Hidden Faces Rita dolda ytor
|
||||
Eyedropper Pipett
|
||||
Eyedropper Applies: Pipetten tillämpar:
|
||||
@@ -2975,6 +2976,12 @@ digits Malayalam Malayalam
|
||||
Responsive Responsiv
|
||||
Restore Återställ
|
||||
Restore every preference to its default (applied on OK) Återställ alla inställningar till standard (verkställs vid OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Enheten för nya dokument i de inbyggda storlekarna, utom storlekar i pixlar, och för öppnade filer som inte anger någon enhet; om du väljer den här och klickar på OK får även det aktiva dokumentet den enheten.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Konturtjocklekar, streck och mellanrum visas i den här enheten, och tal som skrivs för dem läses i den.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Teckenstorlekar, radavstånd och baslinjeförskjutning visas i den här enheten, och tal som skrivs för dem läses i den.
|
||||
The unit for East Asian type measurements, which no field uses yet. Enheten för mått i östasiatisk text, som inget fält använder ännu.
|
||||
When on, a number typed without a unit into a field in picas is read in points. När det är på läses ett tal som skrivs utan enhet i ett fält i pica i punkter.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Med XML-id visas objektnamn som XML-id:n i Lager, Variabler och Lageralternativ.
|
||||
Reset all preferences to their defaults? Återställa alla inställningar till standard?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Standardvärdena verkställs när du klickar på OK i Inställningar. Avbryt där behåller dina nuvarande inställningar.
|
||||
Restore Recovered Documents Återställ återskapade dokument
|
||||
@@ -3008,6 +3015,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Hängande interpunktion (roman)
|
||||
Korean Line Break Anywhere Koreansk radbrytning var som helst
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Inställningar för östasiatisk sättning
|
||||
Korean Composition Settings Inställningar för koreansk sättning
|
||||
Rotate Rotera
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4521,6 +4521,31 @@ fn russian_translates_command_script_and_file_messages() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Danish shows command, script and file messages in Danish: whole messages, messages with a name,
|
||||
/// a number, a size or a command id filled in, a message that keeps its double-quoted values, and
|
||||
/// the messages whose catalog rows escape a backslash or double a brace.
|
||||
#[test]
|
||||
fn danish_translates_command_script_and_file_messages() {
|
||||
let da = Lang::from_code("da").expect("registered");
|
||||
for (english, danish) in [
|
||||
("CSV is empty", "CSV-filen er tom"),
|
||||
("Offset Path: the path is too complex to offset", "Forskyd kurve: kurven er for kompleks til at forskyde"),
|
||||
("no swatch named `Gold`", "ingen farveprøve med navnet `Gold`"),
|
||||
("object 12 is not an Intertwine group", "objekt 12 er ikke en sammenfletningsgruppe"),
|
||||
("no slice 4 in the image (see slice.list)", "intet udsnit 4 i billedet (se slice.list)"),
|
||||
("give origin: [x, y], or reset: true", "angiv origin: [x, y] eller reset: true"),
|
||||
("`kinsoku` must be \"none\", \"hard\" or \"soft\"", "`kinsoku` skal være \"none\", \"hard\" eller \"soft\""),
|
||||
("PNG encoding failed: 0 × 0 pixels is not a valid image size", "PNG-kodning mislykkedes: 0 × 0 pixels er ikke en gyldig billedstørrelse"),
|
||||
("missing `index` (a stop index, or null to clear)", "`index` mangler (et indeks for et gradientstop eller null for at rydde)"),
|
||||
("JSON.parse: unexpected end (at offset 7)", "JSON.parse: unexpected end (ved forskydning 7)"),
|
||||
("\\ at end of pattern", "\\ i slutningen af mønsteret"),
|
||||
("a \\u escape needs four hexadecimal digits", "en \\u-escape kræver fire hexadecimale cifre"),
|
||||
("not an RTF file: it doesn't start with {\\rtf", "ikke en RTF-fil: den starter ikke med {\\rtf"),
|
||||
] {
|
||||
assert_eq!(message(da, english), danish, "{english}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The errors of the parameter checks that many commands share (a number given as text, a missing
|
||||
/// number or index, a fraction for a whole number, `ids` that aren't a list of object ids, an
|
||||
/// `ids` entry or an `id` that is negative, an object id that names no object, a date that isn't
|
||||
|
||||
@@ -1179,6 +1179,7 @@ font-technology Variable Değişken
|
||||
Highlight Size Parlama Boyutu
|
||||
Blend Steps Karışım Adımları
|
||||
Shading Color Gölgeleme Rengi
|
||||
Black Overprint Siyah Üst Baskı
|
||||
Draw Hidden Faces Gizli Yüzleri Çiz
|
||||
Eyedropper Damlalık
|
||||
Sample Color from Screen Ekrandan Örnek Renk
|
||||
@@ -2812,6 +2813,12 @@ digits Malayalam Malayalam
|
||||
Responsive duyarlı
|
||||
Restore Geri yükle
|
||||
Restore every preference to its default (applied on OK) Her tercihi varsayılana geri yükleyin (Tamam'a uygulanır)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Piksel boyutları dışındaki yerleşik boyutlardaki yeni belgelerin ve birim kaydetmeyen açılan dosyaların birimi; burada seçip Tamam'a tıkladığınızda etkin belgenin birimi de bu olur.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Kontur kalınlıkları, kısa çizgiler ve boşluklar bu birimde gösterilir ve bunlar için yazılan sayılar bu birimde okunur.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Yazı boyutları, satır aralığı ve taban çizgisi kayması bu birimde gösterilir ve bunlar için yazılan sayılar bu birimde okunur.
|
||||
The unit for East Asian type measurements, which no field uses yet. Doğu Asya metni ölçüleri için henüz hiçbir alanın kullanmadığı birim.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Açıkken, pika cinsinden bir alana birimsiz yazılan sayı punto olarak okunur.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. XML kimliği seçiliyken nesne adları Katmanlar, Değişkenler ve Katman Seçenekleri'nde XML kimliği olarak gösterilir.
|
||||
Reset all preferences to their defaults? Tüm tercihler varsayılanlarına sıfırlansın mı?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Varsayılanlar, Tercihler'de Tamam'a tıkladığınızda uygulanır. Oradaki İptal, mevcut tercihlerinizi korur.
|
||||
Restore Recovered Documents Kurtarılan Belgeleri Geri Yükle
|
||||
@@ -2843,6 +2850,7 @@ digits Malayalam Malayalam
|
||||
Roman Hanging Punctuation Roma Asılı Noktalama İşaretleri
|
||||
Korean Line Break Anywhere Korece Satırı Her Yerde Kes
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Doğu Asya Dizgi Ayarları
|
||||
Korean Composition Settings Korece Dizgi Ayarları
|
||||
Rotate Döndür
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1209,6 +1209,7 @@ font-technology Variable Варіативні
|
||||
Highlight Size Розмір відблиску
|
||||
Blend Steps Кроки переходу
|
||||
Shading Color Колір затінення
|
||||
Black Overprint Чорний із накладенням
|
||||
Draw Hidden Faces Малювати приховані грані
|
||||
Eyedropper Піпетка
|
||||
Sample Color from Screen Взяти колір з екрана
|
||||
@@ -3074,6 +3075,12 @@ digits Malayalam Малаялам
|
||||
Responsive Адаптивний
|
||||
Restore Відновити
|
||||
Restore every preference to its default (applied on OK) Відновити всі параметри за промовчанням (застосовується при натисканні ОК)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Одиниця нових документів вбудованих розмірів, крім розмірів у пікселях, і відкритих файлів без записаної одиниці; якщо вибрати її тут і натиснути ОК, вона стане й одиницею активного документа.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Товщина обведення, штрихи й зазори показуються в цій одиниці, і введені для них числа читаються в ній.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Розміри тексту, інтерліньяж і зміщення базової лінії показуються в цій одиниці, і введені для них числа читаються в ній.
|
||||
The unit for East Asian type measurements, which no field uses yet. Одиниця для розмірів східноазіатського тексту, якої поки не використовує жодне поле.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Якщо ввімкнено, число, введене без одиниці в поле в піках, читається в пунктах.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. З XML ID назви об’єктів показуються як XML ID у «Шарах», «Змінних» і «Параметрах шару».
|
||||
Reset all preferences to their defaults? Скинути всі налаштування до значень за промовчанням?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Значення за промовчанням застосовуються, коли ви натискаєте ОК у вікні «Налаштування». Скасувати там зберігає поточні налаштування.
|
||||
Restore Recovered Documents Відновити відновлені документи
|
||||
@@ -3107,6 +3114,7 @@ digits Malayalam Малаялам
|
||||
Roman Hanging Punctuation Римська висяча пунктуація
|
||||
Korean Line Break Anywhere Перенесення корейського тексту будь-де
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Параметри східноазійського набору
|
||||
Korean Composition Settings Параметри корейського набору
|
||||
Rotate Повернути
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1395,6 +1395,7 @@ font-technology Variable Biến thiên
|
||||
Highlight Size Kích thước điểm sáng
|
||||
Blend Steps Số bước hòa trộn
|
||||
Shading Color Màu tô bóng
|
||||
Black Overprint Đen in chồng
|
||||
Draw Hidden Faces Vẽ các mặt ẩn
|
||||
Eyedropper Ống hút màu
|
||||
Sample Color from Screen Lấy mẫu màu từ màn hình
|
||||
@@ -3388,6 +3389,12 @@ mark-style Japanese Kiểu Nhật
|
||||
Responsive Đáp ứng
|
||||
Restore Khôi phục
|
||||
Restore every preference to its default (applied on OK) Khôi phục tất cả tùy chọn về mặc định (áp dụng khi nhấn OK)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. Đơn vị cho tài liệu mới theo kích thước dựng sẵn, trừ kích thước bằng pixel, và cho tệp đã mở không ghi đơn vị; chọn đơn vị ở đây rồi bấm OK cũng đặt nó cho tài liệu đang hoạt động.
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. Độ dày nét, nét đứt và khoảng cách hiển thị theo đơn vị này, và số nhập cho chúng được đọc theo đơn vị này.
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. Cỡ chữ, giãn dòng và dịch chuyển đường cơ sở hiển thị theo đơn vị này, và số nhập cho chúng được đọc theo đơn vị này.
|
||||
The unit for East Asian type measurements, which no field uses yet. Đơn vị cho số đo chữ Đông Á, hiện chưa có trường nào dùng.
|
||||
When on, a number typed without a unit into a field in picas is read in points. Khi bật, số nhập không có đơn vị vào trường tính bằng pica được đọc theo điểm.
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. Với XML ID, tên đối tượng hiển thị dưới dạng XML ID trong Các lớp, Biến số và Tùy chọn lớp.
|
||||
Reset all preferences to their defaults? Đặt lại tất cả tùy chọn về mặc định?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. Giá trị mặc định được áp dụng khi bạn nhấn OK trong Tùy chọn. Hủy ở đó giữ nguyên các tùy chọn hiện tại của bạn.
|
||||
Restore Recovered Documents Khôi phục tài liệu đã phục hồi
|
||||
@@ -3427,6 +3434,7 @@ mark-style Japanese Kiểu Nhật
|
||||
Roman Hanging Punctuation Dấu câu treo Roman
|
||||
Korean Line Break Anywhere Ngắt dòng tiếng Hàn ở bất kỳ đâu
|
||||
Bunri-Kinshi Bunri-Kinshi
|
||||
Kurikaeshi Moji Shori Kurikaeshi Moji Shori
|
||||
East Asian Composition Settings Cài đặt dàn trang Đông Á
|
||||
Korean Composition Settings Cài đặt dàn trang tiếng Hàn
|
||||
Rotate Xoay
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 205 and column 5.
|
@@ -1146,6 +1146,7 @@ antiAlias Sharp 锐利
|
||||
Highlight Size 高光大小
|
||||
Blend Steps 混合步骤
|
||||
Shading Color 底纹颜色
|
||||
Black Overprint 黑色叠印
|
||||
Draw Hidden Faces 绘制隐藏表面
|
||||
Eyedropper 吸管
|
||||
Sample Color from Screen 从屏幕取样颜色
|
||||
@@ -2933,6 +2934,12 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Responsive 响应式
|
||||
Restore 恢复
|
||||
Restore every preference to its default (applied on OK) 把所有首选项恢复为默认值 (点击确定后应用)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. 除像素尺寸外,以内置尺寸新建的文档和未记录单位的已打开文件使用此单位;在此选择并点击确定,也会更改当前文档的单位。
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. 描边粗细、虚线和间隔以此单位显示,为其输入的数字也按此单位读取。
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. 字号、行距和基线偏移以此单位显示,为其输入的数字也按此单位读取。
|
||||
The unit for East Asian type measurements, which no field uses yet. 用于东亚文字度量的单位,目前还没有字段使用。
|
||||
When on, a number typed without a unit into a field in picas is read in points. 开启后,在以派卡为单位的字段中输入的不带单位的数字按点读取。
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. 选择 XML ID 时,图层、变量和图层选项中的对象名称显示为 XML ID。
|
||||
Reset all preferences to their defaults? 将所有首选项重置为默认值?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. 在首选项中点击确定后才会应用默认值。在那里点击取消会保留当前首选项。
|
||||
Restore Recovered Documents 恢复已恢复的文档
|
||||
@@ -2965,6 +2972,7 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Roman Hanging Punctuation 西文悬挂标点
|
||||
Korean Line Break Anywhere 韩文任意位置换行
|
||||
Bunri-Kinshi 分离禁止
|
||||
Kurikaeshi Moji Shori 重复字符处理
|
||||
East Asian Composition Settings 东亚排版设置
|
||||
Korean Composition Settings 韩文排版设置
|
||||
Rotate 旋转
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1179,6 +1179,7 @@ font-technology Variable 可變
|
||||
Highlight Size 亮部大小
|
||||
Blend Steps 漸變階數
|
||||
Shading Color 網底顏色
|
||||
Black Overprint 黑色疊印
|
||||
Draw Hidden Faces 繪製隱藏表面
|
||||
Eyedropper 滴管
|
||||
Sample Color from Screen 從螢幕取樣顏色
|
||||
@@ -4183,6 +4184,12 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Responsive 回應式
|
||||
Restore 還原
|
||||
Restore every preference to its default (applied on OK) 將所有偏好設定還原為預設值 (按下確定後套用)
|
||||
The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units. 除像素尺寸外,以內建尺寸新增的文件及未記錄單位的已開啟檔案使用此單位;在此選擇並按下確定,也會變更目前文件的單位。
|
||||
Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it. 筆畫寬度、虛線和間隙以此單位顯示,為其輸入的數字也以此單位讀取。
|
||||
Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it. 字體大小、行距和基線位移以此單位顯示,為其輸入的數字也以此單位讀取。
|
||||
The unit for East Asian type measurements, which no field uses yet. 用於東亞文字度量的單位,目前還沒有欄位使用。
|
||||
When on, a number typed without a unit into a field in picas is read in points. 開啟後,在以派卡為單位的欄位中輸入的不含單位數字以點讀取。
|
||||
With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options. 選擇 XML ID 時,圖層、變數和圖層選項中的物件名稱會顯示為 XML ID。
|
||||
Reset all preferences to their defaults? 要將所有偏好設定重設為預設值嗎?
|
||||
The defaults are applied when you click OK in Preferences. Cancel there keeps your current preferences. 在偏好設定中按下確定後才會套用預設值。在那裡按下取消會保留目前的偏好設定。
|
||||
Restore Recovered Documents 還原找回的文件
|
||||
@@ -4216,6 +4223,7 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Roman Hanging Punctuation 羅馬懸掛標點
|
||||
Korean Line Break Anywhere 韓文任意位置換行
|
||||
Bunri-Kinshi 分離禁止
|
||||
Kurikaeshi Moji Shori 重複字元處理
|
||||
East Asian Composition Settings 東亞排版設定
|
||||
Korean Composition Settings 韓文排版設定
|
||||
Rotate 旋轉
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -859,6 +859,11 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
});
|
||||
});
|
||||
// A repeat mark starting a line is drawn as the character it repeats.
|
||||
let repeat = shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true);
|
||||
if menu_item(ui, tl!("Kurikaeshi Moji Shori"), has, repeat) {
|
||||
toggle_kurikaeshi_moji_shori(app);
|
||||
}
|
||||
// How a line keeps the kinsoku characters off its ends: the selected paragraphs' type is
|
||||
// checked, and none is when they differ.
|
||||
let kinsoku_type = shared_para(app, |p| p.kinsoku_type);
|
||||
@@ -937,6 +942,14 @@ fn toggle_bunri_kinshi(app: &mut VectorcraftApp) {
|
||||
format(app, json!({"bunriKinshi": !on}));
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori (Paragraph panel menu): the menu item is checked when every paragraph the
|
||||
/// panel acts on ([`format`]) has it, and a click turns it off for all of them then, and on for all
|
||||
/// of them otherwise, in one undo step.
|
||||
fn toggle_kurikaeshi_moji_shori(app: &mut VectorcraftApp) {
|
||||
let on = shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true);
|
||||
format(app, json!({"kurikaeshiMojiShori": !on}));
|
||||
}
|
||||
|
||||
/// Korean Line Break Anywhere (Paragraph panel menu): the menu item is checked when every paragraph
|
||||
/// the panel acts on ([`format`]) has it, and a click turns it off for all of them then, and on for
|
||||
/// all of them otherwise, in one undo step.
|
||||
@@ -949,7 +962,7 @@ fn toggle_korean_line_break_anywhere(app: &mut VectorcraftApp) {
|
||||
/// indents or paragraph spacing, Hyphenate off with the default Hyphenation and Justification
|
||||
/// options, Auto direction, Bottom-to-Bottom Leading, the Line-end Punctuation Half Width Mojikumi
|
||||
/// Set, Regular burasagari, the Hard kinsoku set, Push Out Only, the Every-line Composer, Bunri-Kinshi,
|
||||
/// Roman Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo
|
||||
/// Kurikaeshi Moji Shori, Roman Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo
|
||||
/// step named Reset Panel (inside an undo group that is already open, as part of its step).
|
||||
fn reset_panel(app: &mut VectorcraftApp) {
|
||||
let h = HyphenationOptions::default();
|
||||
@@ -971,7 +984,7 @@ fn reset_panel(app: &mut VectorcraftApp) {
|
||||
"autoLeading": j.auto_leading, "singleWordJustification": "fullJustify",
|
||||
"direction": "auto", "leadingModel": "romanBaseline", "mojikumi": "lineEndHalf", "burasagari": "standard", "kinsoku": "hard",
|
||||
"kinsokuType": "pushOutOnly", "composer": "everyLine", "romanHangingPunctuation": false, "koreanLineBreakAnywhere": false,
|
||||
"bunriKinshi": false
|
||||
"bunriKinshi": false, "kurikaeshiMojiShori": false
|
||||
}),
|
||||
);
|
||||
para_cmd(app, "text.tabs.clear", json!({}));
|
||||
|
||||
@@ -324,6 +324,37 @@ fn bunri_kinshi_toggle_follows_kinsoku_and_the_selected_paragraphs() {
|
||||
assert_eq!(flags(&app), (false, false), "Reset Panel turns it off");
|
||||
}
|
||||
|
||||
/// Kurikaeshi Moji Shori: new type has it off; the menu item turns it on for the paragraphs the Type
|
||||
/// tool's selection touches in one undo step, a click while the selected paragraphs differ turns it
|
||||
/// on for all of them, and a click while all have it turns it off. Reset Panel turns it off.
|
||||
#[test]
|
||||
fn kurikaeshi_moji_shori_toggle_follows_the_selected_paragraphs() {
|
||||
let (mut app, id) = editing_text("時々\nすゝ\n");
|
||||
app.session.prefs.show_east_asian_options = true;
|
||||
let flags = |app: &VectorcraftApp| {
|
||||
let node = app.session.active().unwrap().doc.node(NodeId(id.as_u64().unwrap())).unwrap();
|
||||
let NodeKind::Text(text) = &node.kind else { panic!("text") };
|
||||
(text.para_at(0).kurikaeshi_moji_shori, text.para_at(1).kurikaeshi_moji_shori)
|
||||
};
|
||||
assert_eq!(flags(&app), (false, false), "new type has it off");
|
||||
select_range(&mut app, 0, 3);
|
||||
let history = app.session.active().unwrap().history.undo.len();
|
||||
toggle_kurikaeshi_moji_shori(&mut app);
|
||||
assert_eq!(flags(&app), (true, false));
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), history + 1);
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
toggle_kurikaeshi_moji_shori(&mut app);
|
||||
assert_eq!(flags(&app), (true, true), "mixed: a click turns it on for all");
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
toggle_kurikaeshi_moji_shori(&mut app);
|
||||
assert_eq!(flags(&app), (false, false), "all on: a click turns it off");
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
toggle_kurikaeshi_moji_shori(&mut app);
|
||||
app.session.set_tool_option("selectAll", &json!(true));
|
||||
reset_panel(&mut app);
|
||||
assert_eq!(flags(&app), (false, false), "Reset Panel turns it off");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paragraph_mixed_indent_fields_show_blank() {
|
||||
let (mut app, id) = editing_text("A\nB\n");
|
||||
|
||||
@@ -1165,8 +1165,9 @@ fn export_3d_object_adds_the_selected_3d_objects_to_asset_export() {
|
||||
let mut app = app();
|
||||
assert!(painted_text(&mut app, show).contains("Export 3D Object"));
|
||||
let ctx = egui::Context::default();
|
||||
// Without a 3D object: an error, nothing recorded, no asset.
|
||||
// Without a 3D object: the button is dimmed, and an error, nothing recorded, no asset.
|
||||
let history = undo_len(&app);
|
||||
assert!(!super::can_export_3d(&app));
|
||||
assert!(super::export_3d_object(&mut app, &ctx).is_err());
|
||||
assert_eq!((undo_len(&app), assets(&mut app).len()), (history, 0));
|
||||
let a = app.session.active().unwrap().selection.objects[0].0;
|
||||
@@ -1178,9 +1179,10 @@ fn export_3d_object_adds_the_selected_3d_objects_to_asset_export() {
|
||||
let hidden = app.run("shape.rectangle", json!({"x": 100, "y": 250, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap();
|
||||
app.run("effect.apply", json!({"effect": "threeD.extrude", "item": null})).unwrap();
|
||||
app.run("effect.setParams", json!({"index": 0, "item": null, "visible": false})).unwrap();
|
||||
assert!(!super::can_export_3d(&app));
|
||||
assert!(super::export_3d_object(&mut app, &ctx).is_err());
|
||||
app.run("select.set", json!({"ids": [plain, a, hidden]})).unwrap();
|
||||
assert_eq!(super::selected_3d_objects(&app), [a]);
|
||||
assert!(super::can_export_3d(&app));
|
||||
assert!(!crate::panel_docking::visible(&app.ui, crate::panels::asset_export::ID));
|
||||
let history = undo_len(&app);
|
||||
super::export_3d_object(&mut app, &ctx).unwrap();
|
||||
@@ -1217,7 +1219,44 @@ fn export_3d_object_leaves_out_a_3d_object_inside_another() {
|
||||
app.run("select.set", json!({"ids": [inner, group]})).unwrap();
|
||||
let selected: Vec<u64> = app.session.active().unwrap().selection.objects.iter().map(|id| id.0).collect();
|
||||
assert!(selected.contains(&inner) && selected.contains(&group), "{selected:?}");
|
||||
assert_eq!(super::selected_3d_objects(&app), [group]);
|
||||
super::export_3d_object(&mut app, &egui::Context::default()).unwrap();
|
||||
let list = assets(&mut app);
|
||||
assert_eq!(list.iter().map(|a| a["nodes"].clone()).collect::<Vec<_>>(), [json!([group])]);
|
||||
}
|
||||
|
||||
/// A 3D effect on a group's fill draws nothing to export: the button is dimmed for that group
|
||||
/// alone, and beside a 3D object the group is left out instead of refusing them both.
|
||||
#[test]
|
||||
fn export_3d_object_leaves_out_a_group_with_a_3d_fill() {
|
||||
let mut app = app();
|
||||
let a = app.session.active().unwrap().selection.objects[0].0;
|
||||
let other = app.run("shape.rectangle", json!({"x": 250, "y": 100, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap();
|
||||
app.run("select.set", json!({"ids": [other]})).unwrap();
|
||||
let group = app.run("object.group", json!({})).unwrap()["id"].as_u64().unwrap();
|
||||
app.run("select.set", json!({"ids": [group]})).unwrap();
|
||||
app.run("appearance.addFill", json!({})).unwrap();
|
||||
app.run("effect.apply", json!({"effect": "threeD.extrude"})).unwrap();
|
||||
// `effect.apply` puts a group's 3D effect on the group itself; a file can hold one on its fill.
|
||||
app.session
|
||||
.edit("fill", |d, _| {
|
||||
let n = d.node_mut(vectorcraft_doc::NodeId(group)).unwrap();
|
||||
let fx = n.appearance.effects.remove(0);
|
||||
n.appearance.items[0].effects_mut().push(fx);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
assert!(
|
||||
vectorcraft_effects::has_solid(app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(group)).unwrap()),
|
||||
"the fill holds the effect"
|
||||
);
|
||||
assert!(!super::can_export_3d(&app));
|
||||
app.run("select.set", json!({"ids": [a]})).unwrap();
|
||||
set_type(&mut app, "extrude").unwrap();
|
||||
app.run("select.set", json!({"ids": [a, group]})).unwrap();
|
||||
assert!(super::can_export_3d(&app));
|
||||
super::export_3d_object(&mut app, &egui::Context::default()).unwrap();
|
||||
let list = assets(&mut app);
|
||||
assert_eq!(list.iter().map(|a| a["nodes"].clone()).collect::<Vec<_>>(), [json!([a])]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
use egui::Ui;
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_doc::{Effect, Node, NodeId};
|
||||
use vectorcraft_doc::{Effect, Node, NodeId, NodeKind};
|
||||
use vectorcraft_effects::{CLASSIC_EXTRUDE, CLASSIC_REVOLVE, EXTRUDE, INFLATE, THREE_D_TYPES, is_three_d};
|
||||
|
||||
use super::{live_run, pstate, set_pstate};
|
||||
@@ -51,13 +51,6 @@ fn find(n: &Node) -> Option<Target> {
|
||||
in_list(&n.appearance.effects, None).or_else(|| n.appearance.items.iter().enumerate().find_map(|(k, item)| in_list(item.effects(), Some(k))))
|
||||
}
|
||||
|
||||
/// Does object `n` have a visible 3D effect (where [`find`] looks, in a visible fill or stroke),
|
||||
/// the kind Export 3D Object exports, without copying its settings?
|
||||
fn has_three_d(n: &Node) -> bool {
|
||||
let in_list = |fx: &[Effect]| fx.iter().any(|e| e.visible && is_three_d(&e.id));
|
||||
in_list(&n.appearance.effects) || n.appearance.items.iter().any(|item| item.visible() && in_list(item.effects()))
|
||||
}
|
||||
|
||||
/// The panel's object type of effect `id` (`plane`, `extrude`, `revolve` or `inflate`).
|
||||
pub(crate) fn type_of(id: &str) -> Option<&'static str> {
|
||||
THREE_D_TYPES.iter().find(|(_, effect)| *effect == id).map(|(kind, _)| *kind)
|
||||
@@ -284,10 +277,10 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
export_button(app, ui, &ctx);
|
||||
}
|
||||
|
||||
/// The Export 3D Object button, available while a selected object has a 3D effect. An error goes
|
||||
/// to the status bar.
|
||||
/// The Export 3D Object button, available while a selected object has a 3D effect that
|
||||
/// `assets.add3D` exports ([`can_export_3d`]). An error goes to the status bar.
|
||||
fn export_button(app: &mut VectorcraftApp, ui: &mut Ui, ctx: &egui::Context) {
|
||||
let any = app.session.active().is_some_and(|st| st.selection.objects.iter().any(|id| st.doc.node(*id).is_some_and(has_three_d)));
|
||||
let any = can_export_3d(app);
|
||||
ui.add_space(10.0);
|
||||
if ui.add_enabled(any, egui::Button::new(tl!("Export 3D Object"))).clicked() {
|
||||
finish(app, ctx);
|
||||
@@ -297,30 +290,22 @@ fn export_button(app: &mut VectorcraftApp, ui: &mut Ui, ctx: &egui::Context) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The selected objects that have a 3D effect, in tree order, leaving out each one inside another
|
||||
/// listed one (that one's asset holds it).
|
||||
pub(crate) fn selected_3d_objects(app: &VectorcraftApp) -> Vec<u64> {
|
||||
let Some(st) = app.session.active() else { return vec![] };
|
||||
let found = st.selection.objects.iter().copied().filter(|id| st.doc.node(*id).is_some_and(has_three_d));
|
||||
let mut paths: Vec<(Vec<usize>, NodeId)> = st.doc.index_paths(found).into_iter().map(|(id, path)| (path, id)).collect();
|
||||
paths.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
let mut kept: Vec<(Vec<usize>, NodeId)> = Vec::with_capacity(paths.len());
|
||||
for (path, id) in paths {
|
||||
if !kept.last().is_some_and(|(outer, _)| path.starts_with(outer)) {
|
||||
kept.push((path, id));
|
||||
}
|
||||
}
|
||||
kept.into_iter().map(|(_, id)| id.0).collect()
|
||||
/// Does a selected object have a 3D effect that `assets.add3D` exports
|
||||
/// ([`vectorcraft_effects::exports_three_d`])? A path of a compound path counts as the compound
|
||||
/// path, which holds the effects.
|
||||
pub(crate) fn can_export_3d(app: &VectorcraftApp) -> bool {
|
||||
let Some(st) = app.session.active() else { return false };
|
||||
let compound = |id: NodeId| st.doc.parent_of(id).filter(|p| st.doc.node(*p).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. })));
|
||||
st.selection.objects.iter().any(|id| st.doc.node(compound(*id).unwrap_or(*id)).is_some_and(vectorcraft_effects::exports_three_d))
|
||||
}
|
||||
|
||||
/// Export 3D Object: adds the selected objects that have a 3D effect to Asset Export as 3D assets
|
||||
/// (`assets.add3D`, one undo step, none when each is an asset already), selects their assets there
|
||||
/// and shows the Asset Export panel. Objects without a 3D effect in the selection are left out.
|
||||
/// (`assets.add3D` on the selection, one undo step, none when each is an asset already), selects
|
||||
/// their assets there and shows the Asset Export panel. The command leaves out the selected
|
||||
/// objects without a 3D effect and those inside another selected 3D object.
|
||||
pub(crate) fn export_3d_object(app: &mut VectorcraftApp, ctx: &egui::Context) -> Result<(), String> {
|
||||
use super::asset_export;
|
||||
let ids = selected_3d_objects(app);
|
||||
// Without one, `assets.add3D` on the selection says why nothing was added.
|
||||
asset_export::add_3d(app, ctx, (!ids.is_empty()).then_some(ids.as_slice()))?;
|
||||
asset_export::add_3d(app, ctx, None)?;
|
||||
if !crate::panel_docking::visible(&app.ui, asset_export::ID) {
|
||||
app.run("window.panel", json!({"panel": asset_export::ID}))?;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ use crate::state::Dialog;
|
||||
use crate::theme::{self, Accent, Brightness, Scheme, Tokens};
|
||||
use crate::{VectorcraftApp, widgets};
|
||||
|
||||
mod descriptions;
|
||||
|
||||
/// UI-only fields shown in the dialog (backed by `UiState`, not engine prefs).
|
||||
pub const UI_FIELDS: &[(&str, &str, &str)] = &[
|
||||
("__smartGuides", "Smart Guides", "Smart Guides (View → Smart Guides)"),
|
||||
@@ -398,9 +400,12 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
ui.set_width(530.0);
|
||||
ui.label(egui::RichText::new(tl!(cat)).font(theme::semibold(14.0)).color(t.text_strong));
|
||||
ui.add_space(8.0);
|
||||
egui::ScrollArea::vertical().id_salt(("prefs", cat)).max_height(400.0).auto_shrink([false, false]).show(ui, |ui| {
|
||||
category_fields(ui, app, &mut d, cat);
|
||||
});
|
||||
// The description line takes its height from the list, so the column stays FIELDS_HEIGHT tall.
|
||||
let list_height = FIELDS_HEIGHT - ui.spacing().item_spacing.y - DESCRIPTION_GAP - DESCRIPTION_HEIGHT;
|
||||
let scroll = egui::ScrollArea::vertical().id_salt(("prefs", cat)).max_height(list_height).auto_shrink([false, false]);
|
||||
let out = scroll.show(ui, |ui| category_fields(ui, app, &mut d, cat));
|
||||
ui.add_space(DESCRIPTION_GAP);
|
||||
description_line(ui, cat, out.inner_rect, &out.inner);
|
||||
});
|
||||
});
|
||||
ui.add_space(14.0);
|
||||
@@ -477,22 +482,97 @@ pub(crate) fn reset_fields(d: &mut Dialog) {
|
||||
d.fields.insert(RESET_UNITS.into(), d.fields.get("unitsGeneral").cloned().unwrap_or(Value::Null));
|
||||
}
|
||||
|
||||
fn category_fields(ui: &mut egui::Ui, app: &mut VectorcraftApp, d: &mut Dialog, cat: &str) {
|
||||
/// The height of the fields column under the category's name: the field list, the gap and the
|
||||
/// description line.
|
||||
const FIELDS_HEIGHT: f32 = 400.0;
|
||||
|
||||
/// The gap above the description line.
|
||||
const DESCRIPTION_GAP: f32 = 6.0;
|
||||
|
||||
/// The description line's height: three lines of its text.
|
||||
const DESCRIPTION_HEIGHT: f32 = 48.0;
|
||||
|
||||
/// The line under the field list `list` of the category `cat`: in dim text, the sentence that
|
||||
/// describes the setting under the pointer, else the setting with the keyboard focus, or nothing.
|
||||
/// It keeps its height either way. While the pointer stays over the list or the line, between rows
|
||||
/// too, the line keeps the setting it last described under the pointer.
|
||||
fn description_line(ui: &mut egui::Ui, cat: &str, list: egui::Rect, rows: &DescribedRows) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (line, _) = ui.allocate_exact_size(egui::vec2(ui.available_width(), DESCRIPTION_HEIGHT), egui::Sense::hover());
|
||||
let column = list.union(line);
|
||||
// (pass, category, setting last described under the pointer); only the previous pass's counts,
|
||||
// so a dialog closed and opened again starts empty.
|
||||
let id = egui::Id::unique("prefs-description-hovered");
|
||||
let pass = ui.ctx().cumulative_pass_nr();
|
||||
let last = ui
|
||||
.data(|m| m.get_temp::<(u64, String, Option<&'static str>)>(id))
|
||||
.filter(|(p, c, _)| pass.saturating_sub(*p) <= 1 && c == cat)
|
||||
.and_then(|(_, _, k)| k);
|
||||
let hovered = rows.hovered.or_else(|| last.filter(|_| ui.rect_contains_pointer(column)));
|
||||
ui.data_mut(|m| m.insert_temp(id, (pass, cat.to_string(), hovered)));
|
||||
// The tests measure the column and the line.
|
||||
#[cfg(test)]
|
||||
ui.data_mut(|m| m.insert_temp(egui::Id::unique("prefs-description-rects"), (column, line)));
|
||||
let Some(text) = hovered.or(rows.focused).and_then(descriptions::description) else { return };
|
||||
let mut job = egui::text::LayoutJob::simple(tl!(text).to_string(), egui::FontId::proportional(11.5), t.text_dim, line.width());
|
||||
job.wrap.max_rows = 3;
|
||||
let galley = ui.painter().layout_job(job);
|
||||
ui.painter().with_clip_rect(line).galley(line.min, galley, t.text_dim);
|
||||
}
|
||||
|
||||
/// The rows of the settings the description line can describe: the row under the pointer, and the
|
||||
/// row holding the control with the keyboard focus.
|
||||
#[derive(Default)]
|
||||
struct DescribedRows {
|
||||
hovered: Option<&'static str>,
|
||||
focused: Option<&'static str>,
|
||||
}
|
||||
|
||||
impl DescribedRows {
|
||||
/// After the row of the setting `key`, drawn from `top` down. A row this platform does not draw
|
||||
/// takes no space and is skipped. A screen reader gets the row's sentence as the description of
|
||||
/// its focused control.
|
||||
fn row(&mut self, ui: &egui::Ui, key: &'static str, top: f32) {
|
||||
let bottom = ui.min_rect().bottom();
|
||||
if bottom <= top {
|
||||
return;
|
||||
}
|
||||
let rect = egui::Rect::from_x_y_ranges(ui.max_rect().x_range(), top..=bottom);
|
||||
if ui.rect_contains_pointer(rect) {
|
||||
self.hovered = Some(key);
|
||||
}
|
||||
let Some(id) = ui.memory(|m| m.focused()) else { return };
|
||||
if ui.ctx().read_response(id).is_some_and(|r| rect.contains(r.rect.center())) {
|
||||
self.focused = Some(key);
|
||||
if let Some(text) = descriptions::description(key) {
|
||||
ui.ctx().accesskit_node_builder(id, |node| node.set_description(tl!(text).to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The fields of the category `cat`. → The rows under the pointer and with the keyboard focus.
|
||||
fn category_fields(ui: &mut egui::Ui, app: &mut VectorcraftApp, d: &mut Dialog, cat: &str) -> DescribedRows {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let mut section = "";
|
||||
let mut first = true;
|
||||
let mut described = DescribedRows::default();
|
||||
let specs: Vec<_> = PREF_SPECS.iter().filter(|s| s.category == cat).collect();
|
||||
for (key, c, label) in UI_FIELDS {
|
||||
if *c == cat && cat != "Smart Guides" {
|
||||
let top = ui.cursor().top();
|
||||
let mark = found_mark(ui, d, key);
|
||||
bool_row(ui, d, key, label);
|
||||
found_paint(ui, d, mark);
|
||||
described.row(ui, key, top);
|
||||
}
|
||||
}
|
||||
if cat == "Smart Guides" {
|
||||
let top = ui.cursor().top();
|
||||
let mark = found_mark(ui, d, "__smartGuides");
|
||||
bool_row(ui, d, "__smartGuides", UI_FIELDS[0].2);
|
||||
found_paint(ui, d, mark);
|
||||
described.row(ui, "__smartGuides", top);
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
for sp in specs {
|
||||
@@ -508,6 +588,7 @@ fn category_fields(ui: &mut egui::Ui, app: &mut VectorcraftApp, d: &mut Dialog,
|
||||
}
|
||||
first = false;
|
||||
let v = d.fields.get(sp.key).cloned().unwrap_or(Value::Null);
|
||||
let top = ui.cursor().top();
|
||||
let mark = found_mark(ui, d, sp.key);
|
||||
match sp.kind {
|
||||
// General › Scroll Sideways with Cmd/Ctrl + Wheel acts only while Zoom with Mouse Wheel
|
||||
@@ -693,7 +774,9 @@ fn category_fields(ui: &mut egui::Ui, app: &mut VectorcraftApp, d: &mut Dialog,
|
||||
}
|
||||
}
|
||||
found_paint(ui, d, mark);
|
||||
described.row(ui, sp.key, top);
|
||||
}
|
||||
described
|
||||
}
|
||||
|
||||
/// Choose… beside the folder preference `key`: the folder picked becomes the field's value when it
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//! The sentence the Preferences dialog shows under its fields for the setting under the pointer,
|
||||
//! or for the setting whose control has the keyboard focus, by the setting's key, in English.
|
||||
//! Every sentence has a row in each complete catalog.
|
||||
|
||||
/// (preference key, sentence), in the order the dialog lists the settings.
|
||||
pub(crate) const DESCRIPTIONS: &[(&str, &str)] = &[
|
||||
// Units
|
||||
(
|
||||
"unitsGeneral",
|
||||
"The unit for new documents from built-in sizes other than pixel sizes and for opened files that record no unit; choosing one here and clicking OK also sets the active document's units.",
|
||||
),
|
||||
("unitsStroke", "Stroke weights, dashes and gaps show in this unit, and numbers typed for them are read in it."),
|
||||
("unitsType", "Type sizes, leading and baseline shift show in this unit, and numbers typed for them are read in it."),
|
||||
("unitsAsianType", "The unit for East Asian type measurements, which no field uses yet."),
|
||||
("numbersWithoutUnitsArePoints", "When on, a number typed without a unit into a field in picas is read in points."),
|
||||
("identifyObjectsBy", "With XML ID, object names show as XML IDs in the Layers panel, the Variables panel and Layer Options."),
|
||||
];
|
||||
|
||||
/// The sentence that describes the setting `key`, in English, or `None` when it has none yet.
|
||||
pub(crate) fn description(key: &str) -> Option<&'static str> {
|
||||
DESCRIPTIONS.iter().find(|(k, _)| *k == key).map(|(_, s)| *s)
|
||||
}
|
||||
@@ -1075,7 +1075,9 @@ fn scroll_sideways_with_cmd_wheel_dims_with_zoom_with_mouse_wheel() {
|
||||
let mut frame = |d: &mut Dialog, events: Vec<egui::Event>| {
|
||||
let raw =
|
||||
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 900.0))), events, ..Default::default() };
|
||||
let mut out = ctx.run_ui(raw, |ui| category_fields(ui, &mut a, d, "General"));
|
||||
let mut out = ctx.run_ui(raw, |ui| {
|
||||
category_fields(ui, &mut a, d, "General");
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
out.shapes.iter().find_map(|c| label(&c.shape, "Scroll Sideways with Cmd/Ctrl + Wheel"))
|
||||
};
|
||||
@@ -1113,7 +1115,9 @@ fn show_samples_on_white_dims_without_in_menu_font_previews() {
|
||||
events,
|
||||
..Default::default()
|
||||
};
|
||||
let mut out = ctx.run_ui(raw, |ui| category_fields(ui, &mut a, d, "Type"));
|
||||
let mut out = ctx.run_ui(raw, |ui| {
|
||||
category_fields(ui, &mut a, d, "Type");
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
out.shapes.iter().find_map(|c| label(&c.shape, "Show samples on white"))
|
||||
};
|
||||
@@ -1625,3 +1629,242 @@ fn ok_refuses_a_typed_folder_outside_the_automation_roots_before_looking_at_it()
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// One frame of the open Preferences dialog with `events`, a quarter second after the last. → The
|
||||
/// texts it painted where they show (a text its clip rectangle hides is left out), with their
|
||||
/// rectangles, and the description of each accessibility node that has one.
|
||||
fn description_frame(a: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> (Vec<(String, egui::Rect)>, Vec<String>) {
|
||||
let time = ctx.input(|i| i.time) + 0.25;
|
||||
let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1200.0, 900.0)));
|
||||
let raw = egui::RawInput { screen_rect, events, time: Some(time), ..Default::default() };
|
||||
let mut out = ctx.run_ui(raw, |ui| show(a, ui.ctx()));
|
||||
out.textures_delta.clear();
|
||||
fn walk(s: &egui::Shape, clip: egui::Rect, v: &mut Vec<(String, egui::Rect)>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => {
|
||||
let r = egui::Rect::from_min_size(t.pos, t.galley.size());
|
||||
if r.intersects(clip) {
|
||||
v.push((t.galley.text().to_string(), r));
|
||||
}
|
||||
}
|
||||
egui::Shape::Vec(s) => s.iter().for_each(|s| walk(s, clip, v)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut texts = vec![];
|
||||
out.shapes.iter().for_each(|c| walk(&c.shape, c.clip_rect, &mut texts));
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
let described = nodes.iter().filter_map(|(_, n)| n.description().map(str::to_string)).collect();
|
||||
(texts, described)
|
||||
}
|
||||
|
||||
/// The Preferences window's rectangle.
|
||||
fn preferences_window(ctx: &egui::Context) -> egui::Rect {
|
||||
ctx.memory(|m| m.area_rect(egui::Id::unique("dialog-preferences"))).expect("the dialog window is shown")
|
||||
}
|
||||
|
||||
/// Whether one of `texts` is `sentence`.
|
||||
fn painted(texts: &[(String, egui::Rect)], sentence: &str) -> bool {
|
||||
texts.iter().any(|(t, _)| t == sentence)
|
||||
}
|
||||
|
||||
/// The pointer over a Units row shows that row's sentence at the bottom of the dialog, and the
|
||||
/// dialog keeps its size.
|
||||
#[test]
|
||||
fn hovering_a_units_row_shows_its_description() {
|
||||
let mut a = app();
|
||||
open(&mut a, Some("Units"));
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
description_frame(&mut a, &ctx, vec![]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
let size = preferences_window(&ctx).size();
|
||||
let general = descriptions::description("unitsGeneral").expect("Units › General has a sentence");
|
||||
let stroke = descriptions::description("unitsStroke").expect("Units › Stroke has a sentence");
|
||||
assert!(!painted(&texts, general), "nothing is described before the pointer comes");
|
||||
let row = |texts: &[(String, egui::Rect)], label: &str| {
|
||||
texts.iter().find(|(t, _)| t == label).map(|(_, r)| r.center()).unwrap_or_else(|| panic!("no `{label}` in {texts:?}"))
|
||||
};
|
||||
let at = row(&texts, "General:");
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at)]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
assert!(painted(&texts, general), "the General row's sentence shows: {texts:?}");
|
||||
assert!(!painted(&texts, stroke));
|
||||
let line = texts.iter().find(|(t, _)| t == general).map(|(_, r)| *r).unwrap();
|
||||
let ok = row(&texts, "OK");
|
||||
assert!(line.bottom() < ok.y, "the sentence is above OK: {line:?}, {ok:?}");
|
||||
assert_eq!(preferences_window(&ctx).size(), size, "the dialog keeps its size");
|
||||
let at = row(&texts, "Stroke:");
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at)]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
assert!(painted(&texts, stroke) && !painted(&texts, general), "the Stroke row's sentence replaces it");
|
||||
// Moving from row to row, across the spacing between them, never leaves the line empty.
|
||||
let (from, to) = (row(&texts, "General:"), row(&texts, "Stroke:"));
|
||||
let mut y = from.y;
|
||||
while y <= to.y {
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(egui::pos2(from.x, y))]);
|
||||
assert!(painted(&texts, general) || painted(&texts, stroke), "a sentence shows with the pointer at y = {y}");
|
||||
y += 1.0;
|
||||
}
|
||||
// Moving down onto the line keeps the sentence there to read.
|
||||
let line = description_line_rects(&ctx).line;
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
assert!(painted(&texts, stroke), "the sentence stays while the pointer is on the line: {texts:?}");
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerGone]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
assert!(!painted(&texts, stroke), "the sentence goes with the pointer");
|
||||
assert_eq!(preferences_window(&ctx).size(), size);
|
||||
}
|
||||
|
||||
/// With nothing under the pointer, the row whose control has the keyboard focus is described, and a
|
||||
/// screen reader gets the same sentence as that control's description.
|
||||
#[test]
|
||||
fn keyboard_focus_on_a_units_row_shows_its_description() {
|
||||
let mut a = app();
|
||||
open(&mut a, Some("Units"));
|
||||
let ctx = egui::Context::default();
|
||||
ctx.enable_accesskit();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
description_frame(&mut a, &ctx, vec![]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
let general = descriptions::description("unitsGeneral").expect("Units › General has a sentence");
|
||||
assert!(ctx.memory(|m| m.has_focus(search_edit_id())), "the search field has the focus on open");
|
||||
assert!(!painted(&texts, general));
|
||||
// Tab from the search field through the category list to the first Units control.
|
||||
let mut shown = None;
|
||||
for _ in 0..40 {
|
||||
let (texts, described) = description_frame(&mut a, &ctx, key_press(egui::Key::Tab, egui::Modifiers::NONE));
|
||||
if painted(&texts, general) {
|
||||
shown = Some(described);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let described = shown.expect("Tab reaches the General row and its sentence shows");
|
||||
assert!(described.iter().any(|d| d == general), "the focused control carries the sentence: {described:?}");
|
||||
}
|
||||
|
||||
/// The field list with the description line under it, and the description line, in the last frame.
|
||||
struct DescriptionRects {
|
||||
column: egui::Rect,
|
||||
line: egui::Rect,
|
||||
}
|
||||
|
||||
fn description_line_rects(ctx: &egui::Context) -> DescriptionRects {
|
||||
let (column, line) =
|
||||
ctx.data(|m| m.get_temp::<(egui::Rect, egui::Rect)>(egui::Id::unique("prefs-description-rects"))).expect("the description line is shown");
|
||||
DescriptionRects { column, line }
|
||||
}
|
||||
|
||||
/// A row with no sentence leaves the description line empty, also after another category's row
|
||||
/// was described, and the dialog keeps its size.
|
||||
#[test]
|
||||
fn a_row_without_a_description_leaves_the_line_empty() {
|
||||
let mut a = app();
|
||||
open(&mut a, Some("Units"));
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
description_frame(&mut a, &ctx, vec![]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
let at = |texts: &[(String, egui::Rect)], label: &str| {
|
||||
texts.iter().find(|(t, _)| t == label).map(|(_, r)| r.center()).unwrap_or_else(|| panic!("no `{label}` in {texts:?}"))
|
||||
};
|
||||
let general = descriptions::description("unitsGeneral").expect("Units › General has a sentence");
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at(&texts, "General:"))]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
assert!(painted(&texts, general), "the General row's sentence shows: {texts:?}");
|
||||
// Go to the General category and point at a row with no sentence.
|
||||
let button = at(&texts, "General");
|
||||
let press = |pressed| egui::Event::PointerButton { pos: button, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(button), press(true), press(false)]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
let size = preferences_window(&ctx).size();
|
||||
let line = description_line_rects(&ctx).line;
|
||||
let empty = |texts: &[(String, egui::Rect)], when: &str| {
|
||||
let drawn: Vec<_> = texts.iter().filter(|(_, r)| r.intersects(line)).collect();
|
||||
assert!(drawn.is_empty(), "{when}: nothing is drawn on the line: {drawn:?}");
|
||||
};
|
||||
// The Units sentence does not follow the pointer onto the line of another category.
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]);
|
||||
let (after, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
empty(&after, "on the line after changing category");
|
||||
assert_eq!(descriptions::description("keyboardIncrement"), None);
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at(&texts, "Keyboard Increment:"))]);
|
||||
let (after, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
empty(&after, "on Keyboard Increment");
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]);
|
||||
let (after, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
empty(&after, "on the line after Keyboard Increment");
|
||||
assert_eq!(preferences_window(&ctx).size(), size);
|
||||
}
|
||||
|
||||
/// A sentence shown when the dialog closed does not come back when it opens again with the
|
||||
/// pointer away from the rows.
|
||||
#[test]
|
||||
fn opening_the_dialog_again_starts_with_an_empty_line() {
|
||||
let mut a = app();
|
||||
open(&mut a, Some("Units"));
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
description_frame(&mut a, &ctx, vec![]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
let general = descriptions::description("unitsGeneral").expect("Units › General has a sentence");
|
||||
let at = texts.iter().find(|(t, _)| t == "General:").map(|(_, r)| r.center()).expect("the General row is shown");
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(at)]);
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
assert!(painted(&texts, general), "the General row's sentence shows: {texts:?}");
|
||||
let line = description_line_rects(&ctx).line;
|
||||
a.ui.dialog = None;
|
||||
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(line.center())]);
|
||||
description_frame(&mut a, &ctx, vec![]);
|
||||
open(&mut a, Some("Units"));
|
||||
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
|
||||
assert!(!painted(&texts, general), "the old sentence does not come back: {texts:?}");
|
||||
}
|
||||
|
||||
/// The field list and the description line under it together take the height the field list
|
||||
/// alone took before the line, in every category, so the dialog keeps its size.
|
||||
#[test]
|
||||
fn the_description_line_keeps_the_fields_column_height() {
|
||||
let mut a = app();
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
for cat in PREF_CATEGORIES {
|
||||
open(&mut a, Some(*cat));
|
||||
description_frame(&mut a, &ctx, vec![]);
|
||||
description_frame(&mut a, &ctx, vec![]);
|
||||
let kept = description_line_rects(&ctx);
|
||||
assert!((kept.column.height() - 400.0).abs() < 0.01, "{cat}: the column is {} tall, not 400", kept.column.height());
|
||||
assert!((kept.line.height() - DESCRIPTION_HEIGHT).abs() < 0.01, "{cat}: the line is {} tall", kept.line.height());
|
||||
}
|
||||
}
|
||||
|
||||
/// Each sentence describes a setting the dialog shows, and every complete catalog translates it
|
||||
/// into at most the three lines the description line holds.
|
||||
#[test]
|
||||
fn every_description_names_a_setting_and_fits_in_every_language() {
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let mut bad = vec![];
|
||||
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
|
||||
for (key, sentence) in descriptions::DESCRIPTIONS {
|
||||
if !settings().any(|s| s.key == *key) {
|
||||
bad.push(format!("`{key}` is not a setting the dialog shows"));
|
||||
}
|
||||
for lang in crate::i18n::Lang::all() {
|
||||
let text = crate::i18n::tr(lang, sentence);
|
||||
if lang != crate::i18n::Lang::EN && text == *sentence {
|
||||
bad.push(format!("{}: no row for {sentence:?}", lang.code()));
|
||||
}
|
||||
let mut job = egui::text::LayoutJob::simple(text.to_string(), egui::FontId::proportional(11.5), egui::Color32::WHITE, 530.0);
|
||||
job.wrap.max_rows = 3;
|
||||
let galley = ui.painter().layout_job(job);
|
||||
if galley.elided || galley.size().y > DESCRIPTION_HEIGHT {
|
||||
bad.push(format!("{}: {text:?} takes more than three lines", lang.code()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
assert!(bad.is_empty(), "{}", bad.join("\n"));
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ VectorCraft choices; an original approximation, never compared with another appl
|
||||
| Revolve | initial: live, editable profile, rotation and light gizmos, default-on Cap with continuous curved rims, smooth vector shading and round seam joins, overlapping faces drawn in the order of their depths where they overlap, SVG/PDF output, Expand Appearance ([revolve.md](revolve.md), #846) |
|
||||
| Extrude & Bevel, Inflate, Rotate | initial: live, round seam joins, depth, twist, taper, solid or hollow caps, five original bevel shapes, Inflate volume, both sides, twist, taper and cap, Rotate of every fill and stroke, groups and layers turned about one shared axis (#4506), contours that cross, touch or overlap merged first ([three-d.md](three-d.md)), Position presets, rotation and light gizmos, SVG/PDF output, Expand Appearance ([three-d.md](three-d.md)) |
|
||||
| Materials panel, lighting, ray-traced render | Window › 3D and Materials panel with the object types (Plane, Extrude, Revolve, Inflate) and the Object, Rotation and Lighting settings of the applied effect, Render Settings › Wireframe, which draws the live effect as the edges of its faces, and Quick Actions › Expand as Wireframes ([three-d.md](three-d.md#3d-and-materials-panel)); one to ten directional lights with per-light Color (opaque RGB, white by default), Intensity, Rotation, Height, Softness and neutral Ambient Light, Revolve and colored Inflate use smooth vector shading; Extrude & Bevel and Rotate retain planar shading; original Standard, Diffuse, Top Left and Right lighting rigs; hard-edged shadows behind or below the object from the first light ([three-d.md](three-d.md#shadows)); the Materials tab's Graphics, document symbols mapped onto Extrude & Bevel's caps and onto a plane, moved with an artboard handle, and wrapped around Revolve's side ([three-d.md](three-d.md#graphics)); no base materials, graphics on Inflate or on Extrude & Bevel's walls and bevels, soft shadows or ray tracing |
|
||||
| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, round seam joins, Extrude Depth, Cap, five original bevel shapes with Height and Bevel Extent In or Out, Position presets and rotation gizmo, Perspective, Wireframe, No Shading, Diffuse and Plastic surfaces with one to ten lights, Light Intensity, Ambient Light, Highlight Intensity and Size, Blend Steps, Black, Custom or no Shading Color, Draw Hidden Faces ([create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html)); Revolve (Classic) initial: live, round seam joins, Angle, Cap, Offset from the left or right edge, Position presets and rotation gizmo, Perspective, the same four surfaces, lights, highlight, Blend Steps and Shading Color, groups and layers revolved about one shared axis (same page); Rotate (Classic) initial: live, round seam joins, every fill and stroke turned as one plane, Position presets and rotation gizmo, Perspective, No Shading and Diffuse surfaces with lights, Ambient Light, Blend Steps and Shading Color ([rotate objects in 3D](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/rotate-objects-in-3d.html)); Preserve Spot Colors in all three, unavailable with a Custom Shading Color ([Preserve Spot Color](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)); all three: a lighting sphere on the Lighting tab whose lights drag, move to the back or front, and are added at the front center or deleted down to one ([lighting options](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=272)); all three: the track cube (face, edge, Shift and ring drags, keyboard steps; [three-d.md](three-d.md#track-cube)); Map Art: none |
|
||||
| 3D (Classic): Extrude & Bevel, Revolve, Rotate | Extrude & Bevel (Classic) initial: live, round seam joins, Extrude Depth, Cap, five original bevel shapes with Height and Bevel Extent In or Out, Position presets and rotation gizmo, Perspective, Wireframe, No Shading, Diffuse and Plastic surfaces with one to ten lights, Light Intensity, Ambient Light, Highlight Intensity and Size, Blend Steps, Black, Custom, Black Overprint or no Shading Color ([Black Overprint](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=188)), Draw Hidden Faces ([create 3D objects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html)); Revolve (Classic) initial: live, round seam joins, Angle, Cap, Offset from the left or right edge, Position presets and rotation gizmo, Perspective, the same four surfaces, lights, highlight, Blend Steps and Shading Color, groups and layers revolved about one shared axis (same page); Rotate (Classic) initial: live, round seam joins, every fill and stroke turned as one plane, Position presets and rotation gizmo, Perspective, No Shading and Diffuse surfaces with lights, Ambient Light, Blend Steps and Shading Color ([rotate objects in 3D](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/rotate-objects-in-3d.html)); Preserve Spot Colors in all three, unavailable with a Custom Shading Color ([Preserve Spot Color](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)); all three: a lighting sphere on the Lighting tab whose lights drag, move to the back or front, and are added at the front center or deleted down to one ([lighting options](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=272)); all three: the track cube (face, edge, Shift and ring drags, keyboard steps; [three-d.md](three-d.md#track-cube)); Map Art: none |
|
||||
| Turntable (30.0 beta) | none |
|
||||
| Export 3D objects (OBJ, USDA, glTF) | initial: Asset Export's Export 3D Object, and the 3D and Materials panel's Export 3D Object button (which then shows Asset Export with the new assets selected, [three-d.md](three-d.md#3d-and-materials-panel)), collect an object with Extrude & Bevel, Revolve, Inflate or Rotate as a 3D asset, and Export writes its solids as a USDA (the default), USDZ, glTF or OBJ mesh with a material in each solid's paint color (`assets.add3D`, `assets.set3DFormat`, `assets.export3D`); no textures, map art or shading ([3D export help](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/export-3d-vector-artwork.html)) |
|
||||
|
||||
|
||||
@@ -249,7 +249,9 @@ private editing data. VectorCraft:
|
||||
paint; Graph Data then edits it. Other graphs (pie and scatter graphs, graphs with designs or
|
||||
customizations, records of later versions) come in as plain groups, paths and type, with a note. Saving a graph to
|
||||
`.ai`, in either form, writes these records around its art when the reader above reads them back as the same graph,
|
||||
so the file opens again with its data and settings; any other graph is written as its art, with a warning.
|
||||
so the file opens again with its data and settings; any other graph is written as its art, with a warning. A
|
||||
legend swatch the graph tools draw has the stroke of its series' marks, so a drawn stacked column or area graph
|
||||
is written with its records.
|
||||
Legacy `.ai` patterns in the version 7 form (a list of `@` and `&` layers, `_ &` for the tile's background)
|
||||
open as pattern swatches, with a fill's offset, scale, rotation, reflection and shear applied before its
|
||||
matrix. Legacy `.ai` linked images in
|
||||
|
||||
@@ -55,7 +55,7 @@ plus review. Native-speaker review is human work and isn't in the hours.
|
||||
| Traditional Chinese (Taiwan) | `zh-hant` | 8,820 rows, 3,438 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 40 missing messages for it; menus, `tl!` literals and messages were complete when counted on 2026-10-21 (80% overall) | partial |
|
||||
| Italian | `it` | 8,924 rows, 3,560 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 54 missing messages for it, which open #7116, #7211, #7378 and #7405 translate | full |
|
||||
| Dutch | `nl` | 3,447 `@msg` and 48 `@msgplural` rows (counted 2026-11-13): in `COMPLETE_MESSAGES`, and the untranslated report lists 41 missing messages for it; one/other plurals | full |
|
||||
| Danish | `da` | 7,422 rows, 1,636 of them `@msg` and 48 `@msgplural` (counted 2026-11-14 on `main` at `edb228ac3`): in `COMPLETE_MESSAGES`, and the untranslated report lists the same missing messages for it as for Greek, Spanish and Finnish; one/other plurals | full |
|
||||
| Danish | `da` | 9,616 rows, 3,702 of them `@msg` and 49 `@msgplural` (counted 2026-11-15): in `COMPLETE_MESSAGES`, and the untranslated report lists 81 missing messages for it, 46 of them missing in every language; one/other plurals | full |
|
||||
| Russian | `ru` | 9,259 rows, 3,444 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): in `COMPLETE_MESSAGES`; the untranslated report lists 46 menu strings, 21 `tl!` literals and 11 undo labels as missing | full |
|
||||
| Ukrainian | `uk` | 8,802 rows, 3,439 of them `@msg` and 48 `@msgplural` (counted 2026-11-13); one/few/many plurals | full |
|
||||
| Hungarian | `hu` | 9,166 rows, 3,444 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 40 missing messages for it, and lists 47 menu strings, 25 `tl!` strings, 11 undo labels and 45 swatch names without a row; one plural form | full |
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user