systemfonts
systemfonts copied to clipboard
`shape_text()` gives unexpected `y_offset` when `vjust = 1`.
Hello there,
Thank you for this package, I've found it very useful!
I think I might have found an inconsistency in the shape_string()
function that (probably) gives an incorrect value for the y_offset
parameter when vjust == 1
.
library(systemfonts) # v1.0.3
vjust <- seq(-1, 2, by = 0.01)
get_y_offset <- function(vjust) {
ans <- shape_string(rep("ABCdefGHIjkl", length(vjust)), vjust = vjust)$shape
ans$y_offset[!duplicated(ans$metric_id)]
}
plot(vjust, get_y_offset(vjust), type = 'l')
This seems to occur only at 1; very small offsets appear to alleviate the problem.
get_y_offset(1 + .Machine$double.eps)
#> [1] -10.85938
get_y_offset(1 - .Machine$double.eps)
#> [1] -10.84375
get_y_offset(1L)
#> [1] 0
Created on 2021-11-21 by the reprex package (v2.0.1)
As a sidenote; is there any thought about shape_text()
's lifecycle? I find it very useful and I'm hoping it becomes stable at some point.
Thanks - that does look weird. I'll have a look at it.
The future of shape_text()
is not going to disappear, but I don't know in what form it will stabilise. We are still looking at how rich text is best supported at the device level so shape_text might change to accommodate whatever gets decided