Repository navigation
Conversation
The CSS injected into each tab was tracked in a module variable, which is lost whenever Chrome stops the idle MV3 service worker (~30 seconds). The next update then inserted new CSS without removing the old stylesheet, so slider values kept applying after switching to "[Inherit page styles]", and an explicit 'opsz' kept font-optical-sizing: auto from working. Track it in chrome.storage.session instead, serialize CSS updates so quick successive changes can't leave a stylesheet behind, and clean up when a tab closes. Fixes arrowtype#159 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moving any slider wrote every axis into font-variation-settings, including 'opsz', so there was no way to keep font-optical-sizing: auto while adjusting other axes. The Optical size value now doubles as a toggle that reads "auto" while it's on: 'opsz' is then left out and the browser matches it to the font size. Auto is on by default, including for fonts saved before this change; moving the slider turns it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show "auto" as the value's text instead of hiding the number with CSS, so it gets the same size, line height and position as the numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #159.
In #159,
font-optical-sizing: autonever took effect. That came from two separate problems, and this PR fixes both.1. Slider values stuck after switching to "[Inherit page styles]"
service-worker.jskept track of the CSS it had injected into each tab in a module variable (injectedCSS). Chrome stops idle MV3 service workers after about 30 seconds, and that variable is lost when it does. The next update then inserts the new stylesheet but never removes the old one. So a stylesheet with the slider values ('opsz' 18, 'wght' 300, …) stays in the page after switching to Inherit, and the explicit'opsz'overrides automatic optical sizing. Restarting Chrome clears it, which made the bug look intermittent.chrome.storage.session, which survives worker restarts.2. No way to leave optical size on auto while using the sliders
Once any slider was touched,
cssVariationSettings()wrote every axis, includingopsz. The only way back to automatic optical size was "[Inherit page styles]", which also drops your other axis choices. The workaround was a hand-writtenfont-variation-settingsin the CSS box that leftopszout.opszis left out offont-variation-settings, so the browser matches it to the font size.role="button", Enter/Space,aria-pressed).Font.autoOpsz. Fonts saved before this change read it astrue. Decision for you: that means anyone who had deliberately set opsz with a slider gets auto after updating. If you'd rather keep their setting, change the default inFont.fromObjecttofalse.Testing
I tested headlessly in Chromium with the built extension, using Cal Sans VF (
opsz8–45) on a<p>at 44px.font-variation-settingsmain: sliders at opsz 8 → worker stopped → Inherit"opsz" 8, "wght" 400(stale)normalnormal"GEOM" 25, "wght" 400(no opsz)"GEOM" 25, "opsz" 8, "wght" 400autoOpsz)"GEOM" 25, "wght" 400Popup: the toggle reads "auto" on open. Moving the slider to 30 shows "30" and stores
autoOpsz: false. Clicking the toggle brings back "auto" andtrue, and the state survives reopening the popup. Only the opsz row gets the toggle.🤖 Generated with Claude Code