diff --git a/crates/idml/src/model/mod.rs b/crates/idml/src/model/mod.rs index dcf9794e8..e96a0341d 100644 --- a/crates/idml/src/model/mod.rs +++ b/crates/idml/src/model/mod.rs @@ -26,12 +26,12 @@ pub use effects::{DirectionalFeatherValues, DropShadowValues, FeatherValues, Gra pub use geometry::{MAX_PATH_POINTS, PathGeometry, PathGeometryError, PathPoint, SubPath}; pub use preferences::TextFramePreferences; pub use resources::{ - CjkCharacterValues, ColorDefinition, ColorGroup, ColorGroupDefinition, ColorGroupMember, ColorSpace, CompositeFontDefinition, - CompositeFontEntryDefinition, EpubExportTagMap, FontDefinition, FontFamilyDefinition, FontsPart, GradientDefinition, GradientStop, - GradientStopDefinition, GradientStopValue, GraphicPart, GrepStyleValue, Ink, InkDefinition, MojikumiRow, NestedLineStyleValue, NestedStyleValue, - NestedStyleValues, OpenTypeFeatureValues, ParagraphAlignmentValues, ParagraphBoxValues, ParagraphFlowValues, ParagraphListValues, - StrokeDefinition, StrokeStyle, StrokeStyleKind, Style, StyleGroup, StyleGroupWriter, StyleKind, StyleNode, Swatch, SwatchKind, TabStopValues, - TintDefinition, color_groups, inks, named, preference, stroke_styles, style_groups, swatches, + CharacterTypographyValues, CjkCharacterValues, ColorDefinition, ColorGroup, ColorGroupDefinition, ColorGroupMember, ColorSpace, + CompositeFontDefinition, CompositeFontEntryDefinition, EpubExportTagMap, FontDefinition, FontFamilyDefinition, FontsPart, GradientDefinition, + GradientStop, GradientStopDefinition, GradientStopValue, GraphicPart, GrepStyleValue, Ink, InkDefinition, MojikumiRow, NestedLineStyleValue, + NestedStyleValue, NestedStyleValues, OpenTypeFeatureValues, ParagraphAlignmentValues, ParagraphBoxValues, ParagraphFlowValues, + ParagraphListValues, StrokeDefinition, StrokeStyle, StrokeStyleKind, Style, StyleGroup, StyleGroupWriter, StyleKind, StyleNode, Swatch, + SwatchKind, TabStopValues, TintDefinition, color_groups, inks, named, preference, stroke_styles, style_groups, swatches, }; pub use spread::{ ClippingPathValues, Graphic, GraphicChild, GraphicKind, GraphicLayerOptions, Guide, ItemChild, ItemKind, Link, MarginPreference, Page, PageChild, diff --git a/crates/idml/src/model/resources.rs b/crates/idml/src/model/resources.rs index 776ba56db..1b2e57c92 100644 --- a/crates/idml/src/model/resources.rs +++ b/crates/idml/src/model/resources.rs @@ -118,6 +118,54 @@ pub struct ParagraphFlowValues { pub start_paragraph: Option, } +/// Raw IDML character typography values before the caller resolves fonts and semantic enums. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct CharacterTypographyValues { + pub applied_font: Option, + pub font_style: Option, + pub point_size: Option, + pub leading: Option, + pub kerning_method: Option, + pub kerning_value: Option, + pub tracking: Option, + pub leading_aki: Option, + pub trailing_aki: Option, + pub tsume: Option, + pub jidori: Option, + pub leading_model: Option, + pub character_alignment: Option, + pub horizontal_scale: Option, + pub vertical_scale: Option, + pub baseline_shift: Option, + pub skew: Option, +} + +impl CharacterTypographyValues { + /// Reads the common typography attributes and properties from an IDML character range/style. + pub fn from_el(el: &El) -> Self { + let values = Values::of(el); + Self { + applied_font: values.prop("AppliedFont"), + font_style: values.prop("FontStyle"), + point_size: values.num("PointSize"), + leading: values.prop("Leading"), + kerning_method: values.prop("KerningMethod"), + kerning_value: values.num("KerningValue"), + tracking: values.num("Tracking"), + leading_aki: values.num("LeadingAki"), + trailing_aki: values.num("TrailingAki"), + tsume: values.num("Tsume"), + jidori: values.num("Jidori"), + leading_model: values.prop("LeadingModel"), + character_alignment: values.prop("CharacterAlignment"), + horizontal_scale: values.num("HorizontalScale"), + vertical_scale: values.num("VerticalScale"), + baseline_shift: values.num("BaselineShift"), + skew: values.num("Skew"), + } + } +} + impl ParagraphFlowValues { /// Writes IDML attributes for paragraph hyphenation and flow. pub fn to_attrs(&self) -> Vec<(String, String)> {