Skip to content

Add system font size as a device attribute#3

Draft
claude[bot] wants to merge 3 commits into
mainfrom
add-font-scale-device-attribute
Draft

Add system font size as a device attribute#3
claude[bot] wants to merge 3 commits into
mainfrom
add-font-scale-device-attribute

Conversation

@claude

@claude claude Bot commented Jul 2, 2026

Copy link
Copy Markdown

Requested by Jake Mor · Slack thread

Before / After

Before: The web device attributes did not report the user's font-size (text-size) setting at all — there was no signal for how large the user prefers text, so audience filters that reference this on iOS/Android had no web analogue.

After: Device attributes now include two font signals:

  • fontScale — the effective root font-size ÷ the 16px browser default (a 2-decimal multiplier), defaulting to 1. This matches the cross-platform fontScale key that the iOS and Android SDKs emit.
  • fontSize — the effective root font-size in integer pixels, defaulting to 16.

Together they let audience filters key off either the relative scale or the absolute px value.

How

  • Added two SSR-safe helpers in packages/paywalls-js/src/internal/deviceAttributes.ts, sharing a DEFAULT_ROOT_FONT_PX = 16 constant and mirroring the existing deriveInterfaceStyle / deriveDeviceTier pattern (guarded browser-global access + try/catch + hardcoded fallback):
    • deriveFontScale() returns Math.round((rootPx / 16) * 100) / 100, falling back to 1.
    • deriveFontSize() returns Math.round(rootPx), falling back to 16.
  • Surfaced both as the camelCase fontScale and fontSize keys in the web-specific block of the out object, alongside userAgent / viewportWidth / devicePixelRatio.
  • Added matching per-key assertions in deviceAttributes.test.ts (verifies the SSR/failure fallbacks of 1 and 16).

Caveat

Browsers expose no direct OS text-size / accessibility setting. The best available proxy is the computed root (<html>) font-size, so both fontScale and fontSize reflect the effective root/browser font size rather than the raw OS accessibility slider. On SSR or any failure they fall back to 1 and 16 respectively.


Generated by Claude Code

@claude claude Bot changed the title Add system font scale as a device attribute Add system font size as a device attribute Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant