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:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user