From 2e90b3bce8db697052a1f17da670ebe76f34f874 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 11 Nov 2017 11:29:52 -0800 Subject: [PATCH] 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. --- demo/client/src/text.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/demo/client/src/text.ts b/demo/client/src/text.ts index 64632336..ff80263a 100644 --- a/demo/client/src/text.ts +++ b/demo/client/src/text.ts @@ -19,11 +19,19 @@ import {assert, lerp, panic, UINT32_MAX, UINT32_SIZE, unwrapNull} from "./utils" export const BUILTIN_FONT_URI: string = "/otf/demo"; -// Matches macOS 10.13 High Sierra. -const STEM_DARKENING_FACTORS: glmatrix.vec2 = glmatrix.vec2.clone([0.0121, 0.0121 * 1.25]); +const SQRT_2: number = Math.sqrt(2.0); + +// 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. -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. const MAX_STEM_DARKENING_PIXELS_PER_EM: number = 72.0;