Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Format.NullableOverrides: preserve automatic annotation and list-tab values

moppeeera7e1c0e974c2
diff --git a/crates/doc/src/attrs.rs b/crates/doc/src/attrs.rs
index 077637672..d30489c9e 100644
--- a/crates/doc/src/attrs.rs
+++ b/crates/doc/src/attrs.rs
@@ -1086,7 +1086,7 @@ attr_set! {
kenten_font: String = String::new(),
kenten_font_style: String = String::new(),
/// Mark size in points; `None` is half the text size.
- kenten_size: Option<f64> = None,
+ kenten_size: Option<f64> = None => "deserialize_explicit_value",
/// Horizontal / vertical scale of the mark, 1.0 = 100%.
kenten_x_scale: f64 = 1.0,
kenten_y_scale: f64 = 1.0,
@@ -1099,10 +1099,10 @@ attr_set! {
/// Mark fill and stroke swatches (empty = the text's), tints and stroke weight (`None` =
/// the text's).
kenten_fill: String = String::new(),
- kenten_fill_tint: Option<f32> = None,
+ kenten_fill_tint: Option<f32> = None => "deserialize_explicit_value",
kenten_stroke: String = String::new(),
- kenten_stroke_tint: Option<f32> = None,
- kenten_stroke_weight: Option<f64> = None,
+ kenten_stroke_tint: Option<f32> = None => "deserialize_explicit_value",
+ kenten_stroke_weight: Option<f64> = None => "deserialize_explicit_value",
kenten_overprint_fill: crate::cjk_settings::AdornmentOverprint = crate::cjk_settings::AdornmentOverprint::Auto,
kenten_overprint_stroke: crate::cjk_settings::AdornmentOverprint = crate::cjk_settings::AdornmentOverprint::Auto,
// Shatai (斜体): the character is compressed across the direction at `shatai_angle`.
@@ -1126,7 +1126,7 @@ attr_set! {
ruby_font: String = String::new(),
ruby_font_style: String = String::new(),
/// Points; `None` is half the parent size.
- ruby_font_size: Option<f64> = None,
+ ruby_font_size: Option<f64> = None => "deserialize_explicit_value",
/// 1.0 = 100%.
ruby_x_scale: f64 = 1.0,
ruby_y_scale: f64 = 1.0,
@@ -1147,10 +1147,10 @@ attr_set! {
ruby_scaling_min: f64 = 0.66,
/// Ruby colour: empty is the text's colour; `None` tint and weight follow the text.
ruby_fill: String = String::new(),
- ruby_fill_tint: Option<f32> = None,
+ ruby_fill_tint: Option<f32> = None => "deserialize_explicit_value",
ruby_stroke: String = String::new(),
- ruby_stroke_tint: Option<f32> = None,
- ruby_stroke_weight: Option<f64> = None,
+ ruby_stroke_tint: Option<f32> = None => "deserialize_explicit_value",
+ ruby_stroke_weight: Option<f64> = None => "deserialize_explicit_value",
ruby_overprint_fill: crate::cjk_settings::AdornmentOverprint = crate::cjk_settings::AdornmentOverprint::Auto,
ruby_overprint_stroke: crate::cjk_settings::AdornmentOverprint = crate::cjk_settings::AdornmentOverprint::Auto,
/// Digits (World-Ready): how 0–9 are drawn.
@@ -1351,7 +1351,7 @@ attr_set! {
bullet_align: ListAlign = ListAlign::Left,
number_align: ListAlign = ListAlign::Left,
/// A tab stop for the text after the bullet or number, from the column's left edge.
- list_tab: Option<f64> = None,
+ list_tab: Option<f64> = None => "deserialize_explicit_value",
/// Restart Numbers at This Level After: a paragraph at a higher level (0 = any; otherwise
/// that level) starts this level's numbering again.
restart_numbers: bool = true,
diff --git a/crates/format/src/lib.rs b/crates/format/src/lib.rs
index d5653eb9d..c77896b48 100644
--- a/crates/format/src/lib.rs
+++ b/crates/format/src/lib.rs
@@ -794,6 +794,14 @@ mod tests {
underline_offset: Some(Some(1.0)),
strikethrough_weight: Some(Some(2.0)),
strikethrough_offset: Some(Some(1.0)),
+ kenten_size: Some(Some(14.0)),
+ kenten_fill_tint: Some(Some(0.3)),
+ kenten_stroke_tint: Some(Some(0.4)),
+ kenten_stroke_weight: Some(Some(2.0)),
+ ruby_font_size: Some(Some(14.0)),
+ ruby_fill_tint: Some(Some(0.3)),
+ ruby_stroke_tint: Some(Some(0.4)),
+ ruby_stroke_weight: Some(Some(2.0)),
..Default::default()
};
// Legacy JSON loads as format 1, whose upgrade pins Keep Lines Together and Align Left
@@ -803,6 +811,7 @@ mod tests {
start_at: Some(Some(7)),
paragraph_kashida_width: Some(Some(0.5)),
kinsoku: Some(Some(Default::default())),
+ list_tab: Some(Some(36.0)),
keep_all_lines: Some(true),
drop_cap_align_left: Some(true),
..Default::default()
@@ -817,9 +826,18 @@ mod tests {
underline_offset: Some(None),
strikethrough_weight: Some(None),
strikethrough_offset: Some(None),
+ kenten_size: Some(None),
+ kenten_fill_tint: Some(None),
+ kenten_stroke_tint: Some(None),
+ kenten_stroke_weight: Some(None),
+ ruby_font_size: Some(None),
+ ruby_fill_tint: Some(None),
+ ruby_stroke_tint: Some(None),
+ ruby_stroke_weight: Some(None),
..Default::default()
};
- let clear_para = ParaAttrs { start_at: Some(None), paragraph_kashida_width: Some(None), kinsoku: Some(None), ..Default::default() };
+ let clear_para =
+ ParaAttrs { start_at: Some(None), paragraph_kashida_width: Some(None), kinsoku: Some(None), list_tab: Some(None), ..Default::default() };
let selected = if style_clear {
std::sync::Arc::make_mut(&mut d.styles).paragraph.push(designcraft_doc::styles::ParagraphStyle {
name: "Defaults".into(),
@@ -860,6 +878,15 @@ mod tests {
assert_eq!(expected.0.paragraph_kashida_width, None);
assert_eq!(expected.0.kinsoku, None);
assert_eq!(expected.1.leading_aki, None);
+ assert_eq!(expected.0.list_tab, None);
+ assert_eq!(expected.1.kenten_size, None);
+ assert_eq!(expected.1.kenten_fill_tint, None);
+ assert_eq!(expected.1.kenten_stroke_tint, None);
+ assert_eq!(expected.1.kenten_stroke_weight, None);
+ assert_eq!(expected.1.ruby_font_size, None);
+ assert_eq!(expected.1.ruby_fill_tint, None);
+ assert_eq!(expected.1.ruby_stroke_tint, None);
+ assert_eq!(expected.1.ruby_stroke_weight, None);
// Legacy JSON is format 1: its upgrade pins older defaults on the other styles, so only
// the native ZIP compares as the whole document.
for (bytes, native) in [(save(d).unwrap(), true), (serde_json::to_vec(d).unwrap(), false)] {