From 43c6a615b7defdac68a265acb8d242a4da9159da Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Tue, 9 Apr 2024 12:58:39 -0400 Subject: [PATCH] [glyphs-reader] Remove pub from raw types No functional change, but this makes it clear which types are only used inside this file and which types are used elsewhere. --- glyphs-reader/src/font.rs | 214 ++++++++++++++++++-------------------- 1 file changed, 104 insertions(+), 110 deletions(-) diff --git a/glyphs-reader/src/font.rs b/glyphs-reader/src/font.rs index 1bc218a0..c8b46dab 100644 --- a/glyphs-reader/src/font.rs +++ b/glyphs-reader/src/font.rs @@ -249,31 +249,31 @@ pub enum Shape { #[allow(non_snake_case)] struct RawFont { #[fromplist(key = ".appVersion")] - pub app_version: i64, + app_version: i64, #[fromplist(key = ".formatVersion")] - pub format_version: i64, - pub units_per_em: Option, - pub metrics: Vec, - pub family_name: String, - pub date: Option, - pub copyright: Option, - pub designer: Option, - pub designerURL: Option, - pub manufacturer: Option, - pub manufacturerURL: Option, - pub versionMajor: Option, - pub versionMinor: Option, - pub axes: Vec, - pub glyphs: Vec, - pub font_master: Vec, - pub instances: Vec, - pub feature_prefixes: Vec, - pub features: Vec, - pub classes: Vec, - pub properties: Vec, + format_version: i64, + units_per_em: Option, + metrics: Vec, + family_name: String, + date: Option, + copyright: Option, + designer: Option, + designerURL: Option, + manufacturer: Option, + manufacturerURL: Option, + versionMajor: Option, + versionMinor: Option, + axes: Vec, + glyphs: Vec, + font_master: Vec, + instances: Vec, + feature_prefixes: Vec, + features: Vec, + classes: Vec, + properties: Vec, #[fromplist(alt_name = "kerning")] - pub kerning_LTR: Kerning, - pub custom_parameters: CustomParameters, + kerning_LTR: Kerning, + custom_parameters: CustomParameters, } // we use a vec of tuples instead of a map because there can be multiple @@ -525,34 +525,34 @@ impl FromPlist for AxisMapping { } #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, FromPlist)] -pub struct RawMetric { +struct RawMetric { // So named to let FromPlist populate it from a field called "type" type_: Option, } #[derive(Default, Clone, Debug, PartialEq, Eq, Hash, FromPlist)] -pub struct RawName { - pub key: String, - pub value: Option, - pub values: Vec, +struct RawName { + key: String, + value: Option, + values: Vec, } #[derive(Default, Clone, Debug, PartialEq, Eq, Hash, FromPlist)] -pub struct RawNameValue { - pub language: String, - pub value: String, +struct RawNameValue { + language: String, + value: String, } #[derive(Default, Clone, Debug, PartialEq, Eq, Hash, FromPlist)] -pub struct RawFeature { - pub automatic: Option, - pub disabled: Option, - pub name: Option, - pub tag: Option, - pub code: String, +struct RawFeature { + automatic: Option, + disabled: Option, + name: Option, + tag: Option, + code: String, #[fromplist(ignore)] - pub other_stuff: BTreeMap, + other_stuff: BTreeMap, } #[derive(Default, Clone, Debug, PartialEq, Eq, Hash, FromPlist)] @@ -565,33 +565,33 @@ pub struct Axis { } #[derive(Default, Clone, Debug, PartialEq, FromPlist)] -pub struct RawGlyph { - pub layers: Vec, - pub glyphname: SmolStr, - pub export: Option, +struct RawGlyph { + layers: Vec, + glyphname: SmolStr, + export: Option, #[fromplist(alt_name = "leftKerningGroup")] - pub kern_left: Option, + kern_left: Option, #[fromplist(alt_name = "rightKerningGroup")] - pub kern_right: Option, - pub unicode: Option, + kern_right: Option, + unicode: Option, #[fromplist(ignore)] - pub other_stuff: BTreeMap, + other_stuff: BTreeMap, } #[derive(Default, Clone, Debug, PartialEq, FromPlist)] -pub struct RawLayer { - pub name: String, - pub layer_id: String, - pub associated_master_id: Option, - pub width: OrderedFloat, +struct RawLayer { + name: String, + layer_id: String, + associated_master_id: Option, + width: OrderedFloat, shapes: Vec, paths: Vec, components: Vec, - pub anchors: Vec, + anchors: Vec, #[fromplist(alt_name = "attr")] - pub attributes: LayerAttributes, + attributes: LayerAttributes, #[fromplist(ignore)] - pub other_stuff: BTreeMap, + other_stuff: BTreeMap, } impl RawLayer { @@ -628,23 +628,23 @@ impl RawLayer { /// /// #[derive(Default, Clone, Debug, PartialEq, FromPlist)] -pub struct RawShape { +struct RawShape { // TODO: add numerous unsupported attributes // When I'm a path - pub closed: Option, - pub nodes: Vec, + closed: Option, + nodes: Vec, // When I'm a component I specifically want all my attributes to end up in other_stuff // My Component'ness can be detected by presence of a ref (Glyphs3) or name(Glyphs2) attribute // ref is reserved so take advantage of alt names #[fromplist(alt_name = "ref", alt_name = "name")] - pub glyph_name: Option, + glyph_name: Option, - pub transform: Option, // v2 - pub pos: Vec, // v3 - pub angle: Option, // v3 - pub scale: Vec, // v3 + transform: Option, // v2 + pos: Vec, // v3 + angle: Option, // v3 + scale: Vec, // v3 } #[derive(Default, Clone, Debug, PartialEq, Eq, Hash, FromPlist)] @@ -711,10 +711,10 @@ pub enum NodeType { } #[derive(Default, Clone, Debug, PartialEq, FromPlist)] -pub struct RawAnchor { - pub name: SmolStr, - pub pos: Option, // v3 - pub position: Option, // v2 +struct RawAnchor { + name: SmolStr, + pos: Option, // v3 + position: Option, // v2 } #[derive(Clone, Debug, PartialEq)] @@ -788,43 +788,43 @@ impl FontMaster { } #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, FromPlist)] -pub(crate) struct RawFontMaster { - pub id: String, - pub name: Option, +struct RawFontMaster { + id: String, + name: Option, - pub weight: Option, + weight: Option, - pub weight_value: Option>, - pub interpolation_weight: Option>, + weight_value: Option>, + interpolation_weight: Option>, - pub width_value: Option>, - pub interpolation_width: Option>, + width_value: Option>, + interpolation_width: Option>, - pub custom_value: Option>, + custom_value: Option>, - pub typo_ascender: Option, - pub typo_descender: Option>, - pub typo_line_gap: Option>, - pub win_ascender: Option>, - pub win_descender: Option>, + typo_ascender: Option, + typo_descender: Option>, + typo_line_gap: Option>, + win_ascender: Option>, + win_descender: Option>, - pub axes_values: Vec>, - pub metric_values: Vec, // v3 + axes_values: Vec>, + metric_values: Vec, // v3 - pub ascender: Option>, // v2 - pub baseline: Option>, // v2 - pub descender: Option>, // v2 - pub cap_height: Option>, // v2 - pub x_height: Option>, // v2 + ascender: Option>, // v2 + baseline: Option>, // v2 + descender: Option>, // v2 + cap_height: Option>, // v2 + x_height: Option>, // v2 #[fromplist(alt_name = "italic angle")] - pub italic_angle: Option>, // v2 + italic_angle: Option>, // v2 - pub alignment_zones: Vec, // v2 + alignment_zones: Vec, // v2 - pub custom_parameters: CustomParameters, + custom_parameters: CustomParameters, #[fromplist(ignore)] - pub other_stuff: BTreeMap, + other_stuff: BTreeMap, } #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, FromPlist)] @@ -839,12 +839,6 @@ impl RawMetricValue { } } -impl RawGlyph { - pub fn get_layer(&self, layer_id: &str) -> Option<&RawLayer> { - self.layers.iter().find(|l| l.layer_id == layer_id) - } -} - #[derive(Clone, Debug, PartialEq, Hash)] pub struct Instance { pub name: String, @@ -873,23 +867,23 @@ impl From<&str> for InstanceType { } #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, FromPlist)] -pub(crate) struct RawInstance { - pub name: String, - pub exports: Option, - pub active: Option, - pub type_: Option, - pub axes_values: Vec>, +struct RawInstance { + name: String, + exports: Option, + active: Option, + type_: Option, + axes_values: Vec>, - pub weight_value: Option>, - pub interpolation_weight: Option>, + weight_value: Option>, + interpolation_weight: Option>, - pub width_value: Option>, - pub interpolation_width: Option>, + width_value: Option>, + interpolation_width: Option>, - pub custom_value: Option>, + custom_value: Option>, - pub weight_class: Option, - pub width_class: Option, + weight_class: Option, + width_class: Option, } impl RawInstance {