This function is a small wrapper around css_string_as_length() and css_length_as_pixels().

css_string_as_pixels(x, percentage_as_fraction = TRUE, ...)

Arguments

x

Character string of a CSS value e.g. "12", "12px", "3em", "47%"

percentage_as_fraction

Default: TRUE means that if a value is given as "50 FALSE, then a numeric value of 50 would be returned.

...

other arguments passed to css_length_as_pixels()

Value

a numeric value for this length in pixels as best we can with limited knowledge

Details

This function does some naive conversions, and assumes the display is 96dpi.

For more control on the final result, the user is encouraged to use css_string_as_length() and hand-roll their own unit conversion to their display units. This can be tricky as some units rely on rendering viewport sizes and font-size on the root node - thus i'll leave that for the user to handle.