Skip to content

Look for embedded paywall fonts in public/assets#3571

Merged
tonidero merged 3 commits into
mainfrom
font-public-assets-location
Jun 10, 2026
Merged

Look for embedded paywall fonts in public/assets#3571
tonidero merged 3 commits into
mainfrom
font-public-assets-location

Conversation

@tonidero

@tonidero tonidero commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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 path public/assets/ at runtime). The SDK only ever looked in assets/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 to fonts/ 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 to fonts/, so Capacitor apps that bundle fonts under public/assets are treated as local copies instead of triggering network downloads.

OfferingFontPreDownloader walks an ordered list of asset directories when deciding if a font is bundled (skipping pre-download). PaywallResourceProvider.getAssetFontPaths uses the same ordered search at render time, with fonts/ winning when the same .ttf exists in both places.

Tests cover Capacitor-style fonts in public/assets, precedence, and missing fonts; MockResourceProvider test data was aligned with the fonts/ path shape.

Reviewed by Cursor Bugbot for commit 36173ed. Bugbot is set up for automated code reviews on this repo. Configure here.

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

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.30%. Comparing base (2ba14c8) to head (36173ed).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...at/purchases/paywalls/OfferingFontPreDownloader.kt 80.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@tonidero tonidero marked this pull request as ready for review June 9, 2026 14:21
@tonidero tonidero requested review from a team as code owners June 9, 2026 14:21
@tonidero tonidero requested review from a team and JayShortway June 9, 2026 14:21

@rickvdl rickvdl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

@JayShortway JayShortway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to get this in! 🙌

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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's kinda assets/public/assets? 😅 Did you happen to check the fonts are really at this path?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, that seems like a sensible approach.

@tonidero tonidero enabled auto-merge June 10, 2026 07:46
@tonidero tonidero added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit 1082cfd Jun 10, 2026
37 checks passed
@tonidero tonidero deleted the font-public-assets-location branch June 10, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants