]> OCCT Git - occt-copy.git/commitdiff
0026611: Visualization, TKService - fix NULL-dereference in Font_FontMgr on broken...
authorkgv <kgv@opencascade.com>
Thu, 27 Aug 2015 09:34:09 +0000 (12:34 +0300)
committerabv <abv@opencascade.com>
Wed, 2 Sep 2015 11:39:54 +0000 (14:39 +0300)
Check FT_Face::family_name for NULL during detection.
Skip fonts without mandatory UNICODE charset in Font_FontMgr.

src/Font/Font_FontMgr.cxx

index 3cd84af577c2b00d2b233cd572aedc8ccf388964..245c20957cfa3135eb6c475e14a40082993a90fd 100644 (file)
@@ -202,9 +202,14 @@ static Handle(Font_SystemFont) checkFont (const Handle(Font_FTLibrary)& theFTLib
     anAspect = Font_FA_Bold;
   }
 
-  Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aFontFace->family_name);
-  Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (theFontPath);
-  Handle(Font_SystemFont) aResult = new Font_SystemFont (aFontName, anAspect, aFontPath);
+  Handle(Font_SystemFont) aResult;
+  if (aFontFace->family_name != NULL                           // skip broken fonts (error in FreeType?)
+   && FT_Select_Charmap (aFontFace, ft_encoding_unicode) == 0) // Font_FTFont supports only UNICODE fonts
+  {
+    Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aFontFace->family_name);
+    Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (theFontPath);
+    aResult = new Font_SystemFont (aFontName, anAspect, aFontPath);
+  }
 
   FT_Done_Face (aFontFace);