Synthetic bold for fonts that have no bold face and no weight axis
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 57/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- computer-graphics, frontend
Research direction
Start in epaint’s font data and outline glyph rasterization, then check the font tweak UI because the issue identifies both as possible homes for the setting. Trace how outline bounds and strokes are handled, and compare the behavior for color glyphs and unchanged advance widths. Done means a per-font strength can thicken outline glyphs while leaving layout metrics unchanged.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
Some fonts have no bold face and no wght axis, for example MS Gothic and MS Mincho on Windows. egui has no way to draw such a font in bold: an app can register a separate font for bold text, or use a variable font's weight axis, but these fonts offer neither. Bold text therefore looks the same as regular text.
Other apps on Windows show these fonts in bold because GDI and DirectWrite thicken the glyphs themselves when no bold face exists. FreeType offers the same with its embolden functions.
Describe the solution you'd like
A per-font setting that thickens outline glyphs when they are rasterized: the stroke width added around each outline, as a fraction of the font size. An app could then register the regular font file a second time with this setting and use it for bold text.
I use this in a local patch of epaint 0.38.0. It adds embolden: f32 (default 0.0) to FontData. When rasterizing an outline glyph, the outline is stroked after it is filled, and the glyph bitmap is widened by half the stroke width on each side:
let stroke_width = f64::from(embolden.max(0.0) * metrics.scale);
let bounds = path
.control_box()
.inflate(stroke_width / 2.0, stroke_width / 2.0)
.expand();
// ...
ctx.fill_path(&path);
if stroke_width > 0.0 {
ctx.set_stroke(kurbo::Stroke::new(stroke_width));
ctx.stroke_path(&path);
}
Advance widths and metrics are unchanged, so the layout does not move. Color glyphs are not affected. With a strength of 1/24 of the font size (what FreeType uses), bold MS Gothic and MS Mincho look right on Windows 11.
FontTweak might be a more natural home for the setting. I put it in FontData only because egui's font tweak UI destructures FontTweak field by field, so a new field there also needs a UI change.
Describe alternatives you've considered
- A separate bold font file or a variable font's
wghtaxis: these fonts have neither. - Painting the text twice with a small horizontal offset: this only works for text the app paints itself, not for labels and other widgets, and it only thickens strokes horizontally.
Additional context
Related: #3218 (selecting a font weight). This request covers fonts that have no weight to select.
- Dominant language
- Rust
- Stars
- 32.6k
- Forks
- 2.5k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 71
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 emilk/egui
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
egui_extras: column resize cursor reverts to default between press and drag thresholdPossibly taken @2tsoftwareapp claimed this 8 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
`egui-wgpu` defaults to `PowerPreference::HighPerformance` instead of `None`Possibly taken @SEshaan claimed this 16 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
Similar issues
-
autofixer: follow-up triage: bug triage: classified triage: correctness triage: has-reproducer
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
tursodatabase/turso#13221 ·
Maintainers usually reply within 1 day
-
Update Wasmtime to 48.0.11 for RUSTSEC-2026-0648Possibly taken @flyingrobots claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
flyingrobots/edict#457 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
O-windows relnotes relnotes-needs-review relnotes-tracking-issue T-libs
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
approved
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
fritzprix/libr-agent#3266 ·
Maintainers usually reply within 1 day