Merge PR #1946: XLSX: keep cell fonts' charset (Arabic 178) and family on save

crates/xlsx/src/styles.rs: family/charset block ported into the dxf.is_none() branch of font_xml (PR #1225 made it take Option<&DxfStated>)
docs/file-format-parity.md: header Change line keeps both sides' clauses
This commit is contained in:
aiongg
2026-10-22 02:36:23 +00:00
7 changed files with 108 additions and 5 deletions
+5 -1
View File
@@ -296,7 +296,11 @@ fn underline(s: &mut Session, p: &Json) -> Result<Json> {
fn font_name(s: &mut Session, p: &Json) -> Result<Json> {
let Some(name) = str_param(p, "name").map(str::to_string) else { return Err(bad("home.fontName", "missing `name`")) };
apply_style(s, p, |st| st.font.name = name.clone())
apply_style(s, p, |st| {
st.font.name = name.clone();
st.font.charset = None;
st.font.family = None;
})
}
fn font_size(s: &mut Session, p: &Json) -> Result<Json> {
+18
View File
@@ -1207,6 +1207,24 @@ fn structured_refs_to_columns_with_edge_spaces() {
assert_eq!([v(&s, "F1"), v(&s, "F2"), v(&s, "F3")], [n(5.0), n(5.0), n(5.0)]);
}
#[test]
fn changing_the_font_name_drops_the_old_fonts_charset_and_family() {
let mut s = s();
{
let wb = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().wb);
let arabic = wb.styles.derive(gridcraft_model::StyleId::DEFAULT, |st| {
st.font.name = "Traditional Arabic".into();
st.font.charset = Some(178);
st.font.family = Some(1);
});
wb.sheet_mut(0).unwrap().set_style(CellRef::parse("A1").unwrap(), arabic);
}
s.execute("home.fontName", json!({"range": "A1", "name": "Arial"})).unwrap();
let d = s.doc().unwrap();
let font = &d.wb.styles.get(d.wb.active().unwrap().style_id(CellRef::parse("A1").unwrap())).font;
assert_eq!((font.name.as_str(), font.charset, font.family), ("Arial", None, None));
}
#[test]
fn table_rename_keeps_a_defined_name_with_the_same_name() {
let mut s = s();