)]}'
{
  "commit": "f4d31875f0da83e3c9d0a4aa8d777079e45bb8e1",
  "tree": "ec39dc6c0ef52c2c9239bade11f6a5ace1218ccd",
  "parents": [
    "551b94e38877e1b4c1d711afed7ca5d2488471d3"
  ],
  "author": {
    "name": "Behdad Esfahbod",
    "email": "behdad@behdad.org",
    "time": "Fri Nov 20 00:36:01 2026 -0600"
  },
  "committer": {
    "name": "Behdad Esfahbod",
    "email": "behdad@behdad.org",
    "time": "Fri Nov 20 14:08:50 2026 -0600"
  },
  "message": "[vector] Write the Porter-Duff composite modes in PDF\n\nPDF has the blend modes and none of the Porter-Duff operators, so\npop_group painted PLUS as Screen, XOR as Difference, and the other\nten modes as Normal.  composite_CLEAR in test_glyphs-glyf_colr_1.ttf\ncame out with both of the squares that it should have erased, and\nthe 28 glyphs of that font that composite in DEST_OVER came out with\ntheir two layers the wrong way up.\n\nNow that groups are Form XObjects, a group can be a soft mask as well\nas be painted, and that is all these modes take:\n\n  CLEAR, SRC, DEST, DEST_OVER   neither, one, or both the other way up\n  SRC_IN, DEST_IN               one group, through the other\u0027s alpha\n  SRC_OUT, DEST_OUT             one, through the inverse of it\n  SRC_ATOP                      the backdrop, then SRC_IN\n  DEST_ATOP                     the source, then DEST_IN\n  XOR                           DEST_OUT, then SRC_OUT in Screen\n\nThe inverse of a group\u0027s alpha is the luminosity of a group that is\nwhite with black painted over it through the alpha mask.  A transfer\nfunction on the alpha mask would say that in fewer objects, but\npoppler\u0027s cairo backend does not apply one.\n\nThe last three, and PLUS, are sums of two layers, and PDF has no way\nto add: the upper layer hides some of the lower where both are partly\ntransparent.  As written, SRC_ATOP is exact where the backdrop is\nopaque or absent, DEST_ATOP where the source is, and XOR where either\nis.  PLUS stays Screen.  The API documentation now says which modes\nare approximate, in PDF and in SVG.\n\nAs in the SVG writer, the backdrop is everything the enclosing group\nhas painted: transforms and clips that are open in it are closed\naround the backdrop, repeated around the source, and opened again;\npops that do not match their pushes leave the content streams\nbalanced; and what a document refers to more than once counts against\nthe document cap.  Something painted with a blend mode in the root\ngroup would blend with the background too, so a root that has one is\npainted as a group of its own.  render now fails if the root\u0027s\ncontent stream was cut short, as it does for a missing object.\n\nThe graphics states that are kept for sizing sweep gradients are\npopped where a Q is written, so that they go on describing the\ncontent stream when a pop has nothing to close.\n\nTesting: hb-vector\u0027s PDF for the thirteen composite_* glyphs from\nCLEAR to PLUS, and for modes.ttf from How HarfBuzz Works, has the\npixels hb-raster gives them in poppler (Splash and cairo),\nGhostscript, pdfium and MuPDF, antialiased edges aside.  Over the\nwhole of test_glyphs-glyf_colr_1.ttf, 30 more glyphs now match\nhb-raster in PDF, and with the two SVG changes before this one, 41\nin SVG; none fewer.  Glyphs without a composite are byte for byte\nwhat they were.  Replaying the same paint calls on hb-raster and\nhb-vector for 300 random scenes of nested groups and translucent\nfills, with groups popped under open transforms and clips and at the\nroot, the nine exact modes agree in poppler, pdfium and MuPDF on\nevery scene.  Ghostscript 10.05 differs on six.  The one that was\nreduced comes down to a group that sets a soft mask being painted\nthrough another, inside the group of a third, which Ghostscript also\ngets wrong in a PDF written by hand.\n\nThe vector fuzzer and these scenes were also run under ASan and\nUBSan, with and without failing allocations.  The composite test\ngains the PDF counterparts of its SVG checks, and the thirteen glyphs\na second expected output.  Full test suite passes.\n\nFixes: https://github.com/harfbuzz/harfbuzz/issues/6829\nFixes: https://github.com/harfbuzz/harfbuzz/issues/5951\n\nCo-Authored-By: Claude Fable 5.2 \u003cnoreply@anthropic.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e5e5bf1874aaa3e7967405244bfafb29872b3165",
      "old_mode": 33188,
      "old_path": "src/hb-vector-paint-pdf.cc",
      "new_id": "9c4f4fb8601fa75523e940b2a72753eea78a88de",
      "new_mode": 33188,
      "new_path": "src/hb-vector-paint-pdf.cc"
    },
    {
      "type": "modify",
      "old_id": "45f03d0c539fed680d0775f81c11006fb0e06917",
      "old_mode": 33188,
      "old_path": "src/hb-vector-paint.hh",
      "new_id": "0d042e9c0b9414f4e0fcff81446e3df1c3091898",
      "new_mode": 33188,
      "new_path": "src/hb-vector-paint.hh"
    },
    {
      "type": "modify",
      "old_id": "8ce53f5a8c9eebb09f739a6da41545f3f677c6ad",
      "old_mode": 33188,
      "old_path": "src/hb-vector.cc",
      "new_id": "fdb0b359105e35fbfb6eeb1f4ed0ca503b785745",
      "new_mode": 33188,
      "new_path": "src/hb-vector.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "96e39f0dd1e4f4887300caa5e23596ab621ea3f4",
      "new_mode": 33188,
      "new_path": "test/vector/data/expected/basic/colrv1-composite-porter-duff.pdf"
    },
    {
      "type": "modify",
      "old_id": "c73a866ad81d537a9b0cbdf030c0285586ffbe5f",
      "old_mode": 33188,
      "old_path": "test/vector/data/tests/basic.tests",
      "new_id": "d1413b146db2be91a3d47b34cdb4d550bed60f65",
      "new_mode": 33188,
      "new_path": "test/vector/data/tests/basic.tests"
    },
    {
      "type": "modify",
      "old_id": "4d76664836d83afd32f527144493ff603a83c6da",
      "old_mode": 33188,
      "old_path": "test/vector/test-vector-composite.c",
      "new_id": "482e72c442439e316cab279b056798006081b49b",
      "new_mode": 33188,
      "new_path": "test/vector/test-vector-composite.c"
    }
  ]
}
