Multiply stem darkening amounts by sqrt(2).

This compensates for the fact that macOS dilation is relative to the pixel square, while our dilation is relative to each vertex normal.
This commit is contained in:
Patrick Walton 2017-11-11 11:29:52 -08:00
parent ceb9d2bb80
commit 2e90b3bce8
1 changed files with 11 additions and 3 deletions

View File

@ -19,11 +19,19 @@ import {assert, lerp, panic, UINT32_MAX, UINT32_SIZE, unwrapNull} from "./utils"
export const BUILTIN_FONT_URI: string = "/otf/demo"; export const BUILTIN_FONT_URI: string = "/otf/demo";
// Matches macOS 10.13 High Sierra. const SQRT_2: number = Math.sqrt(2.0);
const STEM_DARKENING_FACTORS: glmatrix.vec2 = glmatrix.vec2.clone([0.0121, 0.0121 * 1.25]);
// Should match macOS 10.13 High Sierra.
//
// We multiply by sqrt(2) to compensate for the fact that dilation amounts are relative to the
// pixel square on macOS and relative to the vertex normal in Pathfinder.
const STEM_DARKENING_FACTORS: glmatrix.vec2 = glmatrix.vec2.clone([
0.0121 * SQRT_2,
0.0121 * 1.25 * SQRT_2,
]);
// Likewise. // Likewise.
const MAX_STEM_DARKENING_AMOUNT: glmatrix.vec2 = glmatrix.vec2.clone([0.3, 0.3]); const MAX_STEM_DARKENING_AMOUNT: glmatrix.vec2 = glmatrix.vec2.clone([0.3 * SQRT_2, 0.3 * SQRT_2]);
// This value is a subjective cutoff. Above this ppem value, no stem darkening is performed. // This value is a subjective cutoff. Above this ppem value, no stem darkening is performed.
const MAX_STEM_DARKENING_PIXELS_PER_EM: number = 72.0; const MAX_STEM_DARKENING_PIXELS_PER_EM: number = 72.0;