diff --git a/corpus/fixtures/pages/manifest.tsv b/corpus/fixtures/pages/manifest.tsv index 36e459e..c2c5bfb 100644 --- a/corpus/fixtures/pages/manifest.tsv +++ b/corpus/fixtures/pages/manifest.tsv @@ -185,7 +185,7 @@ OBJ-09 obj-09-pen.pages A free form shape drawn with the pen tool made OBJ-10 obj-10-editable.pages A shape made editable made A shape made editable; no points were moved. OBJ-11 obj-08-11-shapes.pages Every predefined shape and a line made OBJ-11: the parametric shapes keep the default values of their parameters; the handles cannot be dragged on the blank canvas. OBJ-12 obj-12-text-in-shape.pages A shape with text inside made -OBJ-12 shape-text-cases.pages Ten floating shapes with text, default shape style (inset 8, wrap on), text Helvetica 12, each under a Helvetica 10 heading naming it, over 3 A4 pages (72 pt margins), positions in page points from the top left: (a) ovals 120x80 at (90, 100) p1, 160x100 at (90, 242) p1 and 80x120 at (90, 404) p1 with "Text inside the shape of an oval that runs over several lines"; (b) the 120x80 oval with vertical alignment Top at (90, 586) p1 and Bottom at (90, 100) p2; (c) a rectangle 120x80 at (90, 242) p2 and a rounded rectangle 120x80 at (90, 384) p2; (d) a triangle 120x100 at (90, 526) p2 and a diamond 120x100 at (90, 100) p3; (e) the 120x80 oval with only "Text inside the shape" at (90, 262) p3 made Made by AppleScript (make new shape with shape type, size, position and object text; font name and size set on the object text). Top is the default vertical alignment of shapes, so b1 stores no override; Bottom was set in the Text inspector and is stored as verticalAlignment 2. The long text overflows every shape but the 160x100 oval and is clipped; with Bottom the overflowing text is drawn from the top as with Top. The PDF is of Pages '09 until Desk follows Pages 15.4 here (B-024). +OBJ-12 shape-text-cases.pages Ten floating shapes with text, default shape style (inset 8, wrap on), text Helvetica 12, each under a Helvetica 10 heading naming it, over 3 A4 pages (72 pt margins), positions in page points from the top left: (a) ovals 120x80 at (90, 100) p1, 160x100 at (90, 242) p1 and 80x120 at (90, 404) p1 with "Text inside the shape of an oval that runs over several lines"; (b) the 120x80 oval with vertical alignment Top at (90, 586) p1 and Bottom at (90, 100) p2; (c) a rectangle 120x80 at (90, 242) p2 and a rounded rectangle 120x80 at (90, 384) p2; (d) a triangle 120x100 at (90, 526) p2 and a diamond 120x100 at (90, 100) p3; (e) the 120x80 oval with only "Text inside the shape" at (90, 262) p3 made Made by AppleScript (make new shape with shape type, size, position and object text; font name and size set on the object text). Top is the default vertical alignment of shapes, so b1 stores no override; Bottom was set in the Text inspector and is stored as verticalAlignment 2. The long text overflows every shape but the 160x100 oval and is clipped. Pages '09 drew overflowing text aligned to the Bottom from the top, as with Top; the PDF is of Pages 15.4, which sets the lines that fit a point above the bottom (B-024). OBJ-13 obj-13-text-box.pages A floating text box made OBJ-13 phase6-newsletter.pages A two page A4 newsletter in Page Layout (Blank Canvas template), positions in page points from the top left. Page 1: a rectangle 523x84 at (36, 36), fill RGB (0.098, 0.336, 0.687), no stroke, wrap none, behind a text box 499x56 at (48, 50) holding "The Desk Gazette" in Helvetica Neue Bold 36, white; a line from (36, 136) to (559, 136), 2 pt, the same blue; two linked text boxes 253x600 at (36, 150) and (306, 150) with one article of 450 words (6 paragraphs, Helvetica 11, space after 6) that flows from the first box into the second; a floating picture (test-picture.png, 96x64) scaled to 150x100 at (139, 200), inside the right side of the first column, with a drop shadow (black, angle 315, offset 5, blur 6, opacity 60%) and square wrap (largest side, extra space 9) that the article goes around; a caption text box 150x28 at (139, 306) in Helvetica Neue Italic 9, also with square wrap, largest side, extra space 9. Page 2: a text box 523x560 at (36, 60) with three equal columns (157 pt, gutter 26) holding a second article, a heading in Helvetica Neue Bold 18 (space after 6) and 400 words in 5 paragraphs (Helvetica 11, space after 6), ending in the third column; the same picture 150x100 at (316, 200), across the gutter between the second and third columns, with tight wrap (largest side, extra space 6, alpha threshold 50%) and no shadow; a rounded rectangle 240x110 at (60, 650), corner radius 15, fill RGB (1, 0.931, 0.641), 1 pt stroke in the same blue, wrap none, with "Callout: a rounded rectangle with text inside it, set in Helvetica Neue 14." made Our own text (lorem ipsum style words) and picture. Made by AppleScript (make new shape, text box and line with size, position, fill, stroke, wrap, extra space and shadow; font, size, bold, italic and color set on the object text) and by the interface: Format > Text Box > Add Linked Text Box made the second column (then moved to x 306), Insert > Choose placed the pictures, the Pages toolbar menu > Blank added page 2, the Layout inspector set the three columns, and the Wrap inspector set Text Fit (square on page 1; the inserted picture of page 2 was already tight). The dictionary's text fit is unreliable: setting it to rectangular gave tight. Wrap none is stored as no override (the Blank Canvas default has no floating wrap). Pages saves the shadow as a Core Image filter (inputDistance 5, inputAngle 315, inputRadius 6, inputOpacity 0.6), the wraps as sf:external-text-wrap (wrap-style regular for square, tight for tight, floating-wrap-type largest) and the linked boxes as an sl:textbox-chain. The test picture has no transparency, so its tight wrap follows its rectangle. The PDF is File > Export > PDF with Image Quality Best (SLPDFExportQuality 2); Pages crashed the first time that menu item was chosen (EXC_BAD_ACCESS, selector unlock) and exported on the second try, from the saved document. OBJ-14 obj-14-inline-text-box.pages An inline text box made diff --git a/corpus/fixtures/pages/shape-text-cases.pdf b/corpus/fixtures/pages/shape-text-cases.pdf index 2cb4632..394893f 100644 Binary files a/corpus/fixtures/pages/shape-text-cases.pdf and b/corpus/fixtures/pages/shape-text-cases.pdf differ diff --git a/crates/desk-layout/src/objects.rs b/crates/desk-layout/src/objects.rs index 128be82..0dc5e7e 100644 --- a/crates/desk-layout/src/objects.rs +++ b/crates/desk-layout/src/objects.rs @@ -1180,8 +1180,10 @@ impl LineSpace for ShapeSpace { /// The lines of the text of a shape, from the top of its room down, as /// many as fit (OBJ-12). Text aligned to the middle or the bottom that /// fits is laid out again lower, by half or all of the room left below -/// it; text that does not fit then starts a point lower than its first -/// line, as Pages lays it out. +/// it. Text aligned to the middle that does not fit then starts a point +/// lower than its first line, as Pages lays it out; text aligned to the +/// bottom that does not fit goes down by the room the lines that fit +/// leave, less a point, as Pages 15.4 lays it out (B-024). fn shape_lines( document: &Document, placed: &PlacedObject, @@ -1201,6 +1203,10 @@ fn shape_lines( let room = (space.height - space.inset - end).max(0.0); let lower = match (space.vertical, fits) { (VerticalAlignment::Top, _) => 0.0, + // Pages 15.4 sets the lines that fit of text aligned to the + // bottom that does not fit a point above the bottom of its room + // (B-024). + (VerticalAlignment::Bottom, false) => (room - 1.0).max(1.0), (_, false) => 1.0, (VerticalAlignment::Middle, true) => (room / 2.0).floor(), (VerticalAlignment::Bottom, true) => room.floor(),