Clean up at TFreeTypeRenderableFont.SplitText lazarus / 7-LCL ---------------------------------------------------------------------- lagprogramming · 2023-08-10 09:54 components/freetype/easylazfreetype.pas has Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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 splitend;The first and the last lines of the procedure are: ARemains := ''; and ARemains := ''; //no split Between 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. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/components/freetype/easylazfreetype.pas b/components/freetype/easylazfreetype.pasindex 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); ---------------------------------------------------------------------- AlexTP · 2023-08-10 10:01 Too micro change (for my taste). No overhead here.