d2lang/d2 · critical

Failed to decompress SourceSansPro-Bold: %v

Error message

Failed to decompress SourceSansPro-Bold: %v

What it means

Same init()-time brotli decompression as the other embedded fonts, but for the SourceSansPro Bold face. A failed DecompressBrotli on the embedded bold font blob panics during package initialization. Cause is a corrupt/mismatched embedded asset in the wasm build.

Source

Thrown at d2renderers/d2fonts/d2fonts_embed_wasm.go:61

//go:embed encoded/FuzzyBubbles-Bold.txt.br
var fuzzyBubblesBoldBr []byte

//go:embed ttf/*
var fontFacesFS embed.FS

func init() {
	FontEncodings = syncmap.New[Font, string]()

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

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

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

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

	// Decompress and register SourceCodePro fonts
	if str, err := compression.DecompressBrotli(sourceCodeProRegularBr); err != nil {

View on GitHub (pinned to 0d69dca6f5)

Solutions

  1. Verify and regenerate sourceSansProBoldBr (test decompression standalone)
  2. Re-run the project's font embedding/wasm build script from a clean checkout
  3. Confirm the brotli library version used at compression matches the decompressor
  4. Replace the asset from upstream if only this file is broken

Example fix

null
Defensive patterns

Strategy: fallback

Validate before calling

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

Prevention

When it happens

Trigger: Package init of the wasm d2fonts build when sourceSansProBoldBr fails to decompress; occurs at wasm instantiation/load, before any rendering call.

Common situations: Regenerating font .br files with an incompatible brotli version; build pipeline embedding truncated or stale assets; editing embedded blobs by hand.

Related errors


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