mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
Read character appearance through shared IDML model
This commit is contained in:
3 files changed
+29
-29
No files matched your search
Generated
+9
-9
@@ -1242,10 +1242,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-idml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80#914123d662728b49864ff2917147e5fbb4df8d80"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362#a335834a14c676581ec63cbb345a3e8520997362"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362)",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
@@ -1665,7 +1665,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80#914123d662728b49864ff2917147e5fbb4df8d80"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362#a335834a14c676581ec63cbb345a3e8520997362"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1740,7 +1740,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80#914123d662728b49864ff2917147e5fbb4df8d80"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362#a335834a14c676581ec63cbb345a3e8520997362"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2021,7 +2021,7 @@ dependencies = [
|
||||
"craft-prepress",
|
||||
"craft-print",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1)",
|
||||
"designcraft-color",
|
||||
"designcraft-compose",
|
||||
@@ -2103,9 +2103,9 @@ name = "designcraft-idml"
|
||||
version = "0.20.1"
|
||||
dependencies = [
|
||||
"craft-file-formats",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362)",
|
||||
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362)",
|
||||
"designcraft-color",
|
||||
"designcraft-compose",
|
||||
"designcraft-doc",
|
||||
@@ -2222,7 +2222,7 @@ version = "0.20.1"
|
||||
dependencies = [
|
||||
"craft-docx",
|
||||
"craft-file-formats",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=914123d662728b49864ff2917147e5fbb4df8d80)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a335834a14c676581ec63cbb345a3e8520997362)",
|
||||
"craft-rtf",
|
||||
"craft-wordmodel",
|
||||
"craft-xlsx",
|
||||
|
||||
+2
-2
@@ -16,10 +16,10 @@ craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4052591363
|
||||
craft-designcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "19692b6190465671e41967c75d0cd4c439d0c84c", version = "=0.1.0" }
|
||||
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
|
||||
craft-epub = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
|
||||
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "914123d662728b49864ff2917147e5fbb4df8d80", version = "=0.1.0" }
|
||||
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "a335834a14c676581ec63cbb345a3e8520997362", version = "=0.1.0" }
|
||||
craft-indd = { git = "https://github.com/storytold/craft-libs", rev = "47bf5650b0d503b97bfb5e841746c4957897d11f", version = "=0.1.0" }
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "cc23ffd4d26f3074808e2187d332564817624f8f", version = "=0.1.0", features = ["tree-render", "tree-text"] }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "914123d662728b49864ff2917147e5fbb4df8d80", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "a335834a14c676581ec63cbb345a3e8520997362", version = "=0.1.0" }
|
||||
craft-xml-dtd = { package = "craft-xml", git = "https://github.com/storytold/craft-libs", rev = "f23b0f33f0d00b157476533a43cbbcfd901aa1f1", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
|
||||
|
||||
@@ -69,41 +69,41 @@ impl<'r> Importer<'r> {
|
||||
a.v_scale = values.vertical_scale.map(|v| v / 100.0);
|
||||
a.baseline_shift = values.baseline_shift;
|
||||
a.skew = values.skew;
|
||||
if let Some(r) = e.prop("FillColor") {
|
||||
let appearance = craft_idml::model::CharacterAppearanceValues::from_el(&crate::xml::to_craft(e));
|
||||
if let Some(r) = appearance.fill_color {
|
||||
a.fill = Some(self.swatch_ref(r.trim()));
|
||||
}
|
||||
a.fill_tint = tint(e.num("FillTint"));
|
||||
if let Some(r) = e.prop("StrokeColor") {
|
||||
a.fill_tint = tint(appearance.fill_tint);
|
||||
if let Some(r) = appearance.stroke_color {
|
||||
a.stroke = Some(self.swatch_ref(r.trim()));
|
||||
}
|
||||
a.stroke_tint = tint(e.num("StrokeTint"));
|
||||
a.stroke_weight = e.num("StrokeWeight");
|
||||
a.stroke_tint = tint(appearance.stroke_tint);
|
||||
a.stroke_weight = appearance.stroke_weight;
|
||||
// Text strokes are centred on the outline or lie outside it, behind the fill.
|
||||
a.stroke_behind_fill = e.prop("StrokeAlignment").and_then(|v| match v.trim() {
|
||||
a.stroke_behind_fill = appearance.stroke_alignment.as_deref().and_then(|v| match v.trim() {
|
||||
"OutsideAlignment" => Some(true),
|
||||
"CenterAlignment" => Some(false),
|
||||
_ => None,
|
||||
});
|
||||
a.capitalization = e.prop("Capitalization").and_then(|v| names::caps_in(v.trim()));
|
||||
a.position = e.prop("Position").and_then(|v| names::position_in(v.trim()));
|
||||
a.underline = e.boolean("Underline");
|
||||
a.strikethrough = e.boolean("StrikeThru");
|
||||
a.ligatures = e.boolean("Ligatures");
|
||||
a.underline = appearance.underline;
|
||||
a.strikethrough = appearance.strikethrough;
|
||||
a.ligatures = appearance.ligatures;
|
||||
// Underline / strikethrough options (-9999 = automatic).
|
||||
for k in ["Underline", "StrikeThru"] {
|
||||
let num = |n: &str| e.num(&format!("{k}{n}")).filter(|v| *v > -9000.0);
|
||||
for (underline, values) in [(true, appearance.underline_options), (false, appearance.strikethrough_options)] {
|
||||
// An explicit Text Color resets an inherited swatch; absence still inherits.
|
||||
// Resolve the sentinel before swatch_ref, which maps unknown names to [None].
|
||||
let color = e.prop(&format!("{k}Color")).map(|r| if r.trim() == "Text Color" { String::new() } else { self.swatch_ref(r.trim()) });
|
||||
let tint = tint(e.num(&format!("{k}Tint")));
|
||||
if k == "Underline" {
|
||||
a.underline_weight = num("Weight").map(Some);
|
||||
a.underline_offset = num("Offset").map(Some);
|
||||
let color = values.color.map(|r| if r.trim() == "Text Color" { String::new() } else { self.swatch_ref(r.trim()) });
|
||||
let tint = tint(values.tint);
|
||||
if underline {
|
||||
a.underline_weight = values.weight.map(Some);
|
||||
a.underline_offset = values.offset.map(Some);
|
||||
a.underline_color = color;
|
||||
a.underline_tint = tint;
|
||||
} else {
|
||||
a.strikethrough_weight = num("Weight").map(Some);
|
||||
a.strikethrough_offset = num("Offset").map(Some);
|
||||
a.strikethrough_weight = values.weight.map(Some);
|
||||
a.strikethrough_offset = values.offset.map(Some);
|
||||
a.strikethrough_color = color;
|
||||
a.strikethrough_tint = tint;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user