xtd 0.2.0
Loading...
Searching...
No Matches

◆ measure_string() [6/7]

size_f xtd::drawing::graphics::measure_string ( const xtd::string text,
const xtd::drawing::font font,
int32  width,
const xtd::drawing::string_format format 
)

Measures the specified string when drawn with the specified xtd::drawing::font and formatted with the specified xtd::drawing::string_format.

Parameters
textxtd::string to measure.
fontxtd::drawing::font that defines the text format of the string.
widthMaximum width of the string in pixels.
formatxtd::drawing::string_format that represents formatting information, such as line spacing, for the string.
Remarks
The xtd::drawing::graphics::measure_string method is designed for use with individual strings and includes a small amount of extra space before and after the string to allow for overhanging glyphs. Also, the xtd::drawing::graphics::draw_string method adjusts glyph points to optimize display quality and might display a string narrower than reported byxtd::drawing::graphics::measure_string. To obtain metrics suitable for adjacent strings in layout (for example, when implementing formatted text), use the xtd::drawing::graphics::measure_character_ranges method or one of the xtd::drawing::graphics::measure_string methods that takes a xtd::drawing::string_format, and pass xtd::drawing::string_format::generic_typographic. Also, ensure the xtd::drawing::text::text_rendering_hint for the xtd::drawing::graphics is xtd::drawing::text::text_rendering_hint::anti_alias.