https://www.cnblogs.com/gaodu2003/archive/2009/06/12/1502242.html
方法一:
var
CharX, CharY: Integer;
with Canvas do
begin
Font.Name := ‘宋体‘;
Size := 9;
CharX := TextExtent(‘字符串‘).cx; //字符串宽度,单位为像素
CharY := TextExtent(‘字符串‘).cy; //字符高度,单位为像素
end;
方法二:
var
s: TSize;
with Canvas do
begin
Font.Name := ‘宋体‘;
Size := 9;
s := TextExtent(‘字符串‘);
ShowMessage(Format(‘字宽:%d 字高:%d‘, [s.cx, s.cy]);
end;
原文地址:https://www.cnblogs.com/gaodu2019/p/10935778.html
时间: 2024-11-09 09:29:56