diff --git a/corpus/fixtures/pages/manifest.tsv b/corpus/fixtures/pages/manifest.tsv index 186dfc1b..36e459e0 100644 --- a/corpus/fixtures/pages/manifest.tsv +++ b/corpus/fixtures/pages/manifest.tsv @@ -196,7 +196,7 @@ OBJ-16 obj-16-fmt-13-19-box-format.pages A text box with two columns, inset marg OBJ-17 long-document.pages A 41 page A4 document in four sections: title page with a different first page, a table of contents from Heading 1 and 2, a section on a right page with facing pages (a blank left page before it) numbered from 1 with left and right footers, a two column section, a last section continuing the numbers, page number fields in every section, 8 footnotes, inline pictures in multiple, at least and exactly line spacing, square and contour wraps, a shape in the background, LD Child and an override with Space After and Left Indent 0 under a parent with both set, page breaks, a keep with next heading pushed to the next page, justified paragraphs made Public replacement for the private long document; lorem ipsum text, Liberation fonts. Pages kept the long footnote (note 7) whole on page 34 instead of continuing it on the next page. The PDF is of Pages '09 until Desk follows Pages 15.4 here (B-022). OBJ-17 obj-17-wrap.pages Floating objects with different wraps made OBJ-17 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-18 obj-18-audio-video.pages An inline audio file and an inline movie made Sound and movie made by the project (desk-tone.aiff, desk-pattern.mov, 640 x 360); the speaker picture Pages adds for the sound (AudioOnlyMovie@2x.tiff) is replaced by one the project draws, see corpus/fixtures/media. The PDF is of Pages '09 until Desk follows Pages 15.4 here (B-025). +OBJ-18 obj-18-audio-video.pages An inline audio file and an inline movie made Sound and movie made by the project (desk-tone.aiff, desk-pattern.mov, 640 x 360); the speaker picture Pages adds for the sound (AudioOnlyMovie@2x.tiff) is replaced by one the project draws, see corpus/fixtures/media. The PDF is of Pages 15.4, whose line of a sound is taller than the sound (B-025). OBJ-19 obj-19-movie-settings.pages A movie with a poster frame and repeat made Movie made by the project (desk-pattern.mov); poster frame at 16.049 s and repeat back and forth set; start and stop times were not. OBJ-20 Reduce media skipped Only about the application, its dialogs or an action: a saved document does not hold it. OBJ-21 Selecting objects skipped Only about the application, its dialogs or an action: a saved document does not hold it. diff --git a/corpus/fixtures/pages/obj-18-audio-video.pdf b/corpus/fixtures/pages/obj-18-audio-video.pdf index 94f8ed57..085c6085 100644 Binary files a/corpus/fixtures/pages/obj-18-audio-video.pdf and b/corpus/fixtures/pages/obj-18-audio-video.pdf differ diff --git a/crates/desk-layout/src/objects.rs b/crates/desk-layout/src/objects.rs index d0996db6..128be824 100644 --- a/crates/desk-layout/src/objects.rs +++ b/crates/desk-layout/src/objects.rs @@ -537,6 +537,8 @@ pub(crate) fn inline_sizes( // with its paragraph takes no room in the line (OBJ-14). let height = if hangs(o) { desk_model::Length::ZERO + } else if is_sound(o) { + o.frame.height + desk_model::Length::from_pt(SOUND_HEADROOM) } else { o.frame.height }; @@ -551,6 +553,17 @@ pub(crate) fn inline_sizes( (!sizes.is_empty()).then(|| Arc::new(sizes)) } +/// How much higher than a sound in the text Pages 15.4 makes its line, +/// in points (B-025): in the PDF of `obj-18-audio-video` the line of a +/// sound 53 points high is 7.23 points taller than the sound, while a movie +/// takes its own height. The sound stands on the baseline under that room. +const SOUND_HEADROOM: f64 = 7.23; + +/// Whether an object is a sound, whose line Pages 15.4 makes taller. +fn is_sound(object: &Object) -> bool { + matches!(&object.kind, ObjectKind::Media(media) if media.is_sound()) +} + /// Puts the objects in the text on the pages, where the lines put their /// marks: from the left of the mark, standing on the baseline (OBJ-01). pub fn place_inline_objects(document: &Document, layout: &mut DocumentLayout) {