Skip to content

Commit f9cde6a

Browse files
authored
feat: allow writing /GlyphOrientationVertical Auto (#63)
1 parent bbfe936 commit f9cde6a

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/attributes.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,12 +703,34 @@ impl TextDecorationType {
703703
}
704704
}
705705

706+
/// The orientation of a glyph when the inline-progression is top-to-bottom or
707+
/// bottom-to-top.
708+
#[derive(Debug, Copy, Clone, Default, PartialEq)]
709+
pub enum GlyphOrientationVertical {
710+
/// Orient the glyph automatically.
711+
#[default]
712+
Auto,
713+
/// An angle between -180 and +360 degrees in multiples of 90 degrees.
714+
Angle(i32),
715+
}
716+
717+
impl GlyphOrientationVertical {
718+
pub(crate) fn write(self, obj: Obj) {
719+
match self {
720+
Self::Auto => obj.primitive(Name(b"Auto")),
721+
Self::Angle(angle) => obj.primitive(angle),
722+
}
723+
}
724+
}
725+
706726
/// Vertical Text.
707727
impl LayoutAttributes<'_> {
708-
/// Write the `/GlyphOrientationVertical` attribute as an angle between -90
709-
/// and 360 in multiples of 90. PDF 1.5+.
710-
pub fn glyph_orientation_vertical(&mut self, angle: f32) -> &mut Self {
711-
self.dict.pair(Name(b"GlyphOrientationVertical"), angle);
728+
/// Write the `/GlyphOrientationVertical` attribute. PDF 1.5+.
729+
pub fn glyph_orientation_vertical(
730+
&mut self,
731+
orientation: GlyphOrientationVertical,
732+
) -> &mut Self {
733+
orientation.write(self.dict.insert(Name(b"GlyphOrientationVertical")));
712734
self
713735
}
714736
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ pub mod types {
157157
IconScale, IconScaleType, TextPosition,
158158
};
159159
pub use attributes::{
160-
AttributeOwner, BlockAlign, FieldRole, FieldState, InlineAlign,
161-
LayoutBorderStyle, LayoutTextPosition, LineHeight, ListNumbering, NoteType,
162-
Placement, RubyAlign, RubyPosition, Sides, TableHeaderScope, TextAlign,
160+
AttributeOwner, BlockAlign, FieldRole, FieldState, GlyphOrientationVertical,
161+
InlineAlign, LayoutBorderStyle, LayoutTextPosition, LineHeight, ListNumbering,
162+
NoteType, Placement, RubyAlign, RubyPosition, Sides, TableHeaderScope, TextAlign,
163163
TextDecorationType, WritingMode,
164164
};
165165
pub use color::{

0 commit comments

Comments
 (0)