get_string_dimensions: Get String Dimensions

View source: R/get_string_dimensions.R

get_string_dimensionsR Documentation

Get String Dimensions

Description

Calculates font metrics for a specified font, font size, and style.

Usage

get_string_dimensions(string, font = "sans", size = 12, align = "center", ...)

Arguments

string

The string to be measured.

font

Default "sans".

size

A numeric value specifying the size of the font in points.

align

Default '"left"“. The string alignment.

...

Other arguments to pass to 'systemfonts::shape_string()“

Details

The function renders specific characters ("d" for ascender, "g" for descender, "x" for neutral) using the specified font parameters. It calculates the bounding box of each character to determine the necessary adjustments for accurate text positioning.

Value

A data.frame listing the string dimensions.

Examples

# Get height of basic sans font
get_string_dimensions("This is a string", size=24)

rayimage documentation built on April 3, 2025, 9:39 p.m.