Skip to content

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

Open

Description

@GuillaumeBiessy

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).

# Arial at res=150 / grid.text:
#  size 7.0 -> BLANK
#  size 7.5 -> BLANK
#  size 8.0 -> ok
#  size 8.5 -> ok
#  size 9.0 -> ok

Environment

  • R 4.5.3 (Windows 11 Pro 26200, 64-bit)
  • ragg 1.5.2
  • systemfonts 1.3.2
  • 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

  1. thomasp85 commented on Nov 12, 2026

    @thomasp85
    Member

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions