Recent

Author Topic: [SOLVED] Improvement of TFreeTypeRenderableFont.DefaultWordBreakHandler  (Read 784 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
components/freetype/easylazfreetype.pas has
Code: Pascal  [Select][+][-]
  1. procedure TFreeTypeRenderableFont.DefaultWordBreakHandler(var ABefore,
  2.   AAfter: string);
  3. var p: integer;
  4. begin
  5.   if (AAfter <> '') and (ABefore <> '') and (AAfter[1]<> ' ') and (ABefore[length(ABefore)] <> ' ') then
  6.   begin
  7.     p := length(ABefore);
  8.     while (p > 1) and (ABefore[p-1] <> ' ') do dec(p);
  9.     if p > 1 then //can put the word after
  10.     begin
  11.       AAfter := copy(ABefore,p,length(ABefore)-p+1)+AAfter;
  12.       ABefore := copy(ABefore,1,p-1);
  13.     end else
  14.     begin //cannot put the word after, so before
  15.  
  16.     end;
  17.   end;
  18.   while (ABefore <> '') and (ABefore[length(ABefore)] =' ') do delete(ABefore,length(ABefore),1);
  19.   while (AAfter <> '') and (AAfter[1] =' ') do delete(AAfter,1,1);
  20. 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);
« Last Edit: January 31, 2024, 01:15:01 pm by lagprogramming »


 

TinyPortal © 2005-2018