Previously if you tried to use thematic to render a plot with a google font but were not using a ragg device and didnt have showtext installed, the plot would fail for ggplot2 and simply have no text for base graphics.
This is because the logic to warn about not having a package installed only was triggered if bothragg and showtext were not installed. If the user has ragg installed but isnt using it, e.g. plotting to the viewer pane or running shiny without setting options("shiny.useragg" = TRUE), the warning gave no hint as to why it was not working.
Additionally, now the font is just set back to default instead of failing in these scenarios. This means fewer catastrophic failures and the new warning message doesn't get buried by a bunch of grid warnings from trying to render the non-existent font.
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
In addition: There were 50 or more warnings (use warnings() to see the first 50)
But work when showtext is reinstalled.
With this PR the result is:
Warning message:
It seems the current graphics device 'RStudioGD' is unable to render the requested font family 'Righteous'. To render custom fonts, either use a ragg device or install the showtext package
With the resulting plot of
Unit tests
Based on conversations with @wch , we don't think it's possible to write unit tests that fit in the normal workflow for this so there are none.
Previously if you tried to use thematic to render a plot with a google font but were not using a
ragg
device and didnt haveshowtext
installed, the plot would fail forggplot2
and simply have no text for base graphics.This is because the logic to warn about not having a package installed only was triggered if both
ragg
andshowtext
were not installed. If the user hasragg
installed but isnt using it, e.g. plotting to the viewer pane or running shiny without settingoptions("shiny.useragg" = TRUE)
, the warning gave no hint as to why it was not working.Additionally, now the font is just set back to default instead of failing in these scenarios. This means fewer catastrophic failures and the new warning message doesn't get buried by a bunch of
grid
warnings from trying to render the non-existent font.Example
You can recreate this behavior by running
Which will fail with the error
But work when
showtext
is reinstalled.With this PR the result is:
With the resulting plot of
Unit tests
Based on conversations with @wch , we don't think it's possible to write unit tests that fit in the normal workflow for this so there are none.
Relevant issues
This is related to https://github.com/rstudio/thematic/issues/78 and https://github.com/rstudio/thematic/issues/77