slint-ui/slint · error
more than 65535 glyphs are not supported
Error message
more than 65535 glyphs are not supported
What it means
This panic fires in the glyph-embedding pass (internal/compiler/passes/embed_glyphs.rs:400) while building the character map for embedded fonts. Glyph indices are stored as `u16` (matching font formats' 16-bit glyph ids), so if the accumulated `glyph_index` exceeds 65535 the `u16::try_from` fails and the `expect` panics. It means the font set being embedded produces more glyphs than the 16-bit glyph id space supports.
Solutions
- Subset the font before embedding: use tools like pyftsubset/fonttools to reduce the glyph count below 65535 and limit to needed code points.
- Use `EmbedResources::EmbedTextures` (SDF textures) or `DoNotEmbed` instead of glyph embedding for very large fonts.
- Remove unnecessary fallback fonts from the font chain so the combined glyph count stays within 16 bits.
- Split text across multiple smaller fonts if coverage requires more than 65535 glyphs.
Example fix
// before (shell) pyftsubset big.ttf # keeps too many glyphs // after pyftsubset big.ttf --unicodes=U+0020-007E,U+4E00-9FFF --glyph-names --layout-features='*'
Defensive patterns
Strategy: validation
Validate before calling
#!/bin/sh # check glyph count of fonts before enabling embed_glyphs python3 -c "from fontTools.ttLib import TTFont; import sys; f=TTFont(sys.argv[1]); n=f['maxp'].numGlyphs; sys.exit(1 if n>65535 else 0)" myfont.ttf || echo "subset the font first"
Prevention
- Subset large fonts (CJK/emoji) with fonttools/pyftsubset before embedding.
- Keep the fallback font chain short; each extra font adds glyphs.
- For huge coverage needs, switch to EmbedTextures/SDF or runtime font loading instead of glyph embedding.
When it happens
Trigger: Compiling with `embed_glyphs` (font glyph embedding enabled in `CompilerConfiguration`) on a font (or font + fallback fonts chain) where the enumerated glyph index passed 65535 — very large fonts, many merged fallback fonts, or fonts with malformed/oversized glyph tables.
Common situations: Embedded firmware builds with big CJK/emoji fonts embedded as glyphs; accidentally including multiple huge fallback fonts; using a broken/subsetted font with an inflated glyph table.
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 x coordinate
- large glyph y coordinate
- large width
- EmbedTextures builds the shared font collection
- a setter belongs to a field
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/eb9450e4562a744d.
Report an issue: GitHub.
Appendix: source
Thrown at internal/compiler/passes/embed_glyphs.rs:400
fallback_fonts: &[Font],
_compiler_config: &CompilerConfiguration,
normalized_coords: &[skrifa::instance::NormalizedCoord],
_variations: &[(skrifa::Tag, f32)],
override_weight: Option<u16>,
) -> BitmapFont {
let coords_i16: Vec<i16> = normalized_coords.iter().map(|c| c.to_bits()).collect();
let mut character_map: Vec<CharacterMapEntry> = character_coverage
.filter(|code_point| {
core::iter::once(&font)
.chain(fallback_fonts.iter())
.any(|font| swash_font_ref(font).charmap().map(*code_point) != 0)
})
.enumerate()
.map(|(glyph_index, code_point)| CharacterMapEntry {
code_point,
glyph_index: u16::try_from(glyph_index)
.expect("more than 65535 glyphs are not supported"),
})
.collect();
#[cfg(feature = "sdf-fonts")]
let glyphs = if _compiler_config.use_sdf_fonts {
embed_sdf_glyphs(pixel_sizes, &character_map, &font, fallback_fonts, _variations)
} else {
embed_alpha_map_glyphs(pixel_sizes, &character_map, &font, fallback_fonts, &coords_i16)
};
#[cfg(not(feature = "sdf-fonts"))]
let glyphs =
embed_alpha_map_glyphs(pixel_sizes, &character_map, &font, fallback_fonts, &coords_i16);
character_map.sort_by_key(|entry| entry.code_point);
let font_ref = skrifa::FontRef::from_index(font.font.blob.data(), font.font.index).unwrap();
let location = skrifa::instance::LocationRef::new(normalized_coords);
let metrics =View on GitHub (pinned to bb937076de)