slint-ui/slint · error

large width

Error message

large width

What it means

In the embed-glyphs pass, the bitmap glyph's width (`image.placement.width`) must fit in i16 because that is the field width in the compiled glyph structure. Panics when a glyph bitmap is wider than 32767 pixels.

Solutions

  1. Validate the font file (e.g. with fonttools/ots-sanitize) and fix or replace it
  2. Regenerate the bitmap font with sane glyph dimensions (< 32768 px wide)
  3. Exclude the font from embedding or drop its bitmap tables
Defensive patterns

Strategy: validation

Validate before calling

assert!(p.width <= i16::MAX as u32, "bitmap glyph wider than i16");

Type guard

fn glyph_width_fits(width: u32) -> bool { width <= i16::MAX as u32 }

Prevention

When it happens

Trigger: Embedding a font whose bitmap glyph `placement.width` exceeds i16::MAX — practically only possible with a corrupt or absurdly generated bitmap font.

Common situations: Corrupted font files; font-generation tools producing giant bitmap strikes.

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


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/17f10c9d346e8187. Report an issue: GitHub.

Appendix: source

Thrown at internal/compiler/passes/embed_glyphs.rs:494

                        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)