slint-ui/slint · error

large glyph y coordinate

Error message

large glyph y coordinate

What it means

Same embed-glyphs pass as the x-coordinate variant: the bitmap glyph's y offset, computed as `(p.top - p.height) * 64` (26.6 fixed-point), must fit into i16 for the compiled glyph table. Panics via `.expect("large glyph y coordinate")` when it does not.

Solutions

  1. Regenerate or replace the bitmap font so vertical glyph placement stays within ±512 px
  2. Avoid embedding the offending bitmap glyphs (use a different font or drop the bitmap tables)
  3. File an upstream issue if the range is genuinely needed
Defensive patterns

Strategy: validation

Validate before calling

let fits_i16 = ((p.top - p.height as i32) as i64 * 64).abs() <= i16::MAX as i64;
assert!(fits_i16, "bitmap glyph y placement too large for embedding");

Type guard

fn glyph_y_fits(top: i32, height: u32) -> bool { let v = (top - height as i32) as i64 * 64; v >= i16::MIN as i64 && v <= i16::MAX as i64 }

Prevention

When it happens

Trigger: Compiling a .slint file with an embedded bitmap font whose glyph y placement `(top - height) * 64` overflows i16 (beyond roughly ±512 px).

Common situations: Malformed or unusually generated bitmap/emoji fonts with glyph bitmaps positioned far from the baseline origin.

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/180b32be46425059. Report an issue: GitHub.

Appendix: source

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

                        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)