一、Canvas:
String s1="发的是浪费空间";
Canvas->Font->Color=clRed;
Canvas->Font->Name="微软雅黑";
Canvas->Font->Size=24;
int width=Canvas->TextWidth(s1);//是的 你获取了当前字体下该字符串的宽度
int height=Canvas->TextHeight(s2);//是的 你获取了当前字体下该字符串的高度
二、API:
BOOL GetCharWidth(
HDC hdc, // handle of device context
UINT iFirstChar, // first character in range to query
UINT iLastChar, // last character in range to query
LPINT lpBuffer // address of buffer for widths
);
标签:Canvas,下该,int,character,获取,宽度,字体,Font
From: https://blog.51cto.com/u_15487030/7523352