mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 22:42:46 +00:00
Parse CJK paragraph settings in shared IDML model
This commit is contained in:
2 files changed
+48
-7
No files matched your search
@@ -26,13 +26,13 @@ pub use effects::{DirectionalFeatherValues, DropShadowValues, FeatherValues, Gra
|
||||
pub use geometry::{MAX_PATH_POINTS, PathGeometry, PathGeometryError, PathPoint, SubPath};
|
||||
pub use preferences::TextFramePreferences;
|
||||
pub use resources::{
|
||||
CharacterAppearanceValues, CharacterSpecialValues, 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, RubyValues, StrokeDefinition, StrokeStyle, StrokeStyleKind, Style, StyleGroup,
|
||||
StyleGroupWriter, StyleKind, StyleNode, Swatch, SwatchKind, TabStopValues, TextDecorationValues, TintDefinition, color_groups, inks, named,
|
||||
preference, stroke_styles, style_groups, swatches,
|
||||
CharacterAppearanceValues, CharacterSpecialValues, CharacterTypographyValues, CjkCharacterValues, CjkParagraphValues, 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, RubyValues, StrokeDefinition, StrokeStyle,
|
||||
StrokeStyleKind, Style, StyleGroup, StyleGroupWriter, StyleKind, StyleNode, Swatch, SwatchKind, TabStopValues, TextDecorationValues,
|
||||
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,
|
||||
|
||||
@@ -67,6 +67,47 @@ pub struct ParagraphBoxValues {
|
||||
pub shading_corners: Option<[(String, f64); 4]>,
|
||||
}
|
||||
|
||||
/// CJK paragraph composition settings read from an IDML style or text range.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct CjkParagraphValues {
|
||||
pub kinsoku_hang: Option<String>,
|
||||
pub mojikumi: Option<String>,
|
||||
pub kinsoku_type: Option<String>,
|
||||
pub bunri_kinshi: Option<bool>,
|
||||
pub rensuuji: Option<bool>,
|
||||
pub treat_ideographic_space_as_space: Option<bool>,
|
||||
pub kinsoku_set: Option<String>,
|
||||
pub auto_tcy: Option<f64>,
|
||||
pub auto_tcy_include_roman: Option<bool>,
|
||||
pub rotate_single_byte_characters: Option<bool>,
|
||||
pub allow_arbitrary_hyphenation: Option<bool>,
|
||||
pub grid_gyoudori: Option<f64>,
|
||||
pub paragraph_gyoudori: Option<bool>,
|
||||
}
|
||||
|
||||
impl CjkParagraphValues {
|
||||
/// Reads CJK paragraph composition properties from IDML.
|
||||
pub fn from_el(el: &El) -> Self {
|
||||
let values = Values::of(el);
|
||||
let bounded_count = |key: &str| values.num(key).map(|value| value.clamp(0.0, 1000.0));
|
||||
Self {
|
||||
kinsoku_hang: values.prop("KinsokuHangType"),
|
||||
mojikumi: values.prop("Mojikumi"),
|
||||
kinsoku_type: values.prop("KinsokuType"),
|
||||
bunri_kinshi: values.boolean("BunriKinshi"),
|
||||
rensuuji: values.boolean("Rensuuji"),
|
||||
treat_ideographic_space_as_space: values.boolean("TreatIdeographicSpaceAsSpace"),
|
||||
kinsoku_set: values.prop("KinsokuSet"),
|
||||
auto_tcy: bounded_count("AutoTcy"),
|
||||
auto_tcy_include_roman: values.boolean("AutoTcyIncludeRoman"),
|
||||
rotate_single_byte_characters: values.boolean("RotateSingleByteCharacters"),
|
||||
allow_arbitrary_hyphenation: values.boolean("AllowArbitraryHyphenation"),
|
||||
grid_gyoudori: bounded_count("GridGyoudori"),
|
||||
paragraph_gyoudori: values.boolean("ParagraphGyoudori"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Paragraph alignment, spacing, drop cap, baseline grid and composer values after the caller
|
||||
/// maps application semantics to IDML enumerations.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
|
||||
Reference in new issue
Block a user