Recent

Author Topic: [SOLVED] Improvement of TFreeTypeFont.GetVersionNumber  (Read 2069 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
[SOLVED] Improvement of TFreeTypeFont.GetVersionNumber
« on: August 09, 2023, 09:38:51 am »
components/freetype/easylazfreetype.pas has
Code: Pascal  [Select][+][-]
  1. function TFreeTypeFont.GetVersionNumber: string;
  2. var VersionStr: string;
  3.     idxStart,idxEnd: integer;
  4. begin
  5.   VersionStr := Information[ftiVersionString];
  6.   idxStart := 1;
  7.   while (idxStart < length(VersionStr)) and not (VersionStr[idxStart] in['0'..'9']) do
  8.     inc(idxStart);
  9.   idxEnd := idxStart;
  10.   while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);
  11.   if (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);
  12.   while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);
  13.   result := copy(VersionStr,idxStart,idxEnd-idxStart+1);
  14. end;

The attached patch replaces the occurencies of (idxEnd+1 <= length(VersionStr)) with (idxEnd < length(VersionStr)).
Code: Pascal  [Select][+][-]
  1. diff --git a/components/freetype/easylazfreetype.pas b/components/freetype/easylazfreetype.pas
  2. index 9cf56731c0..27f7151674 100644
  3. --- a/components/freetype/easylazfreetype.pas
  4. +++ b/components/freetype/easylazfreetype.pas
  5. @@ -1143,9 +1143,9 @@ begin
  6.    while (idxStart < length(VersionStr)) and not (VersionStr[idxStart] in['0'..'9']) do
  7.      inc(idxStart);
  8.    idxEnd := idxStart;
  9. -  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);
  10. -  if (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);
  11. -  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);
  12. +  while (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);
  13. +  if (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);
  14. +  while (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);
  15.    result := copy(VersionStr,idxStart,idxEnd-idxStart+1);
  16.  end;
  17.  
« Last Edit: August 09, 2023, 02:59:06 pm by lagprogramming »


 

TinyPortal © 2005-2018