Visitar URL original
fix(android): map font-weight to the wght axis for custom fonts on API 26+ by aleclarson · Pull Request #11514 · NativeScript/NativeScript · GitHub
Skip to content

fix(android): map font-weight to the wght axis for custom fonts on API 26+ - #11514

Open
aleclarson wants to merge 1 commit into
NativeScript:mainfrom
aleclarson:fix/android-font-weight-wght
Open

aleclarson wants to merge 1 commit into
NativeScript:mainfrom
aleclarson:fix/android-font-weight-wght

Conversation

@aleclarson

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

On Android API 26+, custom fonts loaded from files ignore CSS font-weight: loadFontFromFile passes only explicit font-variation-settings to Typeface.Builder.setFontVariationSettings, so a variable font with font-weight: 700 renders at its default weight. computeFontCacheKey also omits the weight, so two weights of the same family would collide in the typeface cache. And if a font doesn't support the wght axis, builder.build() throws with no retry — the file load fails outright.

What is the new behavior?

  • A wght axis entry derived from fontWeight (getNumericFontWeight) is appended to the variation settings unless the caller set wght explicitly — explicit settings always win.
  • fontWeight joins the typeface cache key, so weights of one family cache independently.
  • If the augmented build throws, the load retries once with the caller's explicit settings (fonts that lack the wght axis still load). If the caller did request wght explicitly, the error propagates to the outer catch as before and the font falls back to the default typeface — no retry of a request the caller made.

Fixes #11513

…I 26+

Variable fonts loaded from files ignored CSS font-weight: the Typeface
Builder received only explicit font-variation-settings, so font-weight: 700
rendered at the font's default weight. The typeface cache key also lacked
the weight, so two weights of the same family would collide once the axis
is honored.

Inject a wght axis entry derived from fontWeight unless the caller set wght
explicitly, include fontWeight in the cache key, and retry with the
caller's explicit settings when the augmented build throws (font lacking
the wght axis).

Closes NativeScript#11513
@nx-cloud

nx-cloud Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit f2843f7

Command Status Duration Result
nx run-many -t build -p core,webpack5,vite ✅ Succeeded 20s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-08 01:49:12 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11514
npm i https://pkg.pr.new/@nativescript/vite@11514
npm i https://pkg.pr.new/@nativescript/webpack@11514

commit: f2843f7

aleclarson added a commit to octane-xplat/octane-xplat that referenced this pull request Oct 8, 2026
Filed upstream PRs for the five patch-audit fixes and recorded them via a
new upstreamPR field on the manifest entries:

- nativescript-community/octane#14 — setProp undefined-skip, visibility
  capability, intrinsic ref types
- nativescript-community/octane#15 — vite-octane .tsrx HMR matching and
  recipients counting
- nativescript-community/ui-image#69 — iOS prefetch cacheType + headers
- nfrasser/linkifyjs#572 — ICU-free \p{} regex construction
- facebook/lexical#9334 — @lexical/link URL_REGEX via new RegExp
- NativeScript/NativeScript#11514 — font-weight → wght axis mapping on
  Android (issue #11513)

This branch has not been deployed

No deployments
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.

fix(core): Android font-weight is ignored for custom fonts on API 26+ (no wght axis mapping)

1 participant