Skip to content

Latest commit

 

History

History
1082 lines (1023 loc) · 125 KB

CHANGELOG-GRAVITYPDF.md

File metadata and controls

1082 lines (1023 loc) · 125 KB

GravityPDF mPDF changelog

This file lists what the gravitypdf branch (8.x-dev) changes compared with upstream mPDF. It covers everything since the branch left upstream development at 389e19e7. CHANGELOG.md is kept identical to upstream's and only lists upstream's releases.

How to read the references:

  • #N is a GravityPDF/mpdf pull request, or the issue it fixed.
  • mpdf/mpdf#N is the upstream issue or pull request a change mirrors or fixes.

Unreleased

Breaking Changes from Upstream

Read this section before upgrading from upstream mPDF. Each entry says what changed and what to do about it.

  • Fonts are no longer shipped with mPDF. The ttfonts/ directory is gone. Each font family is now a Composer package that registers itself through Mpdf\Fonts\FontRegistry and FontRegistrationInterface. mpdf/mpdf#2161 #2 #4 #7 #36 #45
    • The packages, such as mpdf/font-bundle-lite, mpdf/font-bundle-all and mpdf/font-dejavu-family, are not published yet. They live in this repository's packages/ directory.
    • To install them, add packages/ as a Composer path repository in your project.
  • Encryption uses AES-256 instead of RC4. SetProtection() writes the V5/R6 security handler from ISO 32000-2. #329
    • You need ext-openssl.
    • Passwords are read as UTF-8 and prepared with SASLprep. A password that is not UTF-8, or that holds a prohibited character, throws MpdfException.
    • Every string in the document is now encrypted. Before, some were left in the clear, including form /DA strings, /Lang and attachment names.
  • PDFAversion defaults to 2-B instead of 1-B. Set 'PDFAversion' => '1-B' to keep PDF/A-1b. #330
  • PDFX is an on/off switch. The new PDFXversion option picks the version: 4 (the default) or 1a. Set 'PDFXversion' => '1a' to keep PDF/X-1a. #324
  • percentSubset defaults to 100 instead of 30. Upstream ignores both percentSubset and maxTTFFilesize. A font is now subset when the document draws at most that share of its glyphs, or when the font is larger than maxTTFFilesize. With the defaults, output does not change. #148 #159
  • <annotation file="..."> is off by default. Set allowHtmlAnnotationFiles to true to read the file attribute. #375
  • A <select> without size is written as a combo box, as browsers draw it. #419
  • A <select multiple> without size is four rows tall instead of one, as in browsers. Content after it on the page moves down. Add size="1" to keep the old height. #437
  • The border and background shorthands reset the longhands they do not name, as in a browser, in standard mode. #552 #614
    • border, or one side such as border-top, sets the width, style and colour of each side it covers. p { border-top-color: red } p { border: 1px solid blue } used to draw a red top and now draws a blue one.
    • background sets the colour, image, repeat, position, size, origin and clip. A background-position, -repeat or -size given before a background no longer applies to its image.
    • To keep the old look, restate the longhand after the shorthand, in the same rule or a later one.
    • border keeps border-radius. background keeps mPDF's own background-image-resize, -opacity and -resolution, which it cannot set, in the same way that background leaves background-blend-mode alone in CSS. background-size: auto no longer stops background-image-resize from sizing the image.
    • A property declared twice in one block is read at its last place, so border-top-color: green; border: 1px solid blue; border-top-color: red draws a red top.
  • Dependencies changed. ext-json is now required and symfony/polyfill-intl-normalizer is a new dependency. myclabs/deep-copy is no longer used. #13 #329
  • outline-width and outline-color no longer stroke the text. mPDF read them as text-outline-width and text-outline-color, but in CSS they belong to the line around the box, which mPDF does not draw. outline-width on its own also raised an undefined-key warning. Write text-outline-width and text-outline-color, or text-outline, to keep stroking the text. #578
  • CSS rules apply by specificity, then in the order they are written, as in a browser. mPDF applied them in a fixed order of selector groups, so div p beat #id, p.c beat #i, body p beat .lead, the rule from the nearest ancestor beat a heavier descendant rule, and classes applied in alphabetical order. Now the more specific selector wins each of those, and of .a { } .b { } .a { } the second .a wins. Set 'cssMode' => \Mpdf\CssMode::LEGACY to parse and apply CSS as mPDF v7 did. #535 #631
    • Each element takes, in order: the values it inherits; the built-in defaults and the rules of the default stylesheet (defaultCssFile), which any author rule beats; HTML attributes such as <hr color>, width and vspace, as author rules of no specificity; the stylesheets; then style="".
    • Class and id names still match whatever their case.
    • An author's a { } rule now reaches the links of the table of contents and the index too. Style a.mpdf_toc_a and a.mpdf_index_link to keep them plain.
    • In legacy mode, a rule whose selector mPDF v7 could not read is dropped: child and sibling combinators, structural pseudo-classes outside tables, attribute selectors other than [lang], :lang() through an ancestor, descendant rules through inline ancestors, and :not(), :is() and :where(). The font, border and background shorthands leave the longhands they do not name, as mPDF v7 did. Fixes to how values and selectors are read apply in both modes. #633
  • !important is honoured, as in a browser, in standard mode. mPDF read a declaration marked !important as any other, so p { color: green !important } #i { color: red } drew <p id="i"> red, and so did style="color: red" on a <p>. Now an important declaration beats every declaration that is not, the inline style included. Set 'cssMode' => \Mpdf\CssMode::LEGACY to read the flag as nothing, as mPDF v7 did. mpdf/mpdf#1010 mpdf/mpdf#1707 #532 #638
    • Important declarations apply after the inline style: those of the stylesheets by specificity and then order, then those of style="", then those of the default stylesheet (defaultCssFile), as a browser's own important declarations beat a page's.
    • A shorthand marked !important makes every longhand it sets important, so border: 1mm solid green !important beats a border-top-color of a more specific rule or of a later declaration in the same block.
    • @page rules, body rules and the class rules SVG text looks up take an important declaration over a later one of the same selector that is not. An important declaration of a body rule beats <body style>.
  • HTML attributes that style an element are read only where HTML defines them, as a browser reads them, in standard mode. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the old reading. #531 #641
    • color applies to font and hr only, width to images, tables, cells, hr, meter and progress, height to images, tables, rows, row groups, cells, meter and progress, valign to rows, row groups and cells, vspace and hspace to images, and align to div, p, headings, table parts, caption, hr and img. So <a color>, <span color>, <p color>, <td color>, <div width>, <img valign> and <blockquote align> no longer do anything. mPDF's own tags, such as <barcode color>, keep every attribute.
    • A stylesheet rule beats the attribute everywhere. Before, align on a paragraph, div or table cell, nowrap on a cell, border on a table, <caption align>, <hr width> in a table cell and align on a text field beat any rule for the same property.
    • <div align> passes its alignment on to what it holds, and <li type> beats the marker the item inherits from its list.
    • Attributes mPDF ignored now take effect: <hr align>, <hr size>, <img align> (float left or right, or vertical alignment), <img border>, <thead align>, and <table border> wider than 1.
    • A table's border gives each cell a 1px border of its own, which a rule for the table's border leaves alone. Before, the cells copied the table's border.
  • line-height on an inline element sets the height of its line, as in a browser. mPDF ignored it, so <span style="line-height: 30mm"> left its line as it was. Now each inline element's box is as tall as its line-height, and a line grows to hold the tallest box on it, text or image, in blocks and table cells alike. The block's own line height is the least a line can be, so a smaller inline line-height, or 0, does not shrink it. A percentage in vertical-align is taken of the element's own line-height. line-height on a <p> or <div> inside a table cell, which mPDF lays out as inline content, can now make its lines taller than the cell's. Set 'cssMode' => \Mpdf\CssMode::LEGACY to ignore it as before. #548 #646
  • rem is read against the font size of html, in standard mode, as in a browser. It was read against the font size of body, and inside a table against the table's. Now 1rem is the default font size, from the default_font_size configuration or SetDefaultFontSize(), unless an html or :root rule sizes html: with html { font-size: 62.5% }, 1.6rem is the default size again. A body { font-size } rule no longer changes it. To keep the old sizes, give them in em or points, or set 'cssMode' => \Mpdf\CssMode::LEGACY. #529 #642
  • A border, box-shadow or text-shadow that names no colour is drawn in the element's colour, which is currentColor, as in a browser. A border was drawn black and a shadow grey (#888888). div { color: #c00; border: 1px solid; box-shadow: 2mm 2mm } now draws a red border and a red shadow. This applies to the border shorthands and to a border built from border-style or border-width alone. Name the colour, as in border: 1px solid #000, or set 'cssMode' => \Mpdf\CssMode::LEGACY, to keep black borders and grey shadows. #540 #651
    • currentColor written in background-color, a gradient stop, box-shadow, text-shadow, topntail or thead-underline is read as the element's colour too, and color: currentColor as the colour it inherits. Before, the background was not painted, the gradient lost the stop, the shadows were grey, the table lines black, and color: currentColor on a block drew black. Legacy mode ignores currentColor there as before.
  • The CSS-wide keywords inherit, initial, unset, revert and revert-layer are applied, as in a browser. mPDF read most of them as a value it did not know: color: inherit on a block or a cell drew black, font-size: inherit the default size, and border: inherit no border. Set 'cssMode' => \Mpdf\CssMode::LEGACY to read them as before. #546 #652
    • inherit takes the parent element's value, for properties that are not inherited too, such as border, padding and background. A cell takes those from its row.
    • initial gives the property's initial value, such as currentColor for a border's colour, and the document's default font and size for font-family and font-size. unset is inherit for an inherited property and initial for any other.
    • revert and revert-layer give the value of the built-in defaults and the default stylesheet, such as a heading's size, a list's margin or a cell's padding, and are unset where those give none. An HTML attribute such as cellpadding counts as an author rule, so revert goes past it too.
    • A shorthand passes the keyword to each of its longhands, so border: inherit takes every side's width, style and colour, and font: initial resets the size, family, style, weight, line height and variants.
  • A table inherits from the block around it, as in a browser, under the standard cssMode. It used to start from the document's defaults, so <div style="color: red; font-family: monospace"> around a table left its cells black and in the body's font. Now a table takes every inherited property from the block, list item, header or positioned block it is in, and a nested table takes its cell's text-align and line-height too. #543 #656
    • A table inside an inline element, as in <span class="note">…<table>…</table>…</span>, takes the element's style, as a block does since #653. The text after the table, up to the element's end tag, is drawn in that style again. Before, it lost it, and in a table cell the style ran on past the end tag.
    • table { font-size: 80% } is taken of the block's size, not the document's.
    • The built-in default style no longer gives a table line-height: 1.2, hyphens: manual and font-kerning: auto, which a browser's does not, so a table inherits them. A table in a block with no line-height of its own now takes normal, and its rows are drawn as far apart as a paragraph's lines, at normalLineheight, instead of at 1.2. To keep the old spacing, add table { line-height: 1.2; } to the stylesheet.
    • A th in a table in a right-aligned block is aligned right, since it inherits an alignment.
    • Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep tables starting from the document's defaults.
  • Text decorations propagate to descendants instead of being inherited, as in a browser. A link styled a { text-decoration: none } inside an underlined paragraph now has the paragraph's underline drawn under it. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the old output, or move the text-decoration from the paragraph to the parts of it you want decorated. #544 #654
    • An underline, overline or line-through is drawn over the text of every descendant in the flow, in the colour and at the size of the element that set it. A child block used to redraw it in its own colour and size, and lost an overline.
    • text-decoration: none on a descendant removes only a decoration of its own. A descendant's own decoration is added to its ancestors': line-through inside an underlined block is drawn with both lines.
    • An element whose color is transparent, set or inherited, adds no decoration of its own, since it would be drawn in that colour.
    • A block inside an underlined inline element, as in <span style="text-decoration: underline">…<div>…</div>…</span>, is underlined too, as is the text after it up to the element's end tag.
    • Floats, positioned blocks and inline blocks no longer take the decorations of the element they are in. Tables never did.
    • A child block no longer takes its parent's vertical-align, which is not inherited.
  • Every element inherits its parent's computed values, as in a browser, under the standard cssMode. The separate ways mPDF handed styles from a block to its children, from an inline element to a block in it, from a table to its cells and from a positioned block to its content each carried their own set of properties and values. They are replaced by one: each open element keeps the computed values of the inherited properties, and its children start from them. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the old output. #547 #683
    • A length given in em, ex, ch or rem is inherited as the length it came to, not as the unit read again at the child's size. letter-spacing: 0.1em on a 20pt block spaces the letters of a 10pt paragraph in it 2pt apart, not 1pt. inherit on a length that is not inherited, such as padding-left: inherit, takes it in the same way.
    • The content of a positioned block draws line-height: normal as the rest of the document does. It used to be drawn at a fixed 1.33, which with DejaVu Sans or Times sets the lines a little further apart. To keep the old spacing, add line-height: 1.33 to the positioned block.
    • A bidirectional embedding, as in <span dir="rtl">…<div>…</div>…</span>, is opened again for the inline element's text after the block.
  • Stylesheet rules that name sup, sub or center apply, in both CSS modes. mPDF left the three tags out of allowedCSStags, so sup { color: red }, p sub { … } and center { … } did nothing while a class rule on the same element worked. A rule's font-size and vertical-align take the place of the 55% size and the raise or drop mPDF gives the tags by default, rather than adding to them, so normalize.css's sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline } now draws them at 75% on the baseline. To keep ignoring such rules, pass an allowedCSStags without SUP, SUB and CENTER. #649 #680
  • min-width and max-width hold the width of a block, as in a browser, in standard mode. mPDF never read them on a block, so max-width: 100mm; margin: 0 auto, the usual centred container, filled the page, width: 150mm; max-width: 100mm was 150mm wide, and width: 50mm; min-width: 80mm was 50mm. Now the width is held within the two, max-width first, then min-width, a percentage taken of the container's inner width as width is, and the block's auto margins, direction or float place the narrowed box. Floats and positioned blocks take the same limits. Set 'cssMode' => \Mpdf\CssMode::LEGACY to ignore the two properties as before. #588 #691
    • box-sizing is not read, so the limits measure the content, and a block with padding and borders is wider by them. min-width and max-width on a table or cell are still not read.
  • A block wider than its container sticks out of it, as in a browser, in standard mode. mPDF cut a block's width or min-width down to the space its container left, so <div style="width: 50mm"><div style="min-width: 80mm"> drew a 50mm box, and so did width: 50mm; padding: 0 5mm in a 50mm container less its padding. Now the box keeps its width and sticks out on the right, or on the left where direction is rtl. Auto margins count as 0 when the box does not fit. A left float sticks out on the right; a right float already stuck out on the left. A block wider than the page area runs into the page margin. Text inside wraps at the block's width. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep holding blocks within their container. #552 #701
  • An image with display: block has a line of its own and is placed by its margins, as in a browser, in standard mode. mPDF kept the image inline and read an auto margin as 0, so img { display: block; margin: 0 auto }, the usual way to centre an image, did nothing. Now the line ends before and after the image, margin: 0 auto centres it, margin-left: auto pushes it to the right edge, and in a right-to-left block an image with no auto margin sits at the right. text-align does not move a block-level image, and justify leaves the line before it unstretched. Text that followed such an image on its line moves down a line. Floats, images in table cells and images inside <columns> are placed as before. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the image inline with margins of 0. #589 #693
    • A paragraph's text-indent does not move a block-level image on its first line, as the image is not part of a line of text; before, the image was shifted by the indent, and one as wide as the line ran past the page area. An image too wide for the room beside a float is narrowed in proportion, its margins kept; mPDF took the margins out of its width only, so it was drawn too tall. As mPDF narrows any image to fit, a block-level image wider than its line is narrowed rather than overflowing as in a browser. #703
  • A stream wrapper is checked for every asset fetcher, not only AssetFetcher. A fetcher from the container, or a subclass of AssetFetcher that replaced fetchDataFromPath(), could be handed phar:// and other stream wrappers from the document's HTML and CSS. mPDF now refuses them before the call, as AssetFetcher does. A scheme not registered with PHP still reaches the fetcher. If yours serves a registered wrapper such as s3://, add it to whitelistStreamWrappers. phar cannot be allowed. #864
  • Invalid UTF-8 in HTML or text no longer stops the document. The bad bytes are logged and replaced, with ? unless mb_substitute_character() says otherwise, and the document carries on. Set 'debug' => true to throw MpdfException instead. Text means what is passed to calls such as WriteText(), WriteCell(), MultiCell() and Bookmark(), and SVG text. #873

New features

PDF standards

  • PDF/X-4 (ISO 15930-7). Unlike PDF/X-1a, it keeps transparency, layers, rgba() colours and PNG alpha. #324
    • With no ICCProfile, the bundled SWOP2006_Coated3v2.icc is embedded as the output intent.
    • An imported page's device colours get a default colour space where PDF/X requires one.
    • Black converts to the black ink alone, not to all four inks.
  • PDF/A-2b, PDF/A-2u and PDF/A-3u. PDF/A-2 and PDF/A-3 documents keep opacity, alpha, soft masks, watermarks, transparency groups, layers and hidden content. CI checks every PDF/A level mPDF writes with veraPDF. #330 #357 #359 #386

E-invoices

  • Factur-X and ZUGFeRD. SetEmbeddedInvoice(new Mpdf\Invoice\FacturX($xml)) embeds the invoice XML in a PDF/A-3 document with the right file name and relationship, and writes the fx XMP schema. The conformance level is read from the XML's guideline ID, or you can pass it. #368 #512
    • mPDF does not write or validate the XML. composer.json suggests horstoeko/zugferd and easybill/e-invoicing for writing it.
  • Printing invoice XML as HTML. Mpdf\Invoice\HtmlInvoiceWriter turns Cross Industry Invoice or UBL 2.1 XML into HTML for WriteHTML(). #514 #515
    • CiiInvoiceReader, UblInvoiceReader and InvoiceReader read the XML into a plain array if you want your own layout.
    • Formatter writes amounts, dates and addresses the way a country does. It has 21 country presets.

PDF structure

  • Object streams. Set useObjectStreams to pack objects into compressed object streams with a cross-reference stream, for smaller files. It is off by default. It never applies to encrypted, PDF/A-1 or PDF/X-1a documents. #337
  • Importing PDF 1.5 files. Imported PDFs can use cross-reference streams, object streams and hybrid cross-references. The new Mpdf\Import\PdfParser reads them. #337
  • Imported links keep their look. Links on an imported page keep their border, colour, flags and QuadPoints. mpdf/mpdf#2154 #12
  • Opening on the attachments pane. SetDisplayPreferences('UseAttachments') opens the reader with its attachments pane showing. mpdf/mpdf#2142 #17
  • Safer annotation files. Annotation files are loaded through the asset fetcher, like images and stylesheets. #375
    • Only file types listed in annotationFileAllowList are embedded, and only up to annotationFileMaxSize.
    • A file that cannot be embedded becomes a text note and a logged warning. With debug on, it throws MpdfAnnotationException instead.
  • A fixed creation date. The creationDate config option sets the document's creation date, for reproducible output. #72

Fonts, emoji and text

  • Colour fonts are drawn in colour. Supported formats:
  • Emoji. Emoji are found by the rules of UTS #51 (ZWJ sequences, flags, keycaps, skin tones and tag sequences) and drawn in a font that has them. #290
  • Fonts without a GDEF table can be used with useOTL. Most emoji fonts are like this. #290
  • More OpenType lookups. Four contextual lookup formats that mPDF used to refuse are now applied, including coverage-based GSUB context substitution. #79 #82
  • Unicode 18.0.0. The character, script, joining and emoji tables are generated from Unicode 18.0.0. Upstream's tables date from Unicode 6.1 and 6.2. The OpenType language system table is generated from HarfBuzz's. #103 #227 #261 #265 #273

Images

  • Rounded images. Images take CSS border-radius, including per-corner, elliptical and percentage radii. The picture, its background and its border all follow the curve. #70
  • Exif orientation. Set useImageExifOrientation to turn JPEGs the way their Exif Orientation tag says, as browsers do. It is off by default. imageJpegQuality sets the quality of the re-encoded image. #35 #51

Forms

  • Appearance streams. Every active form widget has its own appearance stream, so viewers draw the field as mPDF laid it out. #387
  • CSS styling. Form fields take their CSS colour, background and border. Static fields draw them, and active fields use the border's width and style. #442 #469
  • Static list boxes. A static list box is drawn as rows of options, with the selected rows highlighted. #446

