Look for embedded paywall fonts in public/assets#3571
Conversation
Capacitor apps that use our paywalls SDK place bundled fonts in src/main/assets/public/assets/ (AssetManager path public/assets/), but the SDK only searched assets/fonts/. As a result those locally bundled fonts were missed and the SDK fell through to downloading them. Search public/assets/ after fonts/ in both the pre-download bundled-font check and the render-time asset font resolution. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3571 +/- ##
==========================================
+ Coverage 80.28% 80.30% +0.01%
==========================================
Files 377 377
Lines 15386 15387 +1
Branches 2134 2135 +1
==========================================
+ Hits 12353 12356 +3
Misses 2174 2174
+ Partials 859 857 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| private val assetsFontsDir = "fonts" | ||
| // Directories within the app's assets where embedded fonts may be bundled, searched in order. | ||
| // "public/assets" is where Capacitor apps that use our paywalls SDK place their fonts. | ||
| private val assetsFontsDirs = listOf("fonts", "public/assets") |
There was a problem hiding this comment.
So it's kinda assets/public/assets? 😅 Did you happen to check the fonts are really at this path?
There was a problem hiding this comment.
Great question! So... basically it depends on where in the original capacitor location the fonts are 😅 . If in the capacitor app, the fonts are inside public/assets, then, they are copied to assets/public/assets. If they have it in /public/fonts then they would be in assets/public/fonts. So this depends a bit on the implementation in Capacitor TBH... These comments certainly make it seem like this is the standard in Capacitor, even though there isn't any, so I will update those... And well, for other places, I think the common is to have either an assets or fonts folder, so maybe we could add that public/fonts folder too... but I'm afraid of doing too many disk checks... Wdyt?
There was a problem hiding this comment.
public/assets is the default or most used right? (I seem to remember that.) If so, maybe we can check just that folder, and add more if customers ask about it?
There was a problem hiding this comment.
Agreed, that seems like a sensible approach.
Why
Capacitor apps that use our paywalls SDK under the hood bundle their fonts into
src/main/assets/public/assets/(which maps to the AssetManager pathpublic/assets/at runtime). The SDK only ever looked inassets/fonts/, so these locally bundled fonts were never found and the SDK fell through to downloading them over the network instead of using the local copy.What
Search
public/assets/in addition tofonts/when resolving embedded fonts, in both places that look up bundled fonts:OfferingFontPreDownloader— the pre-download "is this font bundled?" check that decides whether to skip the download.PaywallResourceProvider.getAssetFontPaths— the render-time asset font resolution.Note
Low Risk
Narrow change to asset font path resolution with ordered fallback and tests; no auth, billing, or network contract changes beyond skipping unnecessary font downloads when assets are found.
Overview
Embedded paywall fonts are now resolved from
public/assets/in addition tofonts/, so Capacitor apps that bundle fonts underpublic/assetsare treated as local copies instead of triggering network downloads.OfferingFontPreDownloaderwalks an ordered list of asset directories when deciding if a font is bundled (skipping pre-download).PaywallResourceProvider.getAssetFontPathsuses the same ordered search at render time, withfonts/winning when the same.ttfexists in both places.Tests cover Capacitor-style fonts in
public/assets, precedence, and missing fonts;MockResourceProvidertest data was aligned with thefonts/path shape.Reviewed by Cursor Bugbot for commit 36173ed. Bugbot is set up for automated code reviews on this repo. Configure here.