@@ -407,7 +407,11 @@ func collectFonts(scopes []platform.InstallationScope, fm platform.FontManager,
407407 }
408408
409409 // Build ParsedFont struct using extracted function
410- parsed = append (parsed , buildParsedFont (p , name , scope , info ))
410+ parsedFont := buildParsedFont (p , name , scope , info )
411+ // Skip invalid font files (returns nil)
412+ if parsedFont != nil {
413+ parsed = append (parsed , * parsedFont )
414+ }
411415 }
412416 }
413417 if ! shouldSuppressVerbose {
@@ -421,7 +425,8 @@ func collectFonts(scopes []platform.InstallationScope, fm platform.FontManager,
421425}
422426
423427// buildParsedFont extracts font metadata from a file path and builds a ParsedFont struct
424- func buildParsedFont (fontPath , fileName string , scope platform.InstallationScope , fileInfo os.FileInfo ) ParsedFont {
428+ // Returns nil if the font file is invalid and should be skipped
429+ func buildParsedFont (fontPath , fileName string , scope platform.InstallationScope , fileInfo os.FileInfo ) * ParsedFont {
425430 // Extract file extension for type
426431 fileExt := strings .ToUpper (strings .TrimPrefix (filepath .Ext (fileName ), "." ))
427432
@@ -443,13 +448,20 @@ func buildParsedFont(fontPath, fileName string, scope platform.InstallationScope
443448 style = md .StyleName
444449 }
445450 } else {
446- // Fallback to filename parsing (minimal)
451+ // Check if this is an invalid font file error - if so, skip it
452+ if errors .Is (err , platform .ErrInvalidFontFile ) {
453+ // Log debug info but don't include in list
454+ output .GetDebug ().Warning ("Skipping invalid font file: %s (%v)" , fontPath , err )
455+ return nil
456+ }
457+ // For other errors (e.g., parsing issues but file might still be valid), use filename fallback
458+ // This handles edge cases where metadata extraction fails but file structure is OK
447459 base := strings .TrimSuffix (fileName , filepath .Ext (fileName ))
448460 family = base
449461 style = "Regular"
450462 }
451463
452- return ParsedFont {
464+ return & ParsedFont {
453465 Name : fileName ,
454466 Family : family ,
455467 Style : style ,
0 commit comments