{"record":{"id":"74aa36c56aa6fa3f","repo":"slint-ui/slint","slug":"large-glyph-x-coordinate","errorCode":null,"errorMessage":"large glyph x coordinate","messagePattern":"large glyph x coordinate","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/passes/embed_glyphs.rs","lineNumber":491,"sourceCode":"\n                    SCALE_CONTEXT.with(|ctx| {\n                        let font_ref = swash_font_ref(font_to_use);\n                        let mut ctx = ctx.borrow_mut();\n                        let mut scaler = ctx\n                            .builder(font_ref)\n                            .size(*pixel_size as f32)\n                            .normalized_coords(normalized_coords)\n                            .build();\n                        let image = swash::scale::Render::new(&[swash::scale::Source::Outline])\n                            .format(swash::zeno::Format::Alpha)\n                            .render(&mut scaler, glyph_id);\n\n                        match image {\n                            Some(image) => {\n                                let p = image.placement;\n                                BitmapGlyph {\n                                    x: i16::try_from(p.left * 64)\n                                        .expect(\"large glyph x coordinate\"),\n                                    y: i16::try_from((p.top - p.height as i32) * 64)\n                                        .expect(\"large glyph y coordinate\"),\n                                    width: i16::try_from(p.width).expect(\"large width\"),\n                                    height: i16::try_from(p.height).expect(\"large height\"),\n                                    x_advance: i16::try_from((advance_width * 64.) as i64)\n                                        .expect(\"large advance width\"),\n                                    data: image.data,\n                                }\n                            }\n                            None => BitmapGlyph {\n                                x: 0,\n                                y: 0,\n                                width: 0,\n                                height: 0,\n                                x_advance: i16::try_from((advance_width * 64.) as i64)\n                                    .expect(\"large advance width\"),\n                                data: vec![],\n                            },","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/compiler/passes/embed_glyphs.rs#L473-L509","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before embedding, check bitmap glyph placement\nuse fontdue::Font; // or any font parser exposing placement\nlet fits_i16 = (p.left as i64 * 64).abs() <= i16::MAX as i64;\nassert!(fits_i16, \"bitmap glyph x placement too large for embedding\");","typeGuard":"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 }","tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","panic","compiler","fonts","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}