CL_TextStyler::get_width - ClanLib Game SDK

Home | All Classes | Grouped Classes | Index | Search

# CL_TextStyler::get_width

Returns the drawn width of some source text.

    	int get_width(
    		const std::string& str, CL_Size max_size = CL_Size(0, 0));

    	int get_width(
    		std::string::const_iterator start, std::string::const_iterator end, CL_Size max_size = CL_Size(0, 0));

Parameters:

str
  The source string to parse and render.
start
  A starting iterator, inclusive.
end
  An ending iterator, exclusive.
max_size
  Acts like the size of a dest rectangle passed to draw(), for height truncating and word wrapping.

Return value:

The width in pixels.

Detailed description:

Newlines have a width of zero unless you gave them a glyph (which is pretty useless anyways). Other unknown characters have the width of a space in their respective font.

See also:

CL_Size | CL_TextStyler

Questions or comments, write to the ClanLib mailing list.