You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
agg_png renders blank PNG for grid.text + Calibri at certain font sizes (7.5, 8.0, 8.5, 9.5 pt) on Windows #219
When rendering text in Calibri to ragg::agg_png at certain fractional font sizes between roughly 6 and 10 pt, the entire PNG comes out blank (white) — silently, with no warning or error. The bug is independent of ggplot2 (reproducible with grid::grid.text alone) and the pattern is erratic by font size.
Minimal reproducible example
library(ragg); library(grid)
agg_png("blank.png", width=6, height=3.7, units="in", res=150)
grid.text("Hello",
gp= gpar(fontfamily="Calibri", fontsize=8))
dev.off()
file.info("blank.png")$size#> [1] 2850 # blank 906x559 white PNG (no text visible)
Font size sweep (Calibri, grid.text, agg_png at res = 150)
fontsize
Result
6.0
BLANK
6.5
BLANK
7.0
ok
7.5
BLANK
8.0
BLANK
8.5
BLANK
9.0
ok
9.5
BLANK
10.0
ok
10.5
ok
11.0+
ok
The same pattern reproduces via ggplot2 (which was how I first hit it). With theme_bw(base_size = 7, base_family = "Calibri") + labs(title = "Bug"), the default plot.title size is rel(1.2) × 7 = 8.4 pt — squarely in the broken zone — so adding a title to any plot causes the whole rendered PNG to be blank.
Control — Arial
Arial also exhibits blanks but at different sizes, suggesting this is a per-font glyph-rasterization issue (perhaps interaction with embedded bitmaps in Microsoft's TrueType files on Windows).
ggplot2 4.0.3 (for the ggplot variant — not needed to reproduce)
Calibri TTF: C:\Windows\Fonts\calibri.ttf, calibrib.ttf (default Microsoft Office font)
systemfonts::match_fonts("Calibri") resolves correctly to the TTF files. The issue manifests at rasterization time, not at font lookup. No warning or message is emitted.
Known workarounds
dpi = 96 or dpi = 300 may produce different sweep patterns (not exhaustively tested).
Use a different font family (base_family = "", "sans").
Switch device: grDevices::png(type = "cairo") or cairo_pdf renders correctly with Calibri at these sizes.
Happy to provide additional traces (e.g. raster bitmap dumps, systemfonts::font_info() output, or a sweep across res values) if useful.
Activity
thomasp85 commentedon Nov 12, 2026
Thanks for the report. Can I get you to try with the dev version? I've done a couple of fixes on areas I think may cause this