Commit ec8f0f7e authored by Michael W. Vogel's avatar Michael W. Vogel
Browse files

LCL: Fixed Canvas.TextExtend if system font is used for drawing. Issue #32319

git-svn-id: trunk@55757 -
parent 30a41701
......@@ -1762,12 +1762,39 @@ end;
Gets the width and height of a text
------------------------------------------------------------------------------}
function TCanvas.TextExtent(const Text: string): TSize;
var
DCIndex: Integer;
ARect: TRect;
procedure SaveState;
begin
if DCIndex <> 0 then exit;
DCIndex := SaveDC(FHandle);
end;
procedure RestoreState;
begin
if DCIndex = 0 then exit;
RestoreDC(FHandle, DCIndex);
end;
begin
Result.cX := 0;
Result.cY := 0;
if Text='' then exit;
RequiredState([csHandleValid, csFontValid]);
DCIndex := 0;
if Font.IsDefault then
begin
SaveState;
SelectObject(FHandle, OnGetSystemFont());
end;
ARect := Rect(0, 0, 0, 0);
GetTextExtentPoint(FHandle, PChar(Text), Length(Text), Result);
RestoreState;
end;
{------------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment