mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 11:49:28 +02:00
Corrects the partial width calculations in GetTextExtentEx
git-svn-id: trunk@33541 -
This commit is contained in:
parent
ef82f9075b
commit
7ccb4963ee
@ -1114,23 +1114,21 @@ begin
|
||||
lPasStrLen := UTF8Length(lPasStr);
|
||||
for i := 1 to lPasStrLen do
|
||||
begin
|
||||
// Since we can't just sum the partial widths because the spaces between
|
||||
// chars matter too, only calculate them if necessary
|
||||
if PartialWidths<>nil then
|
||||
begin
|
||||
lCurSubStr := UTF8Copy(lPasStr, i, 1);
|
||||
Self.GetTextExtentPoint(DC, PChar(lCurSubStr), 1, lCurSize);
|
||||
PartialWidths[i-1] := lCurSize.cx;
|
||||
end;
|
||||
|
||||
// Calculate the width until the utilized size gets bigger then the desired one
|
||||
// Give up when the size surpases MaxWidth to be faster
|
||||
if (not lBestFitFound) and (MaxCount <> nil) then
|
||||
if (not lBestFitFound) then
|
||||
begin
|
||||
lCurSubStr := UTF8Copy(lPasStr, 1, i);
|
||||
Self.GetTextExtentPoint(DC, PChar(lCurSubStr), Length(lCurSubStr), lCurSize);
|
||||
if lCurSize.cx <= MaxWidth then MaxCount^ := i
|
||||
else lBestFitFound := True;
|
||||
|
||||
// Calculate the summed partial widths
|
||||
if PartialWidths<>nil then PartialWidths[i-1] := lCurSize.cx;
|
||||
|
||||
// Calculate the width until the utilized size gets bigger then the desired one
|
||||
// Give up when the size surpases MaxWidth to be faster
|
||||
if (MaxCount <> nil) then
|
||||
begin
|
||||
if lCurSize.cx <= MaxWidth then MaxCount^ := i
|
||||
else lBestFitFound := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user