From 160e11f00ad3eb77a94c6b00a7b3d11f4f0af5a9 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 5 Dec 2022 19:25:08 +0000 Subject: [PATCH] WIP: use toml_edit::easy instead of toml to fix array of arrays https://github.com/toml-rs/toml/issues/387 --- fontir/Cargo.toml | 1 + fontir/src/error.rs | 2 +- fontir/src/ir.rs | 1 - ufo2fontir/Cargo.toml | 1 + ufo2fontir/src/source.rs | 2 +- 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fontir/Cargo.toml b/fontir/Cargo.toml index 13ecb65d6..232622f86 100644 --- a/fontir/Cargo.toml +++ b/fontir/Cargo.toml @@ -16,6 +16,7 @@ read-fonts = { git = 'https://github.com/googlefonts/fontations' } bitflags = "1.3" serde = {version = "1.0", features = ["derive"] } toml = "0.5.9" +toml_edit = { version = "0.15.0", features = ["easy"] } bincode = "1.3.3" filetime = "0.2.18" thiserror = "1.0.37" diff --git a/fontir/src/error.rs b/fontir/src/error.rs index c2ddd4035..5a2eb95be 100644 --- a/fontir/src/error.rs +++ b/fontir/src/error.rs @@ -43,5 +43,5 @@ pub enum WorkError { #[error("Conversion of glyph '{0}' to IR failed: {1}")] GlyphIrWorkError(String, String), #[error("toml error")] - TomlSerError(#[from] toml::ser::Error), + TomlSerError(#[from] toml_edit::ser::Error), } diff --git a/fontir/src/ir.rs b/fontir/src/ir.rs index ca722b42f..0f590bf33 100644 --- a/fontir/src/ir.rs +++ b/fontir/src/ir.rs @@ -1,5 +1,4 @@ //! Serde types for font IR. See TODO:PublicLink. - use std::collections::{BTreeMap, HashMap}; use serde::{Deserialize, Serialize}; diff --git a/ufo2fontir/Cargo.toml b/ufo2fontir/Cargo.toml index 915dd1606..8f570c3f7 100644 --- a/ufo2fontir/Cargo.toml +++ b/ufo2fontir/Cargo.toml @@ -16,6 +16,7 @@ fontir = { version = "0.0.1", path = "../fontir" } serde = {version = "1.0", features = ["derive"] } toml = "0.5.9" +toml_edit = { version = "0.15.0", features = ["easy"] } # TODO use a version of norad with https://github.com/linebender/norad/pull/272 once one exists # norad = "0.7.0" diff --git a/ufo2fontir/src/source.rs b/ufo2fontir/src/source.rs index adfef5b24..730c08884 100644 --- a/ufo2fontir/src/source.rs +++ b/ufo2fontir/src/source.rs @@ -275,7 +275,7 @@ impl Work<()> for GlyphIrWork { // FIXME: this currently fails because TomlSerError(KeyNotString); need to find // a way to serialize a HashMap> let glyph_ir_toml = - toml::ser::to_string_pretty(&glyph_ir).map_err(WorkError::TomlSerError)?; + toml_edit::easy::to_string_pretty(&glyph_ir).map_err(WorkError::TomlSerError)?; fs::write(&self.ir_file, glyph_ir_toml).map_err(WorkError::IoError)?; Ok(()) }