[Tizen] Support custom fonts registration
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / font-client-plugin-impl.cpp
index 6e91eb5..65ca24e 100644 (file)
@@ -1009,7 +1009,7 @@ bool FontClient::Plugin::GetBitmapMetrics( GlyphInfo* array,
       else
 #endif
       {
-        int error = FT_Load_Glyph( ftFace, glyph.index, FT_LOAD_DEFAULT );
+        int error = FT_Load_Glyph( ftFace, glyph.index, FT_LOAD_NO_AUTOHINT );
 
         if( FT_Err_Ok == error )
         {
@@ -1102,7 +1102,7 @@ void FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dal
     else
 #endif
     {
-      error = FT_Load_Glyph( ftFace, glyphIndex, FT_LOAD_DEFAULT );
+      error = FT_Load_Glyph( ftFace, glyphIndex, FT_LOAD_NO_AUTOHINT );
     }
     if( FT_Err_Ok == error )
     {
@@ -1274,6 +1274,12 @@ bool FontClient::Plugin::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
   return FT_Err_Ok == error;
 }
 
+bool FontClient::Plugin::AddCustomFontDirectory( const FontPath& path )
+{
+  // NULL as first parameter means the current configuration is used.
+  return FcConfigAppFontAddDir( NULL, reinterpret_cast<const FcChar8 *>( path.c_str() ) );
+}
+
 void FontClient::Plugin::InitSystemFonts()
 {
   DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::InitSystemFonts\n" );
@@ -1424,23 +1430,25 @@ _FcFontSet* FontClient::Plugin::GetFcFontSet() const
   // a pattern holds a set of names, each name refers to a property of the font
   FcPattern* pattern = FcPatternCreate();
 
+  FcFontSet* fontset = NULL;
+
   // create an object set used to define which properties are to be returned in the patterns from FcFontList.
   FcObjectSet* objectSet = FcObjectSetCreate();
 
-  // build an object set from a list of property names
-  FcObjectSetAdd( objectSet, FC_FILE );
-  FcObjectSetAdd( objectSet, FC_FAMILY );
-  FcObjectSetAdd( objectSet, FC_WIDTH );
-  FcObjectSetAdd( objectSet, FC_WEIGHT );
-  FcObjectSetAdd( objectSet, FC_SLANT );
-
-  // get a list of fonts
-  // creates patterns from those fonts containing only the objects in objectSet and returns the set of unique such patterns
-  FcFontSet* fontset = FcFontList( NULL /* the default configuration is checked to be up to date, and used */, pattern, objectSet );
-
-  // clear up the object set
   if( objectSet )
   {
+    // build an object set from a list of property names
+    FcObjectSetAdd( objectSet, FC_FILE );
+    FcObjectSetAdd( objectSet, FC_FAMILY );
+    FcObjectSetAdd( objectSet, FC_WIDTH );
+    FcObjectSetAdd( objectSet, FC_WEIGHT );
+    FcObjectSetAdd( objectSet, FC_SLANT );
+
+    // get a list of fonts
+    // creates patterns from those fonts containing only the objects in objectSet and returns the set of unique such patterns
+    fontset = FcFontList( NULL /* the default configuration is checked to be up to date, and used */, pattern, objectSet );
+
+    // clear up the object set
     FcObjectSetDestroy( objectSet );
   }
   // clear up the pattern