fix: load system fonts for OG image text rendering

usvg's default Options creates an empty fontdb, so no fonts are found
for text rendering regardless of what's installed. Load system fonts
into a fontdb::Database and set the default font family to Noto Sans.

Also picks up a formatting change to index.html from a linter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 16:17:17 +03:00
parent d539892b70
commit 1f2fea3427
4 changed files with 67 additions and 23 deletions

View File

@@ -22,3 +22,4 @@ chrono.workspace = true
clap.workspace = true
reqwest.workspace = true
resvg.workspace = true
fontdb.workspace = true

View File

@@ -360,7 +360,12 @@ fn render_contributions_png(
svg.push_str("</svg>");
// Rasterize at 1200x630
let tree = resvg::usvg::Tree::from_str(&svg, &resvg::usvg::Options::default())
let mut fontdb = fontdb::Database::new();
fontdb.load_system_fonts();
let mut opts = resvg::usvg::Options::default();
opts.fontdb = std::sync::Arc::new(fontdb);
opts.font_family = "Noto Sans".to_owned();
let tree = resvg::usvg::Tree::from_str(&svg, &opts)
.map_err(|e| format!("svg parse: {e}"))?;
let mut pixmap =