Skip to content

Commit f166d4b

Browse files
committed
Fix #55
1 parent d1d67e3 commit f166d4b

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

src/attributes.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,19 +439,43 @@ impl LayoutAttributes<'_> {
439439
self
440440
}
441441

442-
/// Start writing the `/ColumnWidths` array. The last number in the array is
443-
/// used for all extra columns. PDF 1.6+.
444-
pub fn column_widths(&mut self) -> TypedArray<'_, f32> {
445-
self.dict.insert(Name(b"ColumnWidths")).array().typed()
442+
/// Start writing the `/ColumnWidths` array. PDF 1.6+.
443+
pub fn column_widths(&mut self) -> TrackSizes<'_> {
444+
TrackSizes::start(self.dict.insert(Name(b"ColumnWidths")))
446445
}
447446

448-
/// Start writing the `/ColumnGap` array. The last number in the array is used
449-
/// for all extra columns. PDF 1.6+.
450-
pub fn column_gap(&mut self) -> TypedArray<'_, f32> {
451-
self.dict.insert(Name(b"ColumnGap")).array().typed()
447+
/// Start writing the `/ColumnGap` array. PDF 1.6+.
448+
pub fn column_gap(&mut self) -> TrackSizes<'_> {
449+
TrackSizes::start(self.dict.insert(Name(b"ColumnGap")))
452450
}
453451
}
454452

453+
/// Writer for a _column tracks attribute value_. PDF 1.6+.
454+
///
455+
/// This writer is created by [`LayoutAttributes::column_widths`] and
456+
/// [`LayoutAttributes::column_gap`].
457+
pub struct TrackSizes<'a> {
458+
obj: Obj<'a>,
459+
}
460+
461+
writer!(TrackSizes: |obj| Self { obj });
462+
463+
impl<'a> TrackSizes<'a> {
464+
/// Write the same value for all column or gap tracks.
465+
pub fn uniform(self, value: f32) {
466+
self.obj.primitive(value);
467+
}
468+
469+
/// Start writing an array of values for individual tracks. If there are
470+
/// more tracks than values, the last value is used for all remaining
471+
/// tracks.
472+
pub fn individual(self) -> TypedArray<'a, f32> {
473+
self.obj.array().typed()
474+
}
475+
}
476+
477+
deref!('a, TrackSizes<'a> => Obj<'a>, obj);
478+
455479
/// The inline alignment.
456480
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
457481
pub enum InlineAlign {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub mod writers {
114114
};
115115
pub use attributes::{
116116
ArtifactAttributes, Attributes, FENoteAttributes, FieldAttributes,
117-
LayoutAttributes, ListAttributes, TableAttributes, UserProperty,
117+
LayoutAttributes, ListAttributes, TableAttributes, TrackSizes, UserProperty,
118118
};
119119
pub use color::{
120120
ColorSpace, DeviceN, DeviceNAttrs, DeviceNMixingHints, DeviceNProcess,

0 commit comments

Comments
 (0)