components/freetype/easylazfreetype.pas has
procedure TFreeTypeRenderableFont.SplitText(var AText: string;
AMaxWidth: single; out ARemains: string);
var
pstr: pchar;
left,charlen: integer;
totalWidth: single;
firstChar: boolean;
glyphWidth: single;
glyphCode: cardinal;
procedure WordBreak(ADropCount: Integer = 0);
begin
ARemains:= copy(AText, length(AText) - left + 1 + ADropCount, left);
SetLength(AText, length(AText) - left);
end;
begin
ARemains := '';
if AText = '' then
exit;
totalWidth := 0;
pstr := @AText[1];
left := length(AText);
firstChar := true;
while left > 0 do
begin
if pstr[0] in [#13, #10] then
begin
if (left > 1) and ([pstr[0], pstr[1]] = [#13, #10]) then
WordBreak(2)
else
WordBreak(1);
exit;
end;
charlen := UTF8CodepointSize(pstr);
glyphCode := UTF8CodepointToUnicode(pstr, charlen);
inc(pstr,charlen);
glyphWidth := CharWidthFromUnicode(glyphCode);
if glyphWidth <> 0 then
begin
totalWidth += glyphWidth;
if (totalWidth > AMaxWidth) and not firstChar then
begin
WordBreak;
if Assigned(FWordBreakHandler) then
FWordBreakHandler(AText,ARemains)
else
DefaultWordBreakHandler(AText,ARemains);
exit;
end;
end;
dec(left,charlen);
firstChar := false;
end;
ARemains := ''; //no split
end;
The first and the last lines of the procedure are:
ARemains := ''; and
ARemains := ''; //no splitBetween these two assignments, each and every time
ARemains is modified, it is followed by an
exit, making the last assignment line useless.
The following patch removes it.
diff --git a/components/freetype/easylazfreetype.pas b/components/freetype/easylazfreetype.pas
index 27f7151674..5ba7762125 100644
--- a/components/freetype/easylazfreetype.pas
+++ b/components/freetype/easylazfreetype.pas
@@ -596,7 +596,6 @@ begin
dec(left,charlen);
firstChar := false;
end;
- ARemains := ''; //no split
end;
procedure TFreeTypeRenderableFont.GetTextSize(AText: string; out w, h: single);