Open timtom-dev opened 2 weeks ago
I think this is likely to be acceptable - it doesn't add any huge maintenance version, and e.g. read-fonts
(which we depend on), already has such a feature.
It does look like skrifa
doesn't currently support serde
, so if you need that you might need to work with upstream to get it
After a quick skim of the code, it doesn't look like any of the parley
or fontique
types contain anything from skrifa
, so unless I missed something, skrifa
shouldn't need to change.
Though it does look like a few types borrow data, for example:
pub enum FontStack<'a> {
/// Font family list in CSS format.
Source(&'a str),
/// Single font family.
Single(FontFamily<'a>),
/// Ordered list of font families.
List(&'a [FontFamily<'a>]),
}
Serde supports string slices, as well as byte arrays through the serde_bytes
crate, but the List
variant can't be automatically derived. My first thought is an OwnedList(Vec<FontFamily<'a>>)
variant that would only be used when deserializing. Would that work?
Would it be possible to add an optional "serde" feature flag that derives serialize and deserialize for at least the types in the style module? If so, I'm happy to submit a pull request!