function TCustomCanvas.TextWidth(const Text: string): Integer;
begin
Result := TextExtent(Text).cX;
end;
function TCanvas.TextExtent(const Text: string): TSize;
begin
RequiredState([csHandleValid, csFontValid]);
Result.cX := 0;
Result.cY := 0;
Winapi.Windows.GetTextExtentPoint32(FHandle, Text, Length(Text), Result);
end;