d2lang/d2 · critical

Failed to decompress SourceCodePro-Semibold: %v

Error message

Failed to decompress SourceCodePro-Semibold: %v

What it means

init()-time panic in the wasm d2fonts package when the embedded brotli-compressed SourceCodePro Semibold font fails to decompress. The last of the registered font faces; a failure aborts the entire wasm module during initialization.

Source

Thrown at d2renderers/d2fonts/d2fonts_embed_wasm.go:92

	} else {
		FontEncodings.Set(Font{Family: SourceSansPro, Style: FONT_STYLE_ITALIC}, str)
	}

	// Decompress and register SourceCodePro fonts
	if str, err := compression.DecompressBrotli(sourceCodeProRegularBr); err != nil {
		panic(fmt.Sprintf("Failed to decompress SourceCodePro-Regular: %v", err))
	} else {
		FontEncodings.Set(Font{Family: SourceCodePro, Style: FONT_STYLE_REGULAR}, str)
	}

	if str, err := compression.DecompressBrotli(sourceCodeProBoldBr); err != nil {
		panic(fmt.Sprintf("Failed to decompress SourceCodePro-Bold: %v", err))
	} else {
		FontEncodings.Set(Font{Family: SourceCodePro, Style: FONT_STYLE_BOLD}, str)
	}

	if str, err := compression.DecompressBrotli(sourceCodeProSemiboldBr); err != nil {
		panic(fmt.Sprintf("Failed to decompress SourceCodePro-Semibold: %v", err))
	} else {
		FontEncodings.Set(Font{Family: SourceCodePro, Style: FONT_STYLE_SEMIBOLD}, str)
	}

	if str, err := compression.DecompressBrotli(sourceCodeProItalicBr); err != nil {
		panic(fmt.Sprintf("Failed to decompress SourceCodePro-Italic: %v", err))
	} else {
		FontEncodings.Set(Font{Family: SourceCodePro, Style: FONT_STYLE_ITALIC}, str)
	}

	// Decompress and register FuzzyBubbles fonts
	if str, err := compression.DecompressBrotli(fuzzyBubblesRegularBr); err != nil {
		panic(fmt.Sprintf("Failed to decompress FuzzyBubbles-Regular: %v", err))
	} else {
		FontEncodings.Set(Font{Family: HandDrawn, Style: FONT_STYLE_REGULAR}, str)
		// HandDrawn has no italic, so reuse regular
		FontEncodings.Set(Font{Family: HandDrawn, Style: FONT_STYLE_ITALIC}, str)
	}

View on GitHub (pinned to 0d69dca6f5)

Solutions

  1. Verify sourceCodeProSemiboldBr with a standalone brotli decompressor
  2. Regenerate the semibold .br asset via the project's embed script
  3. Rebuild the wasm module from a clean upstream checkout
  4. Ensure compression toolchain matches the decompressor expectations
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := compression.DecompressBrotli(sourceCodeProSemiboldBr); err != nil {
    return fmt.Errorf("broken embedded SourceCodePro-Semibold asset: %w", err)
}

Prevention

When it happens

Trigger: Package init of the wasm build when compression.DecompressBrotli(sourceCodeProSemiboldBr) returns an error — corrupt, empty, or toolchain-incompatible embedded brotli blob.

Common situations: Custom wasm builds with mis-generated semibold asset; corrupted embedded binaries from build tooling; brotli version mismatch after regenerating fonts.

Related errors


AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31). Data as JSON: /api/errors/85662ddfcf807ebd. Report an issue: GitHub.