Browse Source

Fixes a list out of bounds exception in freetype

git-svn-id: trunk@16308 -
sekelsenmat 14 years ago
parent
commit
b87e3e5057
1 changed files with 9 additions and 3 deletions
  1. 9 3
      packages/fcl-image/src/freetype.pp

+ 9 - 3
packages/fcl-image/src/freetype.pp

@@ -433,11 +433,17 @@ end;
 
 function TFontManager.GetFont (FontID:integer) : TMgrFont;
 begin
-  result := TMgrFont(FList[FontID]);
-  if result <> CurFont then  // set last used size of the font as current size
+  if (FontID >= 0) and (FontID < FList.Count) then
+  begin
+    result := TMgrFont(FList[FontID]);
+
+    if result <> CurFont then  // set last used size of the font as current size
     begin
-    CurSize := result.LastSize;
+      CurSize := result.LastSize;
     end;
+  end
+  else
+    Result := nil;
 end;
 
 procedure TFontManager.GetSize (aSize, aResolution : integer);