Skip to content

2.8.0

Choose a tag to compare

@odrobnik odrobnik released this 12 Nov 10:39
· 2 commits to main since this release
df1336b

render now makes book PDFs ready for print in both engines: a title page and a contents page with page numbers, page numbers and running heads, mirrored book furniture, chapters that start on right-hand pages, and named pages with their own @page size and margins. The swift engine embeds real fonts, hyphenates, sets footnotes at the foot of the page and draws SVG images. It also lays out HTML email the way a browser does, so <td style="display: block"> columns and images inside links no longer disappear.

Book PDFs (render)

  • Title page and contents (#185, #193; #196, #202; #214, #229). --title-page starts HTML and PDF output with a title page built from --title, --subtitle and --author, like the EPUB one. --toc adds a contents page that lists the --chapter-level headings, plus --toc-depth levels below them, as links. In PDFs the page numbers are right-aligned and there are no list markers. A line holding only <!-- toc --> (or [TOC]) places the contents there, so an imprint can come first. --subtitle, --chapter-level, --toc-depth and --language now apply to HTML and PDF output too.
  • Page numbers and running heads (#186, #191; #198, #205; #200, #206; #216, #223). PDFs get a page number in the footer by default; --no-page-numbers turns it off. --running-heads puts the document title and the current chapter in the header. The title page carries neither, and pages before the first chapter have no running head.
  • Classic book furniture (#219, #231). --mirrored-heads puts the book title on left pages and the chapter on right pages, with page numbers on the outside edge, and no head on a page that opens a chapter or on the front matter. --number-from-chapter leaves the title page, imprint and contents unnumbered and makes the first chapter page 1, which the contents then list.
  • Chapters on right-hand pages (#210, #220). break-before: right, left, recto and verso insert a blank page when one is needed, in both engines. --chapter-start right|left does this for every chapter. The blank page is counted but carries no running head or number.
  • Named pages and @page rules (#211, #222; #218, #224; #217, #228; #225, #233). A block with page: <name> gets its own pages at the size and margins of @page <name>, so a wide table can sit on one landscape page between portrait pages. :first, :left and :right rules apply page by page. The WebKit engine now honours @page { size } and :left/:right margins. The swift engine takes the full margin shorthand and the per-side longhands.
  • Bookmarks (#201, #208; #232, #240). WebKit PDFs now carry the same heading outline as swift-engine PDFs. Swift outline titles come from the source text, so a heading that wraps at "Parkinson-Erkrankung" no longer gains a space.
  • Links inside the document jump inside the PDF (#189, #190). With the swift engine, footnote, citation and contents links are written as destinations in the PDF, not as external URLs.

Swift engine

  • Embedded fonts (#199, #207; #236, #238; #250, #252). Subsetted fonts are embedded by default: an installed Arial, Liberation or DejaVu face for sans-serif, serif and monospace text, in the right weight and slant. --font <file> replaces the sans-serif and serif faces, and an @font-face with a local file registers a family. A .ttc collection registers every face, so bold and italic survive. Installed families such as Iowan Old Style resolve through CoreText. Menlo, Georgia, Helvetica and the other names that have a bundled stand-in now use the installed font; the stand-in is used only when the font is missing.
  • Hyphenation (#213, #221). hyphens: auto breaks words using in-house Liang patterns for de, en, fr, es, it and nl, chosen by lang, and draws a visible hyphen at the break. Soft hyphens are no longer painted as glyphs.
  • --footnotes page (#215, #230). Notes go at the foot of the page that holds their reference, in a smaller size below a short rule, as with the WebKit engine. A line moves to the next page together with its note, and a note too long for the space left continues on the next page.
  • SVG images (#249, #251). SVG from a file or a data: URI is drawn as vector graphics, not a grey placeholder. Supported: shapes, paths, groups, transforms, fill and stroke styles, opacity, dashes, viewBox and preserveAspectRatio. Text and gradients inside an SVG are still skipped.
  • HTML email (#253). A table row's <td style="display: block">, which templates use to centre a column, is kept in an anonymous cell; before, the whole column vanished and a payment notice rendered as an empty page. A block inside a link, such as <a href><img style="display: block"></a>, is drawn and stays clickable. An inline-block holding blocks lays out as a block (side-by-side columns stack), a block-level <a href> links its content, and a block image moves to the next page whole instead of being cut.

WebKit engine

  • CSS sizes print at their size (#242, #243). font-size: 12.5pt prints at 12.5 pt, where WebKit's print shrink used to make it 13.3 pt.
  • Headings are found however they are set (#209, #237; #244, #245). Line breaks, hyphenation, letter case and the ligatures ff, fi, fl, ffi and ffl no longer hide a heading from the running heads, outline, contents page numbers or chapter-start pages.
  • Page-foot notes with :left/:right margins (#234, #239; #235, #241). There's no longer a near-empty page after every page. The title page also stays first when --footnotes page meets a named page.

Typographic punctuation (render --smart)

  • Apostrophe after a word-final s (#187, #192). A straight ' after a letter or digit is the apostrophe ’ in every language. In German, "Practitioners'" now gives ’, while 'Zitat' still becomes ‚Zitat‘.
  • No-break space after abbreviations (#188, #194). "Dr. Sturm" and "Prof. Huber" no longer break after the title, matching pandoc's smart extension.

Fixes

  • Table columns are sized by content (#197, #203). Tables with eight or more columns no longer get equal-width columns, and empty rows keep their height.
  • No blank page between the contents and chapter 1 (#195, #204) with --title-page, --toc and --page-break-before.
  • Headings stay with what follows them (#212, #227). In the swift engine, a heading followed by a list, table, quote or image is no longer left alone at the foot of a page.
  • Justified lines stretch only word spaces (#247, #248). In the swift engine, a bold run followed by punctuation no longer gets a gap before the . or :.

API

  • HTMLRenderer.renderPDFWithAnchors(…) returns a RenderedPDF (data, anchorPages, pageCount). renderPDF is unchanged and wraps it.
  • RenderOptions.pageMargins (PageMargins, one value per side); pageMarginPx now reads the top margin and sets all four. Also pageStrings, minimumPageMarginPx and pageFootnotes. PageGeometry gains margins and offsetXPx.
  • ComputedStyle.hyphens (Hyphens), .language and .page.
  • FontBook.registerCollection(data:family:bold:italic:), setOverrideFont(data:fontIndex:) and overrideFont, and embedsStandardFaces. register(data:family:fontIndex:) gains bold: and italic: with defaults. OpenTypeFont.faceCount(in:), plus familyName, subfamilyName, postScriptName, fsSelection and fsType.
  • BlockBox.linkHref.
  • EpubNavLabels and EpubNavLabels.labels(forLanguage:) are public.