Home > Back-end >  grid.text() not rendering on PDF
grid.text() not rendering on PDF

Time:04-16

Trying to understand why grid.text("Name") displays in my RStudio plots window but doesn't render on PDF output.

extrafont::loadfonts()
colors = c("#FFFFFF", "#232D69")
Logo = jpeg::readJPEG("picture.jpg", native=T)

# Layout
library(grid)
library(gridExtra)
pdf(file="Test.pdf", width=10,height=10)
grid.newpage() #Create page
grid.rect(gp = gpar(fill = colors[2], col = colors[2])) #Background color
grid.rect(gp = gpar(fill = colors[1], col = colors[1]), x = unit(0, "npc"), y = unit(1, "npc"), width = unit(2, "npc"), height = unit(0.5, "npc"))
grid.raster(Logo, x = 0.1, y = 0.9, width = 0.15)
grid.text("Name", y = unit(0.90, "npc"), gp = gpar(fontfamily = "Arial", col = colors[2], cex = 3))
dev.off()


CodePudding user response:

With reference to this link grid finds font when run in console but not when rendering Rmd using specific pdf function will solve the issue.

  •  Tags:  
  • r
  • Related