slint-ui/slint · error
large glyph x coordinate
Error message
large glyph x coordinate
What it means
During the embed-glyphs compiler pass, a font's bitmap glyph placement (`image.placement.left * 64`, in 26.6 fixed-point) is converted to i16 for the compiled glyph table. If the x offset does not fit in an i16, the `.expect("large glyph x coordinate")` panics. This is a hard sanity limit of the binary glyph encoding, not a bug in user code.
Solutions
- Replace the font with a normally generated one; re-generate the bitmap font so glyph x placements stay within ±512 px
- If the font is only needed for regular glyphs, disable bitmap/emoji glyph embedding so this code path is not exercised
- If you legitimately need huge offsets, file an upstream issue to widen the storage type; do not patch the expect in application code
Defensive patterns
Strategy: validation
Validate before calling
// before embedding, check bitmap glyph placement use fontdue::Font; // or any font parser exposing placement let fits_i16 = (p.left as i64 * 64).abs() <= i16::MAX as i64; assert!(fits_i16, "bitmap glyph x placement too large for embedding");
Type guard
fn glyph_x_fits(left_px: i32) -> bool { (left_px as i64 * 64) >= i16::MIN as i64 && (left_px as i64 * 64) <= i16::MAX as i64 } Prevention
- Sanitize fonts with ots-sanitize or fonttools before embedding
- Regenerate bitmap fonts with placements within ±512 px
- Test the build with all embedded fonts early in CI
When it happens
Trigger: Compiling a .slint file whose embedded font contains a bitmap (embedded/emoji/color) glyph whose `placement.left * 64` is less than -32768 or greater than 32767, i.e. a glyph x-offset beyond about ±512 pixels.
Common situations: Using a corrupted or pathologically-generated bitmap font (e.g. an CBDT/sbix font with glyphs placed extremely far off the origin), or a font tool mis-generating glyph placement metadata.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- large glyph y coordinate
- large width
- more than 65535 glyphs are not supported
- a setter belongs to a field
- an identifier
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/74aa36c56aa6fa3f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/compiler/passes/embed_glyphs.rs:491
SCALE_CONTEXT.with(|ctx| {
let font_ref = swash_font_ref(font_to_use);
let mut ctx = ctx.borrow_mut();
let mut scaler = ctx
.builder(font_ref)
.size(*pixel_size as f32)
.normalized_coords(normalized_coords)
.build();
let image = swash::scale::Render::new(&[swash::scale::Source::Outline])
.format(swash::zeno::Format::Alpha)
.render(&mut scaler, glyph_id);
match image {
Some(image) => {
let p = image.placement;
BitmapGlyph {
x: i16::try_from(p.left * 64)
.expect("large glyph x coordinate"),
y: i16::try_from((p.top - p.height as i32) * 64)
.expect("large glyph y coordinate"),
width: i16::try_from(p.width).expect("large width"),
height: i16::try_from(p.height).expect("large height"),
x_advance: i16::try_from((advance_width * 64.) as i64)
.expect("large advance width"),
data: image.data,
}
}
None => BitmapGlyph {
x: 0,
y: 0,
width: 0,
height: 0,
x_advance: i16::try_from((advance_width * 64.) as i64)
.expect("large advance width"),
data: vec![],
},View on GitHub (pinned to bb937076de)