You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(core): Android font-weight is ignored for custom fonts on API 26+ (no wght axis mapping) #11513
On Android API 26+, @nativescript/core loads custom font files through android.graphics.Typeface.Builder and passes font-variation-settings via setFontVariationSettings. For a variable font, the font-weight CSS property has no effect unless the caller also knows to pass an explicit 'wght' variation setting: loadFontFromFile never maps fontWeight onto the wght axis, so e.g. font-family: 'MyVariableFont'; font-weight: 700 renders at the font's default weight.
Two adjacent problems:
computeFontCacheKey keys the typeface cache only on family + explicit variation settings, so once the weight is forwarded (by workaround or fix), two weights of the same family collide in the cache.
If a font doesn't support the wght axis, builder.build() throws and there is no retry — the file load fails outright instead of falling back to the explicit variation settings.
Reproduction
On an API 26+ Android device/emulator with a variable font (e.g. fonts/Inter.var.ttf):
<LabelfontFamily="Inter.var"fontWeight="700"text="should be bold" />
The label renders at the font's default weight (400) because setFontVariationSettings is called with '' (no wght axis).
Proposed fix
In loadFontFromFile, inject { axis: 'wght', value: <numeric fontWeight> } into the variation settings when the caller did not set wght explicitly, include fontWeight in computeFontCacheKey, and retry the build with the caller's explicit settings if the wght-augmented build throws.
Environment
@nativescript/core 9.x, Android API 26+
I have a PR with this fix plus unit tests ready to submit.
Activity