showtext
showtext copied to clipboard
Provide a grid grob
This would be useful for people using grid graphics (e.g. ggplot2) so that you don't need to mess text rendering globally.
Hi Hadley,
Could you explain a little bit more about this issue?
I believe showtext
is only in the device level, in charge of rendering text.
Grob is more like a description of text, so it stays in the R level and will not be affected by showtext
.
Currently showtext has global effect - it modifies all text rendering. But it would nice to be able to have local effect, so you could selectively use showTextGrob()
. The behaviour would be identical, just the scope would be different.
OK, now I understand the problem.
For base graphics, users can call showtext.begin()
and showtext.end()
to control the text rendering scope, but for grid graphics, since all graphics components are stored as an R object and then sent to graphics device in a batch, users cannot inject code in between plotting actions.
There may be some difficulties to fix this issue, since the current showtext
works in the graphics device level, while grob lies in the graphics system level. Theoretically devices cannot see the outer world, for example it cannot tell whether one plotting action (such as drawing a circle) is from a base plot or a grid plot. It is only in charge of the rendering part.
I'm not so familiar with the grid system, so I have a few questions here: If I define a grob called showTextGrob()
, can I customize how it will be plotted in the R level? If this is possible, one simple solution is to insert a showtext.begin()
call inside the plotting method of this grob, and call showtext.end()
when exitting.
If the answer is positive, I will then read some materials about grid system and grob customization.