The background of the credits text is not wide enough.
If I generate PNG file instead of PDF with the script below, then the background is too wide:

library(sf)
library(tmap)
lon_min <- -6.375
lon_max <- -5.37
lat_min <- 52.96
lat_max <- 53.8
coords <- matrix(c(lon_min, lat_min,
lon_max, lat_min,
lon_max, lat_max,
lon_min, lat_max,
lon_min, lat_min),
ncol=2,
byrow=TRUE)
bbox = st_polygon(list(coords)) |> st_sfc(crs=4326)
data.sf = st_sf(band=1:1, polygon=bbox)
credits = 'quite long, but ok.\nmuch longer, much longer, much longer.'
p = (tm_basemap('CartoDB.Positron')
+ tm_shape(data.sf, bbox=bbox)
+ tm_sf(fill='red', fill_alpha=0.01)
+ tm_credits(credits,
position=c('right', 'bottom'),
size=0.3,
bg=T,
bg.color='white',
bg.alpha=0.5))
tmap_save(p, file='bug-tmap-credits.pdf', width=3840, asp=0, unit='px')
Please consider the following script, which generates PDF file: bug-tmap-credits.pdf.
The background of the credits text is not wide enough.
Changing font size to 1 in
tm_creditsseems to render the background properly.If I generate PNG file instead of PDF with the script below, then the background is too wide:
