getDomPDF()->getFontMetrics(); $font = $metrics->getFont('NotoSans', 'normal'); expect($font)->not->toBeFalsy('NotoSans should resolve; it is the bundled default face'); return $metrics->getFontHeight($font, $size); } test('a declared line-height is rendered at its declared size', function (float $size) { expect(notoSansHeightAt($size))->toEqualWithDelta($size, 0.01); })->with([9.0, 12.0, 15.0, 18.0, 24.0]); test('the configured ratio is the one that cancels the font metrics', function () { // Guards the value itself, so a well-meaning "restore the dompdf default" // shows up as a failing test rather than as documents silently growing. expect(config('dompdf.defines.font_height_ratio'))->toEqualWithDelta(0.7342, 0.0005); }); /** * The stock ratio is what the drift looked like: 1.1 × 1.362 ≈ 1.4985, which is * within a rounding error of the 1.5 that a hand-tuned compensation shim had * arrived at empirically. */ test('dompdf stock ratio would inflate every line by about half again', function () { $natural = notoSansHeightAt(12.0) / config('dompdf.defines.font_height_ratio'); expect($natural * 1.1 / 12.0)->toEqualWithDelta(1.4985, 0.005); });