Reputation: 1
How to get the width and height of a specified number of characters, font Size, font type and font style?
Examples:
font size = 14 <br>
font type = "Times New Roman" <br>
font style = "Regular"<br>
No of Characters = 50<br>
What is the width and height?
Upvotes: 0
Views: 2764
Reputation:
In C++, look at the "GetTextExtent" functions. Example:
CDC * dc = GetDC();
dc->SelectObject(GetFont());//select the font you want to measure the text in
CSize size = dc->GetTextExtent(chars);//get the dimensions
size.cx;//width
size.cy;//height
For C#, use MeasureString
Upvotes: 1