[SOLVED] Improvement of TFreeTypeFont.GetVersionNumber lazarus / 7-LCL ---------------------------------------------------------------------- lagprogramming · 2023-08-09 07:38 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 function TFreeTypeFont.GetVersionNumber: string;var VersionStr: string;    idxStart,idxEnd: integer;begin  VersionStr := Information[ftiVersionString];  idxStart := 1;  while (idxStart < length(VersionStr)) and not (VersionStr[idxStart] in['0'..'9']) do    inc(idxStart);  idxEnd := idxStart;  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);  if (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);  result := copy(VersionStr,idxStart,idxEnd- idxStart+1);end; The attached patch replaces the occurencies of (idxEnd+1 <= length(VersionStr)) with (idxEnd < length(VersionStr)). 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 9cf56731c0..27f7151674 100644--- a/components/freetype/easylazfreetype.pas+++ b/components/freetype/easylazfreetype.pas@@ -1143,9 +1143,9 @@ begin   while (idxStart < length(VersionStr)) and not (VersionStr[idxStart] in['0'..'9']) do     inc(idxStart);   idxEnd := idxStart;-  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);-  if (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);-  while (idxEnd+1 <= length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);+  while (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);+  if (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] = '.') then inc(idxEnd);+  while (idxEnd < length(VersionStr)) and (VersionStr[idxEnd+1] in['0'..'9']) do inc(idxEnd);   result := copy(VersionStr,idxStart,idxEnd-idxStart+1); end; ---------------------------------------------------------------------- AlexTP · 2023-08-09 08:33 Posted to https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40438