Custom font never renders italic (.italic() and markdown *…*) because the family holds a single Typeface
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start in Font.swift around line 217, where Font.custom builds a FontFamily from a single Typeface; inspect how that family handles requested italic styles. Compare the proposed sibling resource font approach with building the family from ResourceFont, and check existing font tests or add focused coverage for .italic() and Markdown emphasis. Done means custom fonts with an available italic face render italic on Android while regular text remains upright.
Written by the indexing model from the issue text.
Description
A custom font loaded with Font.custom("Spectral-Regular", size:) becomes a single-typeface family (FontFamily(customTypeface) in Font.swift, line 217 in 1.63.0). Compose does not synthesize italic for a family built from an android.graphics.Typeface, so anything that requests FontStyle.Italic on that font renders upright:
Text("…").font(.custom("Spectral-Regular", size: 15)).italic()- markdown emphasis:
Text(LocalizedStringKey("A *quiet* word")).font(.custom("Spectral-Regular", size: 15))renders the asterisks away but not the italic.
On iOS both render in the italic face (the system picks Spectral-Italic from the same family).
Reduced example (not run in isolation; observed in our app with spectral_regular.ttf and spectral_italic.ttf in res/font):
Text(LocalizedStringKey("Ce livre tient en une phrase : *le bonheur n'attend pas.*"))
.font(.custom("Spectral-Regular", size: 15))
The local fix we apply (works for us on device): when the resource name ends in _regular and a sibling _italic resource exists, build a two-face family from resource fonts:
let italique = name.hasSuffix("_regular") ? ctx.resources.getIdentifier(name.dropLast(8) + "_italic", "font", ctx.packageName) : 0
...
} else if italique != 0 {
fontFamily = FontFamily(androidx.compose.ui.text.font.Font(resId: fid, weight: FontWeight.Normal, style: androidx.compose.ui.text.font.FontStyle.Normal),
androidx.compose.ui.text.font.Font(resId: italique, weight: FontWeight.Normal, style: androidx.compose.ui.text.font.FontStyle.Italic))
}
A more general approach might be to build FontFamily from ResourceFont instead of a loaded Typeface, so Compose can at least synthesize the italic.
- Dominant language
- Swift
- Stars
- 334
- Forks
- 95
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from skiptools/skip-ui
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 4 days
All issues in skiptools/skip-ui
Similar issues
-
AndroidAssetManager(env:peer:) in AssetURLProtocol.swift doesn't compile for Android on the Swift nightlyPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
erkamyaman/unslop-anything#579 ·
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
erkamyaman/rust-anything#1311 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug priority:low status:queued
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day