)]}'
{
  "commit": "3dd2eb752f3387a3a0db3bc3b7bc365ecfa405ba",
  "tree": "be7449a27a9ec2dff25c5da921c1f08bc959ac3c",
  "parents": [
    "2da26ba00f3b91127336a1aa582bfca45fe8a6fa"
  ],
  "author": {
    "name": "Behdad Esfahbod",
    "email": "behdad@behdad.org",
    "time": "Sat Nov 21 02:05:34 2026 -0600"
  },
  "committer": {
    "name": "Behdad Esfahbod",
    "email": "behdad@behdad.org",
    "time": "Sat Nov 21 02:10:10 2026 -0600"
  },
  "message": "[vector] Pad a PDF gradient in its last color where that comes late\n\nA color line that pads goes on after its last stop in that stop\u0027s\ncolor.  pdfium takes 256 samples of a shading\u0027s function, at 0, 1/256\nand so on to 255/256, and goes on after the shading in the last of\nthem: in what the function gives at 255/256, not at 1.  For a color\nline of two stops that is within a level of the last color.  Where\nthe last two stops are close together it is not: with red at 0, green\nat 0.9895 and white at 1, pdfium padded in (160, 208, 160), the color\n63% of the way from green to white, where it should be white.\n\nTwo stops at the last offset already get the color line lengthened\nby a stretch in the last color.  Do that as well where the color\nline is more than two levels short of its last color at 255/256, in\nalpha or in what shows of red, green or blue, which is that times\nalpha.  The stretch for it is the last 128th of the lengthened line,\nwhich has pdfium\u0027s last sample in it; two stops at one offset keep\ntheir sixteenth, which puts them at a sample.  A radial gradient\nthat ends at a radius of zero paints nothing after it and is left\nalone there.  It no longer counts as lengthened at that end when the\nstretch at its start is sized, so two stops at its start are a\nsixteenth in as well.\n\nTesting: test_glyphs-glyf_colr_1_variable.ttf has those stops at\nCOL1\u003d0.496,COL3\u003d-0.885.  At 160 pixels per em, the pixels of its\nthree glyphs with gradients that pad that pdfium has more than 24\nlevels from hb-raster\u0027s:\n\n                                              before  after\n  linear_gradient_extend_mode_pad                57%   none\n  radial_contained_gradient_extend_mode_pad      64%   none\n  radial_horizontal_gradient_extend_mode_pad     17%   0.15%\n\nMuPDF, poppler, Ghostscript, Chrome and librsvg have them as before:\nnone, and 0.12% for the last one.\n\nReplaying the same paint calls on hb-raster and hb-vector for 300\nrandom scenes of linear and radial gradients with a stop from 0.001\nto 0.2 of the length in from an end, how many have the same pixels:\n\n                  before  after\n  pdfium             223    300\n  MuPDF              300    300\n  poppler cairo      300    300\n  poppler Splash     300    300\n  Ghostscript        290    288\n  Chrome (SVG)       300    300\n  librsvg (SVG)      300    300\n\nThe two that Ghostscript newly differs on, by 0.4% and 0.2% of the\npixels, both reduce to a linear gradient under a rotation, as do the\ntwo largest of the ten that it differed on before.\n\nScenes of other gradients, 1800 of them, are written byte for byte\nas before, those with two stops at an end among them.  Of the 1553\nmapped glyphs of the COLR test fonts the PDF of four changes, the H\nof BitcountInk and the three glyphs of KalniaGlaze; their pictures\nin pdfium, MuPDF, poppler and Ghostscript stay as they were to within\n0.03% of the pixels.  No SVG changes.\n\nThe test for padding has more cases, and fails without the change.\nIt is clean as C99 with -pedantic under gcc and clang, and the vector\ntests pass under ASan, UBSan and MSan.  hb-vector-fuzzer, built with\ncoverage instrumentation and run from the COLR test fonts with\nfailing allocations, made 289591 runs in three minutes on eight jobs\nwithout a finding.  Full test suite passes.\n\nFound comparing every glyph of the variable test font at random\nlocations in its design space.\n\nCo-Authored-By: Claude Fable 5.2 \u003cnoreply@anthropic.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "53a87e44177c31e9509f1ba7a8ee299d4219aef7",
      "old_mode": 33188,
      "old_path": "src/hb-vector-paint-pdf.cc",
      "new_id": "040b060fa419712f5abc6f591bd2bca45f983743",
      "new_mode": 33188,
      "new_path": "src/hb-vector-paint-pdf.cc"
    },
    {
      "type": "modify",
      "old_id": "85895ea7ef271b4a4e31aacb9f0b5c11776a0ef7",
      "old_mode": 33188,
      "old_path": "test/vector/test-vector-pdf-pad.c",
      "new_id": "457042e39662bd8d728279816b8f6ab7ef4b12ec",
      "new_mode": 33188,
      "new_path": "test/vector/test-vector-pdf-pad.c"
    }
  ]
}
