Changing the font of a Delphi TLabel to Italic chops off the tail - why?

Brian Frost picture Brian Frost · May 26, 2011 · Viewed 8.2k times · Source

A simple demo of a default TLabel with font set to Arial Regular 16 is shown below. enter image description here

The code when the button is clicked is:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Font.Style := Label1.Font.Style + [fsItalic];
end;

When you click the button, the last character is truncated viz:

enter image description here

By default, TLAbel.AutoSize is true so this should be ok, right? This is in XE and Delphi 7 is the same. Is this a bug?

Answer

Tim picture Tim · May 26, 2011

An extra space at the end is a quick work around for this.