Add system font size as a device attribute#3
Draft
claude[bot] wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 to1. This matches the cross-platformfontScalekey that the iOS and Android SDKs emit.fontSize— the effective root font-size in integer pixels, defaulting to16.Together they let audience filters key off either the relative scale or the absolute px value.
How
packages/paywalls-js/src/internal/deviceAttributes.ts, sharing aDEFAULT_ROOT_FONT_PX = 16constant and mirroring the existingderiveInterfaceStyle/deriveDeviceTierpattern (guarded browser-global access + try/catch + hardcoded fallback):deriveFontScale()returnsMath.round((rootPx / 16) * 100) / 100, falling back to1.deriveFontSize()returnsMath.round(rootPx), falling back to16.fontScaleandfontSizekeys in the web-specific block of theoutobject, alongsideuserAgent/viewportWidth/devicePixelRatio.deviceAttributes.test.ts(verifies the SSR/failure fallbacks of1and16).Caveat
Browsers expose no direct OS text-size / accessibility setting. The best available proxy is the computed root (
<html>) font-size, so bothfontScaleandfontSizereflect the effective root/browser font size rather than the raw OS accessibility slider. On SSR or any failure they fall back to1and16respectively.Generated by Claude Code