diff --git a/src/types/mod.rs b/src/types/mod.rs index 7894e4d..5c95d93 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -18,6 +18,7 @@ mod rendering_intent; mod resolution_type; mod resource_type; mod statistic_type; +mod stretch_type; mod style_type; pub use self::alpha_channel_option::AlphaChannelOption; @@ -40,4 +41,5 @@ pub use self::rendering_intent::RenderingIntent; pub use self::resolution_type::ResolutionType; pub use self::resource_type::ResourceType; pub use self::statistic_type::StatisticType; +pub use self::stretch_type::StretchType; pub use self::style_type::StyleType; diff --git a/src/types/stretch_type.rs b/src/types/stretch_type.rs new file mode 100644 index 0000000..40b76d0 --- /dev/null +++ b/src/types/stretch_type.rs @@ -0,0 +1,46 @@ +use crate::bindings; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[repr(u32)] +pub enum StretchType { + Undefined = bindings::StretchType_UndefinedStretch, + Normal = bindings::StretchType_NormalStretch, + UltraCondensed = bindings::StretchType_UltraCondensedStretch, + ExtraCondensed = bindings::StretchType_ExtraCondensedStretch, + Condensed = bindings::StretchType_CondensedStretch, + SemiCondensed = bindings::StretchType_SemiCondensedStretch, + SemiExpanded = bindings::StretchType_SemiExpandedStretch, + Expanded = bindings::StretchType_ExpandedStretch, + ExtraExpanded = bindings::StretchType_ExtraExpandedStretch, + UltraExpanded = bindings::StretchType_UltraExpandedStretch, + Any = bindings::StretchType_AnyStretch, +} + +impl Default for StretchType { + fn default() -> Self { + return StretchType::Undefined; + } +} + +impl From for bindings::StretchType { + fn from(value: StretchType) -> Self { + return value as bindings::StretchType; + } +} + +impl From for StretchType { + fn from(value: bindings::StretchType) -> Self { + /* + * SAFETY: + * + * `StretchType` has the same repr as `bindings::StretchType` - u32 + * + * If `value` is less than Any than it is in the vaild range and can be safely + * reinterpreted as `StretchType` + */ + if value <= bindings::StretchType_AnyStretch { + return unsafe { std::mem::transmute(value) }; + } + return StretchType::default(); + } +} diff --git a/src/wand/drawing.rs b/src/wand/drawing.rs index 5810b43..a0ad764 100644 --- a/src/wand/drawing.rs +++ b/src/wand/drawing.rs @@ -24,6 +24,7 @@ use crate::{ ClipPathUnits, FillRule, GravityType, + StretchType, StyleType, }; @@ -102,7 +103,7 @@ impl DrawingWand { get_font_size, set_font_size, DrawGetFontSize, DrawSetFontSize, f64 get_font_style, set_font_style, DrawGetFontStyle, DrawSetFontStyle, StyleType get_font_weight, set_font_weight, DrawGetFontWeight, DrawSetFontWeight, usize - get_font_stretch, set_font_stretch, DrawGetFontStretch, DrawSetFontStretch, bindings::StretchType + get_font_stretch, set_font_stretch, DrawGetFontStretch, DrawSetFontStretch, StretchType get_stroke_dash_offset, set_stroke_dash_offset, DrawGetStrokeDashOffset, DrawSetStrokeDashOffset, f64 get_stroke_line_cap, set_stroke_line_cap, DrawGetStrokeLineCap, DrawSetStrokeLineCap, bindings::LineCap