Forum > LCL

[SOLVED] Improvement of TFreeTypeRenderableFont.DefaultWordBreakHandler

(1/1)

lagprogramming:
components/freetype/easylazfreetype.pas has

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFreeTypeRenderableFont.DefaultWordBreakHandler(var ABefore,  AAfter: string);var p: integer;begin  if (AAfter <> '') and (ABefore <> '') and (AAfter[1]<> ' ') and (ABefore[length(ABefore)] <> ' ') then  begin    p := length(ABefore);    while (p > 1) and (ABefore[p-1] <> ' ') do dec(p);    if p > 1 then //can put the word after    begin      AAfter := copy(ABefore,p,length(ABefore)-p+1)+AAfter;      ABefore := copy(ABefore,1,p-1);    end else    begin //cannot put the word after, so before     end;  end;  while (ABefore <> '') and (ABefore[length(ABefore)] =' ') do delete(ABefore,length(ABefore),1);  while (AAfter <> '') and (AAfter[1] =' ') do delete(AAfter,1,1);end;
The following patch replaces
ABefore := copy(ABefore,1,p-1); with SetLength(ABefore, p-1);
delete(ABefore,length(ABefore),1); with SetLength(ABefore, length(ABefore)-1);

AlexTP:
Posted to https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40703

Navigation

[0] Message Index

Go to full version