Paged media

  • break-before, break-after and break-inside. They are read as their page-break-* equivalents: page as always, recto and verso as right and left, and avoid-page as avoid. Column and region breaks are not page breaks, so they are read as auto. #552 #569
  • Side margins on :first, :left and :right pages. The :first, :left and :right pages of an @page rule, named or not, can set margin-left and margin-right. Text flowing from page to page is set in the page area of each page, and columns are laid out across it. A side margin on a pseudo page belongs to that side of the physical page, so it is not mirrored. #476 #510
    • Text beside a float, and the blocks around it, keep to the page area of each page the float runs over. #549
    • A block with a set width keeps its place in each page area: a centred block stays centred, and a block pushed right by margin-left: auto or set right to left stays against the right margin. #550 #551 #553

CSS

  • An id written with classes. Selectors such as p#note.warning, p.warning#note, #note.warning and p.a.b#note match, on their own and as parts of descendant rules, in any order of id and classes. They are applied after p#note. A selector with a class or id followed by something mPDF cannot match, such as .a:hover or #note::before, is dropped like any other selector mPDF cannot match. #527 #568
  • Child and sibling combinators, and structural pseudo-classes. div > p, h1 + p, h1 ~ p, and :first-child, :nth-child(), :first-of-type and :nth-of-type() on any element, are matched against the elements open around the one being styled. Rules using them were dropped before, so a document that has them changes. They are applied with the descendant rules, after them, in order of specificity and then of source order. mpdf/mpdf#7 mpdf/mpdf#318 #538 #620
  • Descendant rules through inline elements. A descendant rule whose ancestor is an inline element, a block inside a table cell, or the tbody a table leaves out, such as span em, or .note b for a <span class="note">, applies. mpdf/mpdf#830 #538 #621
  • Attribute selectors and :lang(). [a], [a=v], [a~=v], [a|=v], [a^=v], [a$=v] and [a*=v], with the i and s flags, match as in HTML: case-insensitively for the attributes HTML lists as such, and case-sensitively for the rest. :lang() matches the language an element inherits, from an ancestor or from the <html> or <body> tag. mpdf/mpdf#134 mpdf/mpdf#1838 #538 #627
  • :not(), :is() and :where(). Each takes a selector list whose selectors may have combinators, such as p:not(.note, div > p) or :is(h2, h3) + p. :is() and :where() leave out a selector they cannot read, as browsers do. :not() and :is() weigh as their most specific argument, and :where() as nothing. Rules using them were dropped before. #538 #628
  • Pseudo-classes that look at what follows an element. :last-child, :nth-last-child(), :only-child, :last-of-type, :nth-last-of-type(), :only-of-type and :empty match in the flow, in tables, headers and footers, and positioned blocks. Rules using them were dropped before, so a document that has them changes. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep dropping them. #537 #634
    • WriteHTML() reads ahead through the HTML it is given to count each element's children. An element still open at the end of a call that leaves it open is not known in full, so these do not match its children in that call, and nor does :not() of them.
    • :empty matches as in browsers: an element holding white space is not empty, and one holding only a comment is. A table cell holding only white space is empty, as mPDF strips it.
  • :root, html, :link and :any-link, in standard mode. a:link and :any-link match a link with an href. mPDF has no html element, so html and :root match it as the parent of body: their rules reach the text as a parent's would, and rules for body win over them. :visited, :hover, :focus, :active, :focus-within, :focus-visible and :target never match, as a PDF is never visited or hovered, so :not(:hover) always does. Rules using them were dropped before, so a document that has them changes. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep dropping them. #529 #642
  • The universal selector. * matches every element: alone, with a class, an id, an attribute or a pseudo-class, on either side of a combinator, and inside :is(), :where() and :not(). It weighs nothing, so any rule naming a tag, class, id, attribute or pseudo-class beats it. It reaches html and body too, so * { color: … } colours text written straight into the body, and * { font-size: … } sets the size rem is read against. Rules using it were dropped before, so a document that has them changes. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep dropping them. mpdf/mpdf#312 mpdf/mpdf#1168 mpdf/mpdf#1838 #530 #644
    • A reset such as * { margin: 0; padding: 0 } now takes away the default margins of paragraphs, headings and lists, a list's indent and a cell's padding, as in a browser. It reaches the lines of the table of contents and the index as well, which are the document's elements, so their levels are no longer indented. Style div.mpdf_toc_level_1 and the like to indent them again.
    • mPDF's own <barcode>, <dottab> and <textcircle> are not HTML elements. A rule reaches them only by naming their tag, or an id or class they carry, so *, and :empty, [attr] or :not() alone, leave them as they are: :empty { display: none } does not hide a barcode.
  • Font weights as numbers, bolder and lighter, and font-size: larger and smaller. In the standard CSS mode, font-weight takes a number from 1 to 1000, and bolder and lighter step from the parent's weight by the table in CSS Fonts. The weight is inherited as a number, so bolder inside bolder gives 900 and lighter inside 700 gives 400, and h1 { font-weight: lighter } is regular, one step down from its parent's 400. A weight above 500 is drawn with the family's bold face and any other with its regular face. larger and smaller multiply and divide the parent's size by 1.2. A form field reads them against the document's size, as it reads its other font sizes. The font shorthand's weight is read the same way. All of these were ignored before, so a document that has them changes. Set 'cssMode' => \Mpdf\CssMode::LEGACY to read only normal and bold, as before. #545 #647

Performance

  • Long documents of floats. Floats the layout has already passed are dropped, so each new row no longer rescans every earlier float. A 250-row grid of floats renders about four times faster. #9
  • Chaining context fonts. A font with thousands of chaining context subtables shapes in a fraction of a second. Before, it never finished. #98
  • OpenType subtables are decoded once per document instead of on every glyph they are offered, including GPOS context positioning and mark-to-base. #314 #323
  • Ligatures and marks. Ligature and mark records are renumbered by walking the records instead of the whole run. #313
  • Line measuring. Each character of a flowing block is measured once instead of being decoded again for its width. Each chunk of a line is measured once, and count() calls are taken out of the layout loops. #312 #345
  • Font substitution. A text token is split into all of its font substitution runs in one pass instead of one run per pass. #336
  • CJK output. The subset fonts of a CJK document are written without rereading the font for each one. #311
  • Image metadata. JPEG and PNG metadata is read from the file's structure instead of by scanning the whole file, and PNG chunks are read from a chunk index. #47 #48
  • GD memory. GD asks for less memory when it re-encodes an image. #49
  • nth-child rules in tables. Each row and cell looks up the nth-child rules the stylesheet uses by their keys, instead of running a regex over every rule. A 2,000-cell table under 1,000 rules is written in about 540 ms instead of 745 ms. Class combinations are built only up to the most classes one compound selector names, not one whole selector. #526 #580
  • Selector matching. A chain of descendant combinators stops trying ancestors once none left can match, instead of trying every combination of them, and a general sibling combinator skips a tag the parent has no child of and looks from the first sibling. .x div div div div div p is matched on a path 50 deep in well under a millisecond instead of 4 seconds, and h2 ~ p against 5,000 paragraphs after an <h2> in 20 ms instead of 5 seconds. #535 #631
  • Finding <style> and <link>. The stylesheets in the HTML are found in two passes, one before HTML comments are removed and one after, instead of up to six. The search for a tag also steps over up to 16 other tags in one attempt instead of starting again after each. On a 1 MB table with one <style> and one <link>, reading the stylesheets takes about 2.5 ms instead of 7.7 ms with PCRE's JIT, and 30 ms instead of 80 ms without it. #781 #800
  • Line breaking and colours. A flowing block works out the width a line may take, after its text-indent, a dot tab's outdent and the floats beside it, once per line instead of once per character. SetColor() keeps the operator it builds for each colour instead of formatting it each time a colour is set. A 57-page document of justified paragraphs renders about 10% faster, and pages of bordered boxes about 7%. #843
  • Character ranges. Substitution reads which characters a backup font has from a small file instead of the font, so only the font it uses is loaded. Every font package ships them beside its fonts, mPDF writes one into the font cache for any other font the first time it builds its metrics, and vendor/bin/mpdf-font-ranges writes one for a font package of your own to ship. #827
  • Packaged fonts. TrueType hinting is removed from the 51 packaged fonts whose licences allow it: Aboriginal Sans, Ayar, DejaVu, GNU FreeFont, Garuda, Khmer OS, Lohit Kannada, MPH 2B Damase, Pothana 2000, UnBatang and XB Riyaz. Those files are 10.94 MB (24.3%) smaller, and PDFs embedding them about 24% smaller, with the same outlines and metrics. utils/dehint_fonts.py holds the list. [#850] [#853]

Bugfixes

Layout and CSS

  • page-break-inside: avoid now moves the whole block to the next page when it does not fit. Its text, list numbers, floats, links, bookmarks, index and contents entries, form fields and annotations each appear once, on the page the block ends up on. A block that fits is laid out only once. #38 #43 #60 #63
  • A table with no background left the next table painted twice. #43
  • @page { size: A4 }, or a size of two lengths with no margin, gave 63 pages with one character on each. A page-size name such as A4, letter or A5 landscape now sets the sheet, as a browser sets the paper, and the space around a page box given as two lengths is no longer counted twice. mpdf/mpdf#1220 #552 #562
  • @page { size: landscape }, or a page box wider than it is tall, left the first page portrait, and size: portrait left a landscape document landscape. The first page now turns. A page box and percentage margins are measured on the turned sheet, so size: 250mm 150mm on A4 is no longer cut to 210 mm wide. #552 #562
  • page-break-before: auto or avoid on a block inside another block closed the outer block and opened it again, so its border was drawn around each part. page-break-after: auto or avoid on a table started a new page. #552 #569
  • page-break-before on a table was ignored. On a top-level table, always, left and right now start it on a new page, inside the blocks around it. #552 #622
  • page-break-before: always and page-break-after: always on a table row were ignored; only avoid was read. A row of a top-level table now starts a new page, with the header and footer rows repeated. A break before the first body row, on a header or footer row, or in a nested table is left to the table around it. A <tfoot> written before the <tbody> moved the rows' break markers onto the wrong rows. #552 #591 #690
  • page-break-before: left or right on a table row started the next page, whatever its side. With mirrored margins the row now goes on to the next left or right page, leaving a blank page between where needed, with the header and footer rows on the page the row lands on. page-break-after: always on the last body row did nothing; it now starts a new page after the table, as the table's own page-break-after does. #552 #700
  • A table with a font-size and a row with text-rotate threw a TypeError on PHP 8, and raised a warning before it. A cell whose font size was already in force saved its text with an empty size. #632 #631
  • A border colour mPDF cannot read, such as border-color: initial in the legacy CSS mode, raised "Trying to access array offset" warnings when the border was drawn. #546 #652
  • An image with a vertical-align mPDF does not read, such as a length or, in the legacy CSS mode, inherit, raised undefined-key warnings. It now sits as if none were given. #546 #652
  • background-size: cover scaled by the wrong ratio when the image came out shorter than the area. mpdf/mpdf#833 #22
  • Only double-quoted attributes were read. Single-quoted, unquoted and bare attributes are now read as well. mpdf/mpdf#2030 #24
  • A > inside a quoted attribute value, such as style="font-family: 'a>b'", title="1 > 0" or a link to …?q=a>b, left the whole page blank with autoScriptToLang on, and was deleted from the value otherwise, along with any <. A quoted value is now read whole, as a browser reads it, and reaches the tag unchanged in either cssMode, including in a tag that closes itself, where <input value="a > b"> showed a /b and a bookmark titled a > b read a / b. A stray quote in an unquoted value, as in <img src=a.jpg" width="84">, no longer swallows the tags after it up to the next quote. #552 #745 #761
  • A quoted attribute value holding name=value was cut at the =: <bookmark content="Set x=1 first" /> was titled Set x=, a text field showed the same, and a link whose title held href= lost its link. An apostrophe in an unquoted value, as in title=don't, also ended it. Attribute values are now read as written, in either cssMode. #771 #773
  • An attribute ending in the name mPDF looked for was read in its place: <htmlpageheader data-name="x" name="main"> was registered as x, and a <body> took its style, dir or lang from data-style, data-dir or data-lang. A <meta> keywords, author or description holding x=1 was cut at the =, one single-quoted was not read, and a <title> holding a=1 gained quotes. These tags now read their attributes by name, quoted or not. #772 #774
  • A > inside a quoted attribute value still ended a tag that mPDF reads before drawing. A table whose summary held one lost its caption and raised three warnings, and with use_kwt a heading whose title held one was not kept with its table. Text after a title="draw <svg>" disappeared up to the next inline SVG, as did that SVG. An SVG in a style attribute's data URI left ')"> drawn as text. The newlines of an annotation were joined after the >. An SVG text element with one in an attribute was drawn blank under svgAutoFont. An index entry was split at a : inside a tag. A <pre> or <style> written inside another tag's value was taken for one, so a real <pre> after it lost its line breaks and an HTML comment after it was drawn. A custom element such as <svg-icon> was taken for an <svg>, and a <title> with attributes was not read. A <base>, <link> or <style> with one in an attribute was not read. The <base>, <html>, <link> and <style> tags now read their attributes by name, quoted or not, so a data-href, data-lang, data-dir or data-media is no longer taken for href, lang, dir or media. #768 #776
  • A <title> in the <body>, in a table cell, in an HTML header, or in the <head> of HTML with no <body> tag was drawn as text where it stood. It is no longer drawn, as in a browser, and the first one still gives the document its title. #782 #787
  • The caption of a table with another table in a cell was drawn inside that cell, after the inner table, under caption-side: bottom. It is now drawn below the whole table. #780 #784
  • A <!-- or <script> inside a quoted attribute value, such as a title, hid everything after it up to the next real comment or script. A text field whose value held a comment, <br>, <wbr>, <dottab>, an empty <tr></tr>, a <table> with a <caption> or </tts><tts> showed it changed or emptied, and the caption was drawn as text after the field. Comments, scripts and the tags mPDF rewrites before reading the document are now found only outside tags. #777 #789
  • A run of spaces inside a quoted attribute value was collapsed to one: <bookmark content="Total: 42" /> was titled Total: 42, and a text field, index entry, annotation, watermark or title written with several spaces lost them. Spaces are now collapsed only between tags, so a value keeps them as written. #788 #797
  • An end tag with a space, a newline or an attribute before its >, such as </style >, did not end its element, though a browser reads it as </style>. The stylesheet was not applied and the text up to the next </style> was lost. An inline SVG was not drawn, or swallowed the content up to the next </svg>. A <title> was not read, or took in the markup up to the next </title>. A <pre> or <textarea> lost its line breaks, an empty <textarea> was not drawn, a table's <caption> was not drawn and raised three warnings, and an <htmlpageheader> or <htmlpagefooter> was drawn in the body and raised a warning. With use_kwt, a heading was not kept with its table, and with allow_charset_conversion the charset of the <head> was not read. An SVG file ending </svg > was not recognised as an image, a gradient that borrowed the stops of one ending </linearGradient > was not drawn, and with list_auto_mode set to mpdf a nested list ending </ol > left room for its markers as if the items after it were its own. #802 #805
  • A shadow colour written without spaces, such as rgba(255,0,0,0.5), fell back to grey. Whitespace in shadows is now parsed as CSS writes it too. #25
  • A border that draws nothing was described with fewer keys than one that draws, and the border code read the missing keys anyway. mpdf/mpdf#1892 #29
  • A <tr> border was read for sides the row did not set. mpdf/mpdf#1893 #30
  • A <li> with no list around it raised undefined-key warnings. It now gets the styles a list would have set. mpdf/mpdf#1890 #31
  • A font size of zero divided by zero in the letter- and word-spacing calculations. mpdf/mpdf#1888 #32
  • An empty <textarea> lost the placeholder space it needs to be drawn. mpdf/mpdf#1735 #33
  • A fixed-position block that shrinks to fit was drawn in the font the previous fixed-position block left behind. mpdf/mpdf#2174 #11
  • Descendant rules such as .box p did not reach the content of an absolutely or fixed positioned .box. #474 #493
  • Descendant rules naming a table, row or cell, such as td img or td span, matched nothing inside the cell. #223 #507
  • A descendant rule with a part mPDF cannot parse was cut short at that part and applied to the element before it. Such rules are now dropped. #519
  • An inline style with !important drew no border for a border shorthand, dropped the bottom padding of a two-value padding, drew text at 0pt for a font-size, and ignored an image's height with a warning. The flag is now removed, as it is from a stylesheet. mpdf/mpdf#1010 mpdf/mpdf#1707 #523 #561
  • A declaration whose flag had a space after the bang, such as margin: 5mm ! important, kept the flag in its value: that margin set the right and left margins to ! and the bottom one to important, a font-size was lost, and a border drew nothing. The flag is now found whatever its spacing and case, in stylesheets and inline styles, in either cssMode. #532 #638
  • With cssMode standard, an !important declaration in a plain @page rule lost to a plain one in a @page :first, :left, :right or named page rule, so @page { margin-top: 30mm !important } @page :first { margin-top: 10mm } gave the first page a 10mm top margin. The important declaration now wins, as a named page's does over its own :first, :left and :right pages. Of two important declarations, the one in the rule applied later wins, as before, and the default stylesheet's (defaultCssFile) beats the document's. A plain @page side margin is still mirrored, so on a left page an important margin-left is the right margin, and beats the margin-right of a :left rule. Legacy mode is unchanged. #532 #640 #679
  • Text styled with the font shorthand or <font face> came out as empty boxes when the family was not installed or had a space in its name, such as font: 12pt Roboto or font: 16px "DejaVu Sans Mono". It was drawn in the first registered font, which is the emoji font in a full install. The family is now read as font-family reads it: a name is kept whole, the list is tried in order, and when mPDF knows none of it the text keeps the family it inherits. font-family itself also reads an unquoted name with spaces whole. #552 #560
  • A descendant rule ending in :lang() or [lang], such as div :lang(fr), div p:lang(fr) or table [lang=fr], never applied. It now applies in block content and in tables, and a regional language such as fr-CA falls back to the rule for fr, as the simple lang rules do. #525 #559
  • A rule such as td:nth-child(2):not(.x) or td:nth-child(2 of .x) was applied to the second cell of every row, as if it were td:nth-child(2). A rule with anything after an nth-child argument, or with an argument that is not a formula, is now dropped. mpdf/mpdf#83 #522 #564
  • rgb() and hsl() written with spaces, such as color: rgb(255 0 0), threw a TypeError out of WriteHTML(), or drew the wrong colour with warnings. They are now read, with a slash before the alpha (rgb(255 0 0 / 50%)) and with the hue in deg, grad, rad or turn. #552 #563
    • A percentage alpha, as in rgba(255, 0, 0, 50%), gave an opacity above 1, which viewers draw opaque.
    • A fourth argument to rgb() or hsl() is read as the alpha instead of being dropped.
    • border-color: rgb(255, 0, 0) or cmyk(0, 100, 0, 0), with spaces after the commas, drew black.
  • A declaration mPDF cannot read replaced the value before it. A calc(), min(), max(), clamp() or var() length became 0, so margin: calc(…) removed the default margins, and a colour mPDF does not know, or one written with var(), drew the text black. Such a declaration is now dropped, as a browser drops it, so the earlier declaration, the default or the inherited value applies. #552 #565
  • vw, vh, vmin, vmax, Q and ch were read as pixels, +5mm and 1e+1mm as 0, and 1,5mm as 1mm. The units are now resolved against the page and the font size, the numbers are read, and 1,5mm is dropped. #552 #565
  • line-height: 0 gave lines a normal height. Lines now have no height, as in a browser. A line height well below the font size, such as 0.5 or 1mm, was stretched down to the baseline; it is now kept. A negative line-height, which shrank lines to odd heights, is now ignored. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the old reading of all three. #552 #567 #643
  • The rule after an @supports, @layer, @keyframes, @container or other block at-rule was lost, and so were the rules inside @supports and @layer. The rule after @charset, @namespace or @import was lost too. @supports and @layer blocks are now unwrapped as @media blocks are, except @supports not, and other at-rules are removed whole. #524 #566
  • @media was matched by looking for the word print, so @media not print applied, orientation was ignored and min-width never matched. Media queries are now evaluated for the print medium against the page current when the stylesheet is read: media types with not and only; and, or and not conditions; and width, height and orientation, with min-/max- prefixes and range syntax such as (width >= 600px). An A4 page is about 794px wide, so @media (min-width: 768px) rules now apply to it. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep matching by the word print or all. #552 #575 #643
  • @import ignored its media list, and did not load a URL that does not end in .css, such as a Google Fonts stylesheet. Legacy mode loads them as before, except that in either mode an @import is read only from <style> blocks and stylesheets, not from the body text. #552 #575 #643
  • A brace, semicolon or comment marker inside a quoted string, an unquoted url() or an escape broke the stylesheet around it. q { quotes: "}" } lost the rule after it, font-family: 'a;color:red' set the colour, a /* in one string and a */ in a later one removed every rule between them, and @import url(…?family=Inter:wght@300;400) lost the rule after it. A rule or at-rule nested in a block, as CSS nesting writes them, lost the rest of the block and the rule after it. Stylesheets are now split by a tokenizer that reads strings, url(), escapes and comments as CSS does, in either cssMode. A rule or at-rule nested in a block is left out, and the declarations after it apply. #536 #635
    • A string left open ends at the line break, as in CSS. A block or comment left open ends with its <style> or stylesheet file instead of running into the next one.
    • A byte order mark at the start of a stylesheet, as WriteHTML(file_get_contents('style.css'), HTMLParserMode::HEADER_CSS) passes one on, no longer spoils the first rule.
    • An @import is loaded only from the stylesheet's own rules, not from a comment, a string or a block.
    • A style attribute is split the same way, so style="font-family: 'a;b', serif; color: red" applies both, and a value may run over several lines.
  • An HTML comment between two words drew a space: Book<!-- x -->keeper read "Book keeper", and <p><!-- x --></p> held a space. A comment now leaves nothing in its place, as in a browser and as HTMLParserMode::HTML_BODY already had it, in either cssMode. A document that relied on the space can put one next to the comment. #636 #637
    • In the default parser mode, a <!-- inside a <script>, as in var s = "<!--", drew part of the script and lost the text up to the end of the next comment.
    • In HTMLParserMode::HTML_BODY, a <script> tag inside a comment lost the text up to the next script's end.
  • td:nth-child() and th:nth-child() counted grid columns, so a colspan or rowspan before a cell made the rule miss it and reach the cell after. They now count the cells of the row. :first-child on a tr, td or th now works, as :nth-child(1). #528 #572
  • Some colour values were read wrongly. #552 #570
    • #rgba was read from the wrong digits: #f008 drew rgb(240, 8, 0). #rrggbbaa dropped its alpha. Both are now read with their alpha.
    • A channel outside its range wrapped instead of being clamped: rgb(255.5, 0, 0) drew black and rgb(300, 0, 0) dark red. Channels, alphas, and hsl() saturation and lightness are now clamped, as CSS does.
    • rebeccapurple was missing. mPDF's violetred, which is not a CSS colour, is kept.
  • A list-style-image whose URL had capitals, such as url(img/List-Bullet.png), drew no marker on a case-sensitive disk or server, because the URL was lowercased before the image was fetched. The URL now keeps its case. #552 #623
  • The border shorthand drew nothing when its parts came in some orders, such as border: solid #c00 2mm, 2mm #c00 solid or red 2mm solid. The width, style and colour of border and of each side are now read in any order. #552 #583
    • A lone colour, as in border-top: #f00, was read as the width.
  • The background shorthand lost a colour written after url() and misplaced the image, and lost a size after the position (center / cover). Its colour, image, position and size, repeat, attachment, and origin and clip boxes are now read in any order. #552 #583
    • With several layers, mPDF still draws only the first, now over the colour given in the last.
  • A border or background shorthand with a part that is none of its parts, such as border: 1px solid bogus, is dropped, as a browser drops it, so the value it would have replaced still applies. border: 1px solid bogus used to draw a black border. #552 #583
  • tr:nth-child() counted the rows of the whole table less its header and footer rows, so a second <tbody> carried on the count of the first, and tr:first-child missed the first footer row when <tfoot> came after the body. Rows are now counted within their <thead>, <tbody> or <tfoot>, or within the run of rows written straight into the table. #528 #582
  • Under the legacy cssMode, a table cell, row or row group whose end tag was left out passed the descendant rules it matched on to the parts after it. With tr:nth-child(2) td { color: red }, every row after the second of <tr><td>A<tr><td>B<tr><td>C was red too, and a .totals td rule for a <tbody class="totals"> with no </tbody> coloured the next row group's cells. A <td> or <tr> now closes the open cell and row, and a <thead>, <tbody> or <tfoot> the open row group, whether the table is written straight into the body or into a block, and whether or not the cell holds a block such as a <p>. A </table> closes a row group left open too, which in a nested table let its rules reach the outer table's rows. In both modes, the rows after the first of a <thead> written without end tags inside a block were left out of the header that repeats on each page. #630 #682
  • currentColor in a border raised two "Uninitialized string offset" warnings for each side and drew it black, and in text-outline it raised an undefined-key warning and drew black. Both are now drawn in the element's colour, set or inherited. #540 #651
  • Colours that convert to nothing were drawn black or grey instead of drawing nothing. #552 #540 #651
    • A transparent side of a border, as in Bootstrap's border: 1px solid transparent, was drawn black, with warnings on a block. It now takes its width and draws nothing, on blocks, inline elements, table cells and images.
    • border-style: hidden on a block or an image drew a black hairline, with warnings.
    • color: transparent drew black text. The text is now laid out and written in the invisible text rendering mode, so it takes its place and can be selected but is not seen. Its text-shadow is still drawn.
    • A box-shadow or text-shadow in transparent was grey. It is no longer drawn.
  • font: small-caps 14pt serif drew the text in full-size capitals, as text-transform: uppercase does. It is now drawn in small capitals, as font-variant: small-caps draws it. The font shorthand also kept a line-height and a font-variant it inherited; like the style and weight, in standard mode they are now reset to normal when the shorthand does not name them, as in a browser. To keep a line height, give it in the shorthand, as in font: 14pt/1.5 serif, or declare line-height after it. A font shorthand with a negative line height, such as font: 12pt/-1 serif, is dropped whole. font-variant: normal now resets font-variant-position as well. #552 #581
  • A percentage width, min-width or max-width on an image in a table cell was resolved against the block around the table, not the cell. In a 60mm cell, max-width: 20% came out as 36mm. #223 #505
  • An @page :left or @page :right rule was ignored unless the style sheet also had a plain @page rule. With one, the margins of a :right rule were applied to left pages too. #555 #556
  • When a later WriteHTML() call turned the document right to left, the text on the page already started was set between the swapped side margins. That page now keeps its margins, and the swap starts with the next page. #554 #558
  • Balancing columns raised a warning and drew a block's closing background past the last column. #475 #488
  • Inside <columns>, a block with an rgba() or cmyka() background was painted fully opaque. #482 #498
  • A table with a background on the table, a row or a cell, drawn first in a <columns> column, raised an "Undefined array key" warning. #552 #743
  • Inside <columns>, a block with a border and no background raised Undefined array key "bgcolorarray" warnings when it held a table, one for each row and repeated header, or a block with an rgba() background, one for each line. A block whose background sets no colour, such as background-color: transparent or background: none, raised one inside any block with no background. #552 #748
  • In a UTF-8 document, CSS naming chelvetica, ctimes or ccourier did not draw in the core font. #467 #468
  • The U+200B the line breaker inserts was drawn. #28
  • A zero-width space was drawn, and gave no line break, in core fonts and in text written outside WriteHTML(). #463 #503
  • When a hyphenation hyphen moved to the next line, its record stayed on the line before. In a bidi paragraph that drew a hyphen in the wrong place and dropped the one that moved. mpdf/mpdf#1831 #145
  • A hyphen inserted at a line break had no bidi direction. It now takes the direction of the word it breaks. #116 #137
  • $extgstates had no default, so count() on it threw a TypeError on PHP 8. mpdf/mpdf#2135 #20
  • rotate: 90deg on a positioned block turned it on PHP 5.6 to 7.4 but not on PHP 8, where "90deg" == 90 is false. The angle is now read as tables read it: whole degrees, with or without deg, so 270deg turns the block as -90 does. A positioned block also takes 180deg as it takes 180. #579
  • background-size lengths such as 60mm or 100px drew the image 2.83 times too small, because they were used as points. #574
  • A stylesheet url() did not load its image when the path had spaces or parentheses, when there was whitespace inside the parentheses, or when it was an SVG data URI that is not base64, such as Bootstrap's form-select arrow. #573
  • linear-gradient(to bottom, …) and to top were drawn upside down, and so was the vertical half of to bottom right and the other corners. Angles ran counter-clockwise from pointing right, so 90deg drew bottom to top. A gradient now runs as CSS Images gives: 0deg points up and angles turn clockwise, turn is read, and a corner keyword leaves the other two corners halfway along. -moz-, -webkit- and -o- gradients keep their legacy angles, and their side keyword, such as left, names the side the gradient starts from. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the directions mPDF v7 drew, prefixed or not. #577 #639
  • linear-gradient(red 0, blue), radial-gradient(red 0, blue) and repeating-radial-gradient(red 0, blue 10px) drew solid blue. A first colour stop whose position is a unitless 0 was taken for the gradient's angle and dropped. The first argument is now a stop whenever it starts with a colour; a bare 0 is still the angle. #552 #584 #689
  • radial-gradient(at 10px 0, red, blue) and -moz-radial-gradient(10px 0, red, blue) were centred halfway down the box instead of on its top edge, and -moz-linear-gradient(10px 0, red, blue) ran straight across from halfway down. A unitless 0 in a position was not read as a coordinate, and a linear gradient took it for the angle 0; radial-gradient() also took at for the first coordinate. A 0 beside another word of the position is now its coordinate, a bare 0 is still the angle, and the words after at are the position, in both CSS modes. #552 #707
  • linear-gradient(to right, red 12.5%, blue 50%) held red only to 5%, and radial-gradient(12.5% 50%, circle, red, blue) was centred 5% across. A percentage with a fraction was read from the digits after the point. A stop or position of 0px, or any zero length, was dropped as if not written, so radial-gradient(0px 0px, circle, red, blue) was centred and linear-gradient(10px 0px, red, blue) started halfway down. linear-gradient(to right, red 50%, blue 0%) drew a solid blue box, and a stop placed before an earlier one in the middle of the list was moved halfway between its neighbours. A stop placed before an earlier one now moves up to it, as CSS Images does, so the colours meet in a hard edge, in both CSS modes. A repeating gradient whose stops all sit at one position, such as repeating-linear-gradient(red 0%, blue 0%), ran PHP out of memory; it is now a solid fill of the average colour, as in a browser. #552 #738
  • In a table with collapsed borders, a row with a border-color and no border style, or a border of no width, took the borders of its cells away. A reset such as * { border-color: #dee2e6 } or * { border: 0 solid } gives every row a border like that. A row border that draws nothing now leaves the cells' borders; hidden still takes them away. A row's border-top or border-bottom was drawn only when the row also set border-left; each side is now drawn on its own. #644
  • Characters mPDF moved into a substitute font (useSubstitutions, and the fonts for supplementary planes) were wrapped in a <span> that stylesheet rules reached, so span { border: 1px solid } drew a box around them, and the span counted among its siblings for :nth-child(). In the standard CSS mode no rule reaches that span and it is not counted, as a browser has no such element. The legacy mode styles it as before. #634
  • Some inherited properties stopped short of where a browser takes them. A text-shadow did not reach a block's child blocks or list items. word-spacing, hyphens and text-outline did not reach the content of a positioned block. text-transform, text-shadow, font-variant and the other font features did not reach a table's cells. A table nested in a cell took none of the cell's colour, font, size, weight, style, transform or shadow. Each of these channels now carries every inherited property mPDF supports, from the one list in Mpdf\Css\InheritedProperties. Under the standard cssMode only; set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the old output. #539 #648
  • text-transform: none on an inline element, such as a <span> in an uppercase paragraph, did not undo the transform it inherits. Under the standard cssMode only; set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the transform. #552 #539 #648
  • A block inside an inline element, such as <span class="note">…<div>…</div>…</span> or a card written as <a href="…"><div>…</div></a>, lost the inline element's colour, font and other inherited text properties, and so did the inline element's text after the block. A link lost its colour and underline on the block's text and did not cover it. In a table cell the block kept the style, but the text after the inline element did too. A block now inherits the text properties of the inline elements it opens in, and the text after it is drawn in their style until they end. Text before the inline element, on the line before the block, is no longer drawn in the inline element's colour or covered by its link. Under the standard cssMode only; set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the old output. #541 #653
  • Styling a table row or row group, such as tr.total { font-weight: bold } or <thead style="color: #fff">, did not change the text of its cells, only their background. A tr, thead, tbody or tfoot now hands every inherited property to its cells, over the table's and under the cell's own, and a tbody rule reaches the rows written straight into a table. A row's font-size: 80% is taken of its row group's size, and a cell's of its row's. A row's currentColor is its row group's colour, and a cell's is its row's. A th stays bold, and is centred only when it inherits no text-align from its row, row group or table, as HTML's rendering rules have it. Under the standard cssMode only; set 'cssMode' => \Mpdf\CssMode::LEGACY to keep the old output. #542 #655
  • text-outline-width with no text-outline-color raised an undefined-key warning (outline-COLOR) and drew the outline black. The warning is gone in either cssMode. In standard mode the outline is now drawn in the colour of the text, as text-outline-color is currentColor by default, and text-outline with a width alone, such as text-outline: 0.2mm, which was ignored, outlines the text in its colour too. A text outline in currentColor, written or by default, is passed on as the keyword, so a <span> of another colour inside the outlined text is outlined in its own colour. Set 'cssMode' => \Mpdf\CssMode::LEGACY to keep black outlines and to ignore that shorthand. #552 #650 #681
  • A percentage border-radius on a block, such as border-radius: 50% on a box 40 mm by 12 mm, drew a pill instead of an ellipse. Both radii were taken of the width of the block around it, and then shrunk to fit. A percentage is now of the block's own border box, as in CSS: a horizontal radius of its width and a vertical one of its height, so 50% draws an ellipse and 10% a corner a tenth of each side. A block split across pages resolves a vertical percentage against the height of the part on each page. In both cssModes. #552 #586
  • list-style: U+2022, the shorthand, numbered the list where list-style-type: U+2022 drew a bullet. The shorthand dropped the U+ from the marker it set. It now keeps it, so the shorthand draws the character as the longhand does, in either cssMode. #552 #746 #755
  • text-decoration: overline was drawn heavier than an underline on the same text, 2.4 pt against 1.76 pt at 40pt in DejaVu Serif Condensed. The overline is now as thick as the font's underline, sits at the font's cap height rather than a fixed 700/1000 em, and in a table shrunk to fit is thinned and placed with its text. In either cssMode. #741
  • A fixed or absolutely positioned block with a margin-top and no top, such as bottom: 10mm; height: 30mm; margin-top: 20mm, was drawn taller by its top margin, and one with a top, a height and a margin-top grew by its top margin less its bottom margin. Its top margin was counted twice when the top, height or bottom was worked out from the others, and its bottom margin not at all. Each margin now counts once, so margin-top moves the box without stretching it. In both cssModes. #552 #737
  • A positioned block with different left and right margins was placed or sized by its left margin twice. position: absolute; left: 10mm; right: 20mm; width: 100mm; margin-left: 5mm; margin-right: 30mm drew a box 75 mm wide, and right: 20mm; width: 100mm with the same margins put it 25 mm too far right. The CSS 2.1 width algorithm now takes each margin on its own side. In both cssModes. #552 #701
  • With autoPadding on, a block with a percentage border-radius, such as 50%, got no padding, so its text ran over the curve of the corners. A percentage now adds padding as a length does. The horizontal radius is taken of the block's border-box width when the block opens, and so is the vertical one, as an estimate: the block's height is not known until it closes, and depends on the padding being set. So 50% on a block 40 mm wide pads as 20mm would, whatever the block's height, and 50% / 10% as 20mm / 4mm. The corners are still drawn against the block's real width and height. Any rounded corner, of a length or a percentage, is now padded less: the corner of the text is put on the curve where it runs at 45 degrees, which adds the least padding. A 20mm radius on every corner pads 5.86 mm on each side, where it padded 8.45 mm on the left and top, and a flat 20mm / 4mm corner pads 0.39 mm across and 3.22 mm down, where it padded 8.45 mm across. In both cssModes. #552 #702
  • An image, barcode, form input, <dottab>, <hr>, <meter> or <textcircle> straight after a U+FEFF that left no text was not drawn, with no error. A PHP template saved as UTF-8 with a byte order mark and rendered after a <style> block hits this. A <br> in the same place was lost too, so the next text sat a line too high. #870
  • A document or text starting with a byte order mark threw "HTML contains invalid UTF-8 character(s)" on newer versions of PHP (seen on 8.2 to 8.5, not 7.4). The mark is valid UTF-8 and is dropped. U+FEFF elsewhere in the text of a core font, or of a direct call such as WriteCell() or MultiCell(), no longer draws a question mark or a missing glyph either. Write() and Cell() do not validate their text and still draw it. #870
  • WriteHTML() never returned for HTML ending in a cut-off UTF-8 sequence, such as <p>\xE2, or holding a lead byte above \xF4 at its end. With an error handler that returns true, most other invalid UTF-8 hung as well. All invalid UTF-8 now logs the bad bytes, replaces them and carries on, or with debug on throws MpdfException with Invalid input characters. Did you set $mpdf->charset_in properly?. The message HTML contains invalid UTF-8 character(s). See log for further details is gone. #873

Images and SVG

  • A greyscale PNG read more tRNS samples than it has. mpdf/mpdf#1927 #27
  • transform: scaleX() and scaleY() flattened the image on the other axis. mpdf/mpdf#1089 #37
  • An SVG image resolved its variable name instead of the path it points at. mpdf/mpdf#1384 #40
  • An embedded SVG lost its class, so class rules no longer styled it. mpdf/mpdf#1405 #41
  • An inline SVG the XML parser could not read, for example one with an unquoted attribute, divided by zero. It is now reported. #44
  • A GD decode could run out of memory on an image whose header claims a huge size. The claimed size is now checked against memory_limit first. #50
  • A second transformed image with the same border drew that border in the PDF default width and colour. #75
  • An image with both a rotate attribute and a CSS transform turned about the wrong centre and sat off its own border. #70
  • An SVG rgba() or cmyka() fill, stroke or stop-color lost its alpha. #395 #420
  • SVG text lost the alpha of its rgba() or cmyka() fill or stroke. #427 #486
  • SVG text after a nested <tspan> was not drawn. #288
  • Arabic in an SVG was not given an Arabic font. #281
  • An RGB image converted to CMYK truncated its inks, so full ink fell short of 255. #349 #354
  • An image's /SMask pointed at whichever object came before it, which is only its mask if nothing was added in between. An image and its soft mask are now registered together. #373
  • A <textcircle> with no font-size from its tag or the CSS raised three Undefined array key "fontsize" warnings. It is now drawn at the size of the text around it, as though that size were set on it. #645 #678
  • An inline SVG's <title> became the PDF's title when the document had none, or when the SVG came before the document's own <title>. Only a <title> outside any <svg> now titles the document. #779 #783
  • An inline SVG holding another <svg> was cut at the inner </svg>: what followed it in the outer SVG was not drawn. #780 #784
  • An SVG <use>, <tref> or gradient xlink:href drew nothing when another of its attributes held a >, as in data-note="a > b", and an element with a data-id was taken for the one whose id was named. References are now found by the id attribute alone, and a <use>'s x and y move it after its own transform rather than being added to a translate() in it. An element named like <markers> or <patterns>, or an empty <marker/> or <pattern/>, was dropped with everything up to the next </marker> or </pattern>. An SVG that is not well-formed is still drawn as far as it can be read, but now logs a warning, or throws under debug or showImageErrors. #778 #791
  • An SVG <use> of a <g> holding another <g> drew only what came before the inner </g>, and left the markup after it unbalanced. The referenced element now ends at the end tag that closes it, however deeply elements of its name nest inside it. #790 #796
  • An <svg> nested in an SVG ignored its x, y, width and height, and its viewBox rescaled the whole outer SVG, changing the picture's size. It now sets up a viewport of its own: moved by x and y, clipped to its size unless overflow is visible, with its viewBox fitted in as preserveAspectRatio says. #785 #793
  • An SVG whose width and height were not the shape of its viewBox came out the viewBox's shape, sized from width alone: a 200×100 SVG with viewBox="0 0 10 10" was drawn 200×200. It now takes its width and height, with the viewBox fitted in as preserveAspectRatio says. #792 #799

Forms

  • A <select> with a bare disabled attribute was not disabled. #429
  • font-size: larger or smaller on an <input>, <select>, <textarea> or <textcircle> drew its text at 0pt, so it could not be seen. In the legacy CSS mode the value is now ignored and the element keeps the size around it; in the standard mode it is 1.2 times the size of the element it is in, or that divided by 1.2. #545 #647
  • A button with no name raised warnings under useActiveForms. Unnamed buttons are now named Submit_<n>, Reset_<n> or Button_<n>. #438
  • Text wider than its field was cut off. It is now drawn in a smaller font, both on the page and in an active field's appearance. #433 #441
  • A shaped value too long for its field is cut to the longest start that fits, and only between whole clusters. #460 #492
  • In an active widget's appearance, Arabic did not join, right-to-left values were in logical order and Thai and Indic marks were not positioned. The text is now shaped and ordered as page text is. #408 #448
  • A list box's last row ran past its border, and a one-row box could show the top of the next option. #426 #444
  • A static select's drop-down arrow is drawn as a triangle, not a ZapfDingbats glyph. #454 #490
  • An active button with value="" showed its field name as its caption. It is now blank, as it is in a browser. #459 #489
  • An active field in a fixed-position block that shrinks to fit kept its unscaled appearance, so it clipped its value and changed size when clicked. #457 #487
  • Push buttons that share a name are written as one field, with each widget as a kid. #447
  • Each radio widget wrote /AP twice. Radio groups and same-named push buttons are now one field that their widgets inherit from. #450 #500
  • A linefeed in a text field's value was drawn as a space, so value="x(newline)y" showed x y, and one written as &#10; was drawn as a missing-glyph box. A text, search, email, URL, tel or password field, or one of any type mPDF draws as text, now drops the linefeeds and carriage returns in its value, as a browser does, on the page and in an active field. A hidden field, checkbox, radio, button and <textarea> are unchanged. #794 #798

Links, annotations and attachments

  • A link was treated as external only if its address had a dot, so a link to http://localhost/ was not. Links are now classed by their scheme. #8
  • Internal links had no usable /Border entry, so poppler-based viewers such as Evince and Okular drew a box around each one. #68 #69
  • Annotations in an HTML header or footer were lost. They are now written on each page the header or footer is drawn on. #410 #418
  • With forcePortraitHeaders, a link in a rotated header or footer sat about 110mm away from its text. #428
  • An annotation's file given as a Windows path was named after the whole path instead of the file name.
  • A file attachment that is not allowed reserved more object numbers than it wrote. #343 #356
  • SetAssociatedFiles() raised warnings when the optional description, mime or AFRelationship keys were left out. #328
  • In an encrypted document, an imported page used on several pages had its link strings encrypted again on each use, so they read as garbage from the second page on. #335

Index and table of contents

  • The table of contents look-ahead deep-cloned the whole document. It now saves and restores a state snapshot instead. mpdf/mpdf#2207 #13
  • With a table of contents at the front, index page numbers were counted from before the table moved into place. #56 #64
  • An index entry with a run of three or more pages followed by a later page printed only the later page: pages 1, 2, 3 and 5 came out as 5. #66 #67
  • Index entries whose keys collate the same, such as Term and term, came out in a different order on PHP 7 and PHP 8. They now keep the order they were made in. #74
  • With a toc-page-selector, a long index and whatever followed it were laid out in the table of contents' @page margins, header and footer. #856
  • An SVG with a gradient or opacity came out blank when first drawn in the table of contents, or in a page-break-inside: avoid block that moved to the next page. The same SVG drawn later in the body after an index was blank too. #857
  • A spot colour first used in the table of contents, or in a page-break-inside: avoid block that moved to the next page, was left undefined. After an index, the contents could print in the ink of a spot colour the body went on to use. #857
  • A <style> in toc-preHTML also applied to whatever followed an index, as well as to the table of contents. #857
  • A colour or image PDF/A or PDF/X does not allow went unreported when first used in the table of contents or in a page-break-inside: avoid block that moved to the next page, so the document was output instead of refused. #857

PDF/A and PDF/X

  • A PDF/A-1b document could carry fonts, SVG opacity, shadow blur and annotation colours that PDF/A-1 forbids. #346 #361
  • Under PDF/A-1b, SVG gradient stops are painted opaque, and only the visibility groups the catalog lists are written. #346 #351 #386
  • An annotation lost its subject under PDF/A-2 and PDF/A-3. #350 #357
  • A PDF/A-3 annotation's file was not written as an associated file, so veraPDF rejected it. #347 #358
  • PDFAauto and PDFXauto now leave out screen-only content, and hidden content that the standard cannot hold. #397 #416
  • A PDF/A document with restrictColorSpace => 3 and no ICCProfile embedded the sRGB profile with /N 4 and wrote CMYK colours, which fails PDF/A. The output intent profile is now checked against what PDF/A permits, /N is read from the profile and a suitable bundled profile is embedded under PDFAauto. #449 #499

PDF output

  • The file header kept the PDF version set at the start, even when later features raised it. #339 #378
  • /PageMode could appear more than once in the catalog. mpdf/mpdf#2142 #17
  • Every CID font carried a ToUnicode CMap whose single range mapped the whole two-byte space. #344 #362
  • A subset's ToUnicode map put more than 100 entries in one block. Readers that enforce the limit lost text extraction, copy and search past that point. #363 #365
  • Writing an SVG background pattern read keys that only used fonts have from fonts the document loaded but never used. #19
  • OverWrite() returned a document it could not read unchanged. It now refuses it. mpdf/mpdf#747 #42
  • OverWrite() assumed every content stream was compressed the way the current instance compresses. It now reads each stream's compression from the document. #52 #53
  • In a core-font document, OverWrite() did not find search text with characters outside ASCII, or with (, ) or \. #464 #485
  • An EAN or UPC code longer than the symbol holds is refused. mpdf/mpdf#1334 #39
  • A <title> or <meta> written inside a <script>, <style>, <textarea> or HTML comment was read as the document's own: it became the PDF's title in place of the real <title> after it, or set its author, subject or keywords. These hold text, not elements, as they do in a browser. #786 #795
  • Passing a class that only implements AssetFetcherInterface through the container as assetFetcher threw a TypeError while Mpdf was constructed. Only AssetFetcher or a subclass of it was accepted. #858

Font cache

  • Two processes creating the cache directory at the same time could fail. mpdf/mpdf#1775 #224
  • A cache file another process removed raised a warning. mpdf/mpdf#1368 #236
  • A cache entry that expired between the check and the read was drawn with as false. It is now regenerated. #231 #246
  • The right-to-left form table was sorted differently on different PHP versions, so the same font gave different cache files. #248 #249
  • AddFont() read back stale metrics when it regenerated a font in the same process. #290

Fonts and subsetting

  • MarkGlyphSets was not read from GDEF 1.3 and was read from the wrong offset, and UseMarkFilteringSet did not follow the specification. #1 #14 #26
  • A subset's cmap could write a glyphIdArray that idRangeOffset cannot reach, and counted its length in entries instead of bytes. #151 #158 #165
  • A format 6 cmap subtable too long for its uint16 length field is left out. #164 #169
  • A subset's maxp profile was not recalculated when it kept a simple or empty glyph. #173 #197
  • A subset's head bounds and hhea extremes came from the whole font instead of the glyphs it keeps. #179 #184
  • The font file stayed open when building a subset or a repackaged font threw, or when getCTG or getTTCFonts returned early. #168 #180 #182 #183
  • The character count header could overflow the two bytes that hold it. #127 #134
  • Font names outside ASCII were garbled because they were read one byte per character instead of as UTF-16. #238 #241
  • The synthetic Myanmar font kept the Reserved name of the font it was made from. #237 #239
  • Since mPDF 7.1.8, the Ascent, Descent and Leading overrides in fontdata had no effect, and TTCfontID always picked the first font of a collection. #321 #322
  • Font substitution moved characters the document font has into the backup font. A space between two emoji was drawn in the emoji font and left an emoji-sized gap. #303
  • A backup font that the substitution scan tried and rejected was still added to the document, so the same document gave different bytes with a cold and a warm font cache. #315 #318 #342 #381
  • Text in a core font such as chelvetica that the core font cannot draw, like Cyrillic, came out as question marks the first time its backup font was used with nothing of that font in the font cache. With more than one backup font it went to a later one instead. Rendering again worked. #829
  • A run of Plane 2 characters next to a newline was not moved into its SIP font, and text after the newline could be dropped. #411
  • A CJK Extension E or later character, or a Plane 3 character in a document that also had a Plane 2 character, was moved into Sun-ExtB, which lacks it, and drawn as Sun-ExtB's missing-character box. Sun-ExtB was loaded for it, and the other backup fonts were never tried. This happened with or without useSubstitutions in text set in Sun-ExtA, or in any font whose sip-ext font is Sun-ExtB. Now a character above U+1FFFF goes to the SIP font only where that font has it, and is otherwise offered to the backup fonts like any other. With useSubstitutions on, text in such a font is substituted in one pass: the text ahead of a Plane 2 character, which used to be skipped, is substituted too, and a Plane 2 character the font has itself stays in it. #837
  • haskernGPOS was read for core fonts, which have no GPOS. #141 #149
  • Core-font text is held in Windows-1252 but was decoded as UTF-8 when given bidi data, which dropped some bytes such as a lone 0xA0. #383
  • debugfont mode read the wrong byte offsets in hhea, post and maxp. mpdf/mpdf#2053 #23
  • Sun-ExtA and Sun-ExtB could not be loaded as web fonts: Chromium and Firefox rejected both for their malformed vertical metrics. vhea, vmtx, VORG and Sun-ExtB's stale DSIG are removed, as are the substitutions in Sun-ExtA's GSUB that name glyphs it does not have. PDFs using them look the same. #881

Text shaping: general

  • A GPOS feature with no lookups, such as Myriad Pro's old size feature, raised a notice while the font cache was built. mpdf/mpdf#1967 #10
  • MultiCell() with a blank string raised warnings when slicing its OTL data. mpdf/mpdf#2197 #15
  • The first font-variant-position: super or sub in a document raised an undefined-key warning. mpdf/mpdf#2136 #16
  • font-feature-settings could not turn off the features a script's shaper applies itself, such as blwf, pref, half or rphf. It now can, at the stage the shaper applies them, as in HarfBuzz. #384
  • The kern feature was appended to a run's empty feature set instead of being set on it. #157
  • Text straight after a block in a table cell lost its kerning and mark positions, and in some fonts, such as XB Riyaz, its glyphs came out in the wrong order. It now draws as it does alone in a cell. #872
  • Text was kerned twice, drawing its pairs too close, when it followed text with no GPOS kerning of its own in a font that also has a kern table. #872
  • A character added to Unicode since 6.1 was read as unassigned. #99 #101 #103
  • The lang attribute now selects the language system HarfBuzz would for variant, script, region and extended language subtags. That includes ZHH, ZHS, ZHT and ZHTM for Chinese. #191 #201 #206 #218 #220 #221

Text shaping: Arabic, Syriac and Sogdian

  • Arabic letters that a font's ccmp splits into a base and dots, as Noto Sans Arabic does for beh, lost their joining. Joining is now worked out from the characters as written, before locl and ccmp. #209 #226
  • A letter did not join to the base before it when more than one mark sat between them. #161
  • A mark took its form from the mark after it instead of from the letters around it. #163
  • A joining form the font writes as several glyphs was drawn as one. #115 #125
  • A final form made of several glyphs was matched as a whole in the kashida rules instead of by its first glyph. #126 #135
  • An Arabic form's plain context rule was given a backtrack or lookahead. #189 #215
  • An Arabic form's context walk ran past the edge of the run. #204 #219
  • Letters either side of an Arabic presentation form, U+FC5E to U+FC62, were drawn joined. #267 #276
  • The Arabic End of Ayah was not read as Arabic everywhere a script is read. #277
  • An Arabic presentation feature the document names was applied twice when the shaper had already asked for it. #230 #240
  • Sogdian Fe now joins to the letter before it, and Low Alef joins to nothing. #94
  • The Syriac Alaph took the wrong form. It now takes the form the font gives after DALATH or RISH, is chosen from the bases either side of it, and resolves fin2, fin3 and med2 from the joining state table. #132 #143 #155 #228 #244 #247 #254
  • Cursive joining and Transparent-Joining now come from Unicode. A letter next to a recently added character joins, and a mark that only the font knows does not break a join. #251 #259 #261 #273

Text shaping: Indic, Khmer, Myanmar and Sinhala

  • The Khmer Coeng was read outside the cluster it belongs to. #93 #95
  • A glyph of an Indic cluster the shaper did not reorder had no mask, which raised a warning per glyph per feature. #96
  • The Myanmar shaper raised undefined-key warnings on every call to insert dotted circles. mpdf/mpdf#2046 #21
  • A v2 Indic script tag fell back to other scripts' original tags instead of only its own. #192 #216
  • An Indic run's shaper is chosen from the script chosen for the run, as in HarfBuzz. #199 #222
  • Above-base forms are applied at the stage HarfBuzz applies them, in Indic and Khmer fonts. #263 #269 #270 #279
  • Below-base forms are applied before the base as well as after it, as in HarfBuzz. #422
  • A Sinhala repaya was not formed. It is now formed and drawn after the consonant it sits on. #287 #289
  • A Sinhala font whose pref, blwf or pstf ligature is written Consonant + Halant did not have its al-lakuna recognised, as the other viramas are. #435 #501

Text shaping: OpenType lookups

  • Every feature of a language system is offered, not only the last of those that start at the same lookup. #245 #252
  • A shared lookup's rules are classed under every feature of the language system that names it. #271 #284
  • A GSUB lookup that two selected features name is applied once where HarfBuzz merges it, under the alternate the first feature asked for. A Khmer font reaches its merged mask. #243 #257 #258 #264 #272
  • Where GSUB features are applied one at a time, each pass applied every feature. It now applies one, and each lookup of that feature runs over the whole run. #212 #229 #233 #234 #242
  • A nested lookup applied what its subtable holds for the first glyph it covers to any glyph. It now applies only to a glyph the subtable covers. #102 #106
  • A chained context positioning by coverage ran its nested lookups twice on the same glyph. #97
  • A contextual subtable that matched but changed nothing let the next subtable of the lookup run too. #109
  • A GSUB subtable over 32 KB did not resolve, because its record offsets were read as signed. #100 #107
  • A class-based chained rule kept the extra backtrack and lookahead positions of the rule read before it. #170 #195
  • A class 0 backtrack or lookahead position in a chained context rule never matched. #385
  • An input position naming a class the ClassDef does not define matched any glyph. It now matches nothing, as in HarfBuzz. #412
  • Class 0 matched glyphs of classes numbered above a gap in the ClassDef, and glyphs a ClassDef lists as class 0 were kept as a class of their own. #414 #417
  • GDEF class membership was tested by searching for the glyph's hex in the class. #193 #217
  • A lookup that sets IgnoreMarks and names a mark attachment class skipped only the marks outside the class. It now skips every mark. #175 #185
  • NULL offsets were read as real offsets in GSUB and GPOS headers, class-based context ClassDefs, Class Definition tables and the rule sets of context and chained context Format 1 subtables. #253 #262 #326 #331 #379 #382 #413
  • A NULL anchor on a base or mark was read as an anchor. It now attaches nothing. #260 #268
  • A Single Substitution warned for a glyph that text cannot reach. #307 #309
  • The GSUB row was built differently depending on whether the font cache had one. #285 #286
  • Four lookup keys were read by what the reader assumed instead of what the font states. #104 #105 #113 #139

OtlDump

  • MarkGlyphSets was not read from GDEF 1.3. #34
  • A context rule's example string and records were reported twice. #124 #130 #144
  • The rules of a nested lookup reached at a class 0 position were not reported. #123 #138
  • Substitutions the parser does not keep were reported, and glyphs that GDEF does not class as marks were drawn on a dotted circle. #187 #194

Internal

These changes do not change output.

  • OTL refactor. Otl, OtlDump and TTFontFile were refactored. Each OTL table is read once, the parser is split from the subsetter, the table readers moved to Mpdf\Fonts\Table, and OtlData, OtlTags and the debugOTL trace moved out of Otl. #84 #117 #160 #167 #171 #172 #174 #176 #177 #178 #186 #188 #190 #198 #235 #250 #275 #282
  • Unicode namespace. The Unicode character data and the bidi algorithm moved under Mpdf\Unicode. #294
  • Dead code. State left by the pre-OTL Arabic shaper was deleted #88 #128, and so was the unread Form::$form_checkboxes #471.
  • Annotation objects. Annotation object numbers are given once instead of being predicted in PageWriter. #360
  • ToUnicode. The byte-subset ToUnicode map is built in one place. #372
  • UTF-8 decoding. A valid UTF-8 string is decoded with mbstring. #364
  • Glyph outline numbers. A glyph outline's coordinates are written through NumericString::decimal(), as the colour glyphs and SVG paths write theirs. #625
  • Snapshot tests. Snapshot tests compare bytes first, then PDF objects, then pixels. Snapshot documents carry nothing of the machine that made them. #72
  • Data scripts. Composer scripts regenerate the Unicode, emoji, joining, language system, font cache, subset, shaping and grey profile data, and update snapshots.
  • CI. #5 #310 #317 #376 #377 #615 #674 #675
    • CI runs on the gravitypdf branch, caches Composer downloads and uses current action versions.
    • It checks PDF/A and PDF/X-4 output with veraPDF, and tests e-invoices against the XML packages composer.json suggests.
    • The test suite runs under a 512M memory limit.
    • Pull requests run 5 of the 24 PHP and OS test jobs unless labelled full-ci, leaving out PHP 5.6 on Windows, the slowest. Pushes to gravitypdf, a nightly run and a manual run get all 24. A newer push to a pull request cancels the run it replaces.
    • Every workflow, code coverage included, also runs nightly on gravitypdf and can be run by hand.
    • The Windows test jobs no longer spend minutes on HTTP requests to localhost. A test left $_SERVER['HTTP_HOST'] set, so every later test fetched each missing stylesheet or image from http://localhost, and on Windows each refused connection takes about two seconds. #674
    • The coding standard and PHPStan run as one Lint workflow. The e-invoice and PDF/X-4 checks run on a pull request only when it changes the code they cover.
  • Test memory. On PHP 5.6 the test suite peaks at about 330MB instead of 470MB. PHPUnit before 8.5 has every suite keep its own copy of the list of declared classes. The test listener now empties those copies before the first test runs, and the bootstrap no longer creates an Mpdf instance, which made every copy longer. #841
  • PHPStan. Fixes for newer PHP versions and PHPStan 2.2.15. #6 #295 #319 #451
  • Branch alias. The Composer branch alias maps dev-gravitypdf to 8.x-dev. #3
  • Open elements. WriteHTML() keeps a stack of the elements open in the HTML it reads, so that CSS rules can be matched against an element's parents, ancestors and earlier siblings rather than only the blocks mPDF lays out. Each element carries its position among its siblings and a record of the siblings before it. Mpdf::getOpenElements() reads it. #533
  • Compiled selectors. A rule whose selector the legacy parser cannot read is compiled into its compound selectors, the combinators between them and its specificity, and filed under its rightmost compound for the selector matcher. A selector list is split at the commas outside parentheses, brackets and strings, so :is(h1, h2) and [title="a,b"] stay whole. #538 #619
  • Computed values on the open elements. In the standard CSS mode, each element on the stack of open elements carries the properties merged for it, with the CSS-wide keywords resolved, in the computed slot of its frame, and the document's frame carries those of <body>. inherit reads a parent's from there. #546 #652
  • nth-child in tables from the open elements. tr, td and th:nth-child() and :first-child take a row's or cell's position among its siblings from the stack of open elements, as the selector matcher does, instead of from mPDF's row and column counters. An element a browser moves out of a table, such as a <bookmark> or <tocentry> written between two cells, is not counted, and with allow_html_optional_endtags off a cell, row or row group with no end tag is closed by the next one, as mPDF lays it out. #538 #629