Indeed, that is pretty close, but this is closer:
Edit1.Width := canvas.TextWidth(Edit1.TExt) + 10;
But maybe 10 will not be sufficient for all fonts, I will try.
TEdit has some border spacings, but they seem to be ignored.
Edit: No, it does not work. If I set the FontSize of the TEdit to 26 only 50% of the characters are shown.
This seems to work so far:
Canvas.Font.Size := Edit1.Font.Size;
Edit1.Width := canvas.TextWidth(Edit1.TExt) + 10;