diff --git a/docs/format/attributes.md b/docs/format/attributes.md index 73a1154..32c0669 100644 --- a/docs/format/attributes.md +++ b/docs/format/attributes.md @@ -82,6 +82,8 @@ styles with INDD styles of the same name (486 styles), then checked with | 0x1B0A | `StrokeWeight` | f64 | 241/241 ranges | | 0x1B0B | `Tracking` | thousandths of an em ×1000 | 49/49 ranges, 94/94 styles | | 0x1B0C | `Composer` | code: 0x2001 HL Single, 0x2002 HL Composer, 0x2078 HL Composer Optyca | 4/4 ranges, 114/114 styles | +| 0x1B0D | `DropCapCharacters` | u16 | 79/79 styles; see below | +| 0x1B0E | `DropCapLines` | u16 | 79/79 styles; see below | | 0x1B11 | `Capitalization` | 0 Normal, 1 SmallCaps, 2 AllCaps, 3 CapToSmallCap | 77/77 styles; codes 1 and 3 below | | 0x1B12 | `StrokeColor` | swatch UID | 75/75 styles | | 0x1B16 | `LeftIndent` | f64 | 22/22 ranges | @@ -96,6 +98,9 @@ styles with INDD styles of the same name (486 styles), then checked with | 0x1B2B | `AppliedFont` (Properties) | font family UID | 1,071/1,071 ranges, 236/247 styles | | 0x1B2E | `MaximumWordSpacing` | fraction ×100 | 77/77 styles | | 0x1B2F | `MinimumWordSpacing` | fraction ×100 | 77/77 styles | +| 0x1B31 | `MaximumLetterSpacing` | fraction ×100 | 78/78 styles; see below | +| 0x1B32 | `MinimumLetterSpacing` | fraction ×100 | 78/78 styles; see below | +| 0x1B37 | `StartParagraph` | 0 Anywhere, 2 NextPage | 78/78 styles; code 2 below | | 0x1B42 | `FillTint` | f64 | 24/24 ranges | | 0x1B4D | `RuleAboveLineWeight` | f64 | 155/155 ranges | | 0x1B4F | `RuleAboveOffset` | f64 | 78/78 styles | @@ -133,6 +138,47 @@ styles with INDD styles of the same name (486 styles), then checked with The converter leaves out other codes. +**Drop caps (0x1B0D, 0x1B0E).** In every pair, the root style +`[No paragraph style]` has 0 for both and IDML writes +`DropCapCharacters="0"` and `DropCapLines="0"`. One pair (InDesign 20.2, +IDML from the same version) also has a style with 0x1B0D = 1 and +0x1B0E = 3; its IDML has `DropCapCharacters="1"` and `DropCapLines="3"`. +The different values tell the two attributes apart. + +**Letter spacing (0x1B31, 0x1B32).** In every pair both are 0 in the root +style, as are `MaximumLetterSpacing` and `MinimumLetterSpacing` in the +IDML. That does not tell them apart from other attributes that are 0 +there. The rest of the evidence is a sample and its print PDF: + +- A paragraph style of the sample sets 0x1B31 to a positive fraction + and 0x1B32 to a negative one. The style sets no tracking, and its + other unidentified attributes are not fractions. +- In the PDF, justified lines in that style have a character spacing + (`Tc` operator) that changes from line to line, both positive and + negative. So the style lets letter spacing vary in both directions, + which needs a negative minimum and a positive maximum. +- The values are stored as fractions, like word spacing (0x1B2E, + 0x1B2F), so they are written ×100. The positive one is the maximum. + +A layout of the converted sample with these two attributes reproduces +noticeably more of the PDF's line breaks than one without them. + +**`StartParagraph` (0x1B37).** In every pair the root style has 0 and +IDML writes `StartParagraph="Anywhere"`; no pair has another value. Code +2 rests on a sample and its print PDF: + +- Every paragraph whose style has code 2 is the first text on its page + in the PDF, and the page before it often ends with room for more + lines. Those styles set no other attribute that is unidentified. +- Such paragraphs start on both odd and even pages, so code 2 is not + `NextOddPage` or `NextEvenPage`. +- In the sample, `NextColumn`, `NextFrame` and `NextPage` would give the + same layout, so the PDF does not tell them apart. The converter writes + `NextPage`. + +One public template without an IDML has a style with code 4; with no +reference, the converter leaves out codes other than 0 and 2. + Attributes whose value never varies in the corpus (for example `BaselineShift`, `RightIndent`) cannot be located this way and are not written; InDesign then uses its defaults. diff --git a/docs/format/objects.md b/docs/format/objects.md index 4ef70f1..c808bf2 100644 --- a/docs/format/objects.md +++ b/docs/format/objects.md @@ -420,6 +420,7 @@ From the frame's multi-column frame object (class 0x263): | 0x2D1 | u32 0 | `TextColumnCount` (1,052/1,052) | | 0x2D1 | f64 4 | `TextColumnGutter` (93/93) | | 0x2D1 | f64 14 | `TextColumnFixedWidth` (1,045/1,045) | +| 0x2CE | u16 0 | `FirstBaselineOffset`: 0 LeadingOffset, 1 AscentOffset, 2 CapHeight (below) | | 0x2CE | u16 2 | `VerticalJustification`: 0 Top, 1 Center, 2 Bottom, 3 Justify (350/350) | | 0x2CE | u16 20 | `VerticalBalanceColumns` (18/18) | | 0x2CE | u16 22 | `AutoSizingType`: 0 Off, 1 HeightOnly, 2 WidthOnly, 3 HeightAndWidth (61/61) | @@ -427,6 +428,25 @@ From the frame's multi-column frame object (class 0x263): Inset spacing is 0 in every sample and not located. +**First baseline offset.** IDML writes `FirstBaselineOffset` on a frame's +`TextFramePreference` only when it differs from the frame's object style. +Over the frames of the corpus pairs, compared with the value written on +the frame or, if absent, on its object style: + +| Code | IDML value | Frames | +|---|---|---| +| 1 | `AscentOffset` | 1,121 of 1,121 (13 on the frame, 1,108 from the object style) | +| 2 | `CapHeight` | 10 of 10 (copies of one document) | + +No pair has code 0. The evidence for it is a sample and its print PDF. In +the PDF, the first baseline in each frame with code 0 lies below the +frame's top edge by exactly the leading of that first line, for first +lines with several different leadings. Of the values in the IDML schema +(`AscentOffset`, `CapHeight`, `LeadingOffset`, `EmboxHeight`, `XHeight`, +`FixedHeight`), only `LeadingOffset` depends on the leading. The sample +also has code 3, with no evidence; the converter leaves out codes other +than 0, 1 and 2. + ## Colours (0x1F05) | Chunk | Contents | diff --git a/src/idml/mod.rs b/src/idml/mod.rs index 895496c..f2329b9 100644 --- a/src/idml/mod.rs +++ b/src/idml/mod.rs @@ -63,6 +63,8 @@ const TEXT_ATTRS: &[(u32, &str, TextKind, bool)] = &[ ]), false, ), + (0x1B0D, "DropCapCharacters", TextKind::Number, false), + (0x1B0E, "DropCapLines", TextKind::Number, false), ( 0x1B11, "Capitalization", @@ -87,6 +89,14 @@ const TEXT_ATTRS: &[(u32, &str, TextKind, bool)] = &[ (0x1B2B, "AppliedFont", TextKind::Font, true), (0x1B2E, "MaximumWordSpacing", TextKind::Percent, false), (0x1B2F, "MinimumWordSpacing", TextKind::Percent, false), + (0x1B31, "MaximumLetterSpacing", TextKind::Percent, false), + (0x1B32, "MinimumLetterSpacing", TextKind::Percent, false), + ( + 0x1B37, + "StartParagraph", + TextKind::Enum(&[(0, "Anywhere"), (2, "NextPage")]), + false, + ), (0x1B42, "FillTint", TextKind::Number, false), (0x1B4D, "RuleAboveLineWeight", TextKind::Number, false), (0x1B4F, "RuleAboveOffset", TextKind::Number, false), @@ -838,6 +848,7 @@ impl Writer<'_> { "BottomRightPoint", ]; const JUSTIFY: [&str; 4] = ["TopAlign", "CenterAlign", "BottomAlign", "JustifyAlign"]; + const FIRST_BASELINE: [&str; 3] = ["LeadingOffset", "AscentOffset", "CapHeight"]; const SIZING: [&str; 5] = [ "Off", "HeightOnly", @@ -849,6 +860,9 @@ impl Writer<'_> { .attr("TextColumnCount", p.column_count.to_string()) .attr("TextColumnGutter", num(p.column_gutter)) .attr("TextColumnFixedWidth", num(p.column_fixed_width)); + if let Some(v) = FIRST_BASELINE.get(p.first_baseline_offset as usize) { + x.attr("FirstBaselineOffset", *v); + } if let Some(v) = JUSTIFY.get(p.vertical_justification as usize) { x.attr("VerticalJustification", *v); } diff --git a/src/model/mod.rs b/src/model/mod.rs index 100a007..69a7313 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -354,6 +354,9 @@ pub struct TextFramePreferences { pub column_count: u32, pub column_gutter: f64, pub column_fixed_width: f64, + /// First baseline offset code (chunk 0x2CE, u16 at 0): 0 LeadingOffset, + /// 1 AscentOffset, 2 CapHeight. + pub first_baseline_offset: u16, pub vertical_justification: u16, pub vertical_balance_columns: bool, pub auto_sizing_type: u16, @@ -656,6 +659,7 @@ impl<'a> Reader<'a> { column_count: Cursor::new(&cols).u32()?, column_gutter: Cursor::new(&cols[4..]).f64()?, column_fixed_width: Cursor::new(&cols[14..]).f64()?, + first_baseline_offset: Cursor::new(&just).u16()?, vertical_justification: Cursor::new(&just[2..]).u16()?, vertical_balance_columns: Cursor::new(&just[20..]).u16()? != 0, auto_sizing_type: Cursor::new(&just[22..]).u16()?,