Multiple spaces are all trimmed: Leading / trailing spaces are removed, mid-text spaces are converted into a single space.
This includes markdown tricks, e.g. or "\ua0" , with use_markdown either FALSE or TRUE.
library(gridtext)
library(grid)
library(reprex)
# January is led by regular spaces, March is led by non-breaking spaces by using ALT+0160
text <- c(" January", "Feb ruary", " March", "\u00a0\u00a0\u00a0April", "____May", "Ju ne",
"July ")
x <- (1:7)/9 + 1/30
y <- rep(0.8, 7)
g <- richtext_grob(
text, x, y, halign = 0, hjust = 1,
rot = 45,
padding = unit(c(3, 6, 1, 3), "pt"),
r = unit(4, "pt"),
align_widths = TRUE,
box_gp = gpar(col = "black", fill = "cornsilk", use_markdown = FALSE)
)
grid.newpage()
grid.draw(g)

Created on 2024-02-01 with reprex v2.0.2