{"record":{"id":"e0ced2ef84fe8938","repo":"wezterm/wezterm","slug":"failed-to-get-font-data","errorCode":null,"errorMessage":"Failed to get font data","messagePattern":"Failed to get font data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wezterm-font/src/locator/gdi.rs","lineNumber":58,"sourceCode":"\n        let ttc_size = GetFontData(hdc, ttc_table, 0, std::ptr::null_mut(), 0);\n\n        let data = if ttc_size > 0 && ttc_size != GDI_ERROR {\n            let mut data = vec![0u8; ttc_size as usize];\n            GetFontData(hdc, ttc_table, 0, data.as_mut_ptr() as *mut _, ttc_size);\n\n            Ok(data)\n        } else {\n            // Otherwise: presumably a regular ttf\n\n            let size = GetFontData(hdc, 0, 0, std::ptr::null_mut(), 0);\n            match size {\n                _ if size > 0 && size != GDI_ERROR => {\n                    let mut data = vec![0u8; size as usize];\n                    GetFontData(hdc, 0, 0, data.as_mut_ptr() as *mut _, size);\n                    Ok(data)\n                }\n                _ => Err(anyhow::anyhow!(\"Failed to get font data\")),\n            }\n        };\n        DeleteDC(hdc);\n        let data = data?;\n\n        Ok(FontDataSource::Memory {\n            data: Arc::new(data.into_boxed_slice()),\n            name: name.to_string(),\n        })\n    }\n}\n\nfn extract_font_data(\n    font: HFONT,\n    attr: &FontAttributes,\n    pixel_size: u16,\n) -> anyhow::Result<ParsedFont> {\n    let source = extract_raw_font_data(font, &attr.family)?;","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/wezterm/wezterm/blob/9c04f79f86649f76a8c978ff4b674f60297a6ec9/wezterm-font/src/locator/gdi.rs#L40-L76","documentation":"In the Windows GDI locator, extract_raw_font_data calls GetFontData twice: once for the 'ttcf' table (TrueType Collection) and once for the whole file. If both calls return 0 or GDI_ERROR, the HFONT has no byte stream GDI can expose, and the function bails. GetFontData only works for TrueType/OpenType fonts backed by a readable file; it fails for Type 1, vector, bitmap (.FON/.FNT) and some cloud-streamed fonts.","triggerScenarios":"GdiFontLocator processes an installed system font whose data GDI cannot read: legacy bitmap/vector fonts, Type-1 .PFB fonts, fonts stubbed by cloud/subscription font services, or a corrupted font file. The error names the family in surrounding logs and that font is skipped from discovery.","commonSituations":"Windows boxes with old bitmap fonts (e.g. legacy terminal/FON fonts) or enterprise font-management agents installed. The rest of wezterm keeps working; the message appears during startup font enumeration and users hit it when the skipped font was the one they configured.","solutions":["Identify the failing family from the adjacent log line and remove or reinstall that font as a proper TTF/OTF (right-click -> Install on the .ttf file)","Replace legacy .FON/Type-1 fonts with modern equivalents (e.g. Cascadia Mono, JetBrains Mono)","If the font is optional, point wezterm at a known-good TTF via font_dirs + wezterm.font in wezterm.lua so discovery of the broken font does not matter"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# before pointing wezterm at a font, confirm GDI can expose its data\npowershell \"(Get-Item 'C:\\Windows\\Fonts\\MYFONT.TTF').Length\"  # must be a real TTF/OTF/TTC file, not a .FON/.PFM stub","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install only well-formed TTF/OTF fonts; avoid legacy .FON/Type-1 fonts on systems running wezterm","Review wezterm startup logs after installing new fonts and remove any family that logs a GetFontData failure","Scope discovery with font_dirs pointing at directories you control"],"tags":["windows","gdi","getfontdata","font-locator","font-file"],"backgroundTag":"font-data-extraction-failed","analyzedSha":"9c04f79f86649f76a8c978ff4b674f60297a6ec9","analyzedAt":"2026-08-16T21:23:27.157Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}