From: Jinho, Lee Date: Tue, 11 Jul 2017 13:04:40 +0000 (+0900) Subject: [4.0] Support custom fonts registration X-Git-Tag: accepted/tizen/4.0/unified/20171010.163017~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4029514e547192e5f9224565ed819b9d6e2aca77;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git [4.0] Support custom fonts registration Change-Id: If97a9807539a870ac741c8ac78ef35fcd3b0db62 --- diff --git a/text/dali/devel-api/text-abstraction/font-client.cpp b/text/dali/devel-api/text-abstraction/font-client.cpp index 90470d2..d15cc57 100644 --- a/text/dali/devel-api/text-abstraction/font-client.cpp +++ b/text/dali/devel-api/text-abstraction/font-client.cpp @@ -207,6 +207,11 @@ bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ) return GetImplementation(*this).IsColorGlyph( fontId, glyphIndex ); } +bool FontClient::AddCustomFontDirectory( const char* path ) +{ + return GetImplementation(*this).AddCustomFontDirectory( path ); +} + FontClient::FontClient( Internal::FontClient* internal ) : BaseHandle( internal ) { diff --git a/text/dali/devel-api/text-abstraction/font-client.h b/text/dali/devel-api/text-abstraction/font-client.h index 8c8cfca..cf0c0b1 100644 --- a/text/dali/devel-api/text-abstraction/font-client.h +++ b/text/dali/devel-api/text-abstraction/font-client.h @@ -405,6 +405,15 @@ public: */ bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ); + /** + * @brief Add custom fonts directory + * + * @param[in] path to the fonts directory + * + * @return true if the fonts can be added. + */ + bool AddCustomFontDirectory( const char* path ); + public: // Not intended for application developers /** * @brief This constructor is used by FontClient::Get(). diff --git a/text/dali/internal/text-abstraction/font-client-impl.cpp b/text/dali/internal/text-abstraction/font-client-impl.cpp index 4ab90bf..1bed788 100644 --- a/text/dali/internal/text-abstraction/font-client-impl.cpp +++ b/text/dali/internal/text-abstraction/font-client-impl.cpp @@ -281,6 +281,13 @@ bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ) return mPlugin->IsColorGlyph( fontId, glyphIndex ); } +bool FontClient::AddCustomFontDirectory( const char* path ) +{ + CreatePlugin(); + + return mPlugin->AddCustomFontDirectory( path ); +} + void FontClient::CreatePlugin() { if( !mPlugin ) diff --git a/text/dali/internal/text-abstraction/font-client-impl.h b/text/dali/internal/text-abstraction/font-client-impl.h index cfa3a20..9637531 100644 --- a/text/dali/internal/text-abstraction/font-client-impl.h +++ b/text/dali/internal/text-abstraction/font-client-impl.h @@ -193,6 +193,11 @@ public: */ bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ); + /** + * @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory() + */ + bool AddCustomFontDirectory( const char* path ); + private: /** diff --git a/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp b/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp index a1e4cc6..b7055c1 100644 --- a/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp +++ b/text/dali/internal/text-abstraction/font-client-plugin-impl.cpp @@ -1274,6 +1274,12 @@ bool FontClient::Plugin::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ) return FT_Err_Ok == error; } +bool FontClient::Plugin::AddCustomFontDirectory( const char* path ) +{ + // NULL as first parameter means the current configuration is used. + return FcConfigAppFontAddDir( NULL, reinterpret_cast( path ) ); +} + void FontClient::Plugin::InitSystemFonts() { DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::InitSystemFonts\n" ); diff --git a/text/dali/internal/text-abstraction/font-client-plugin-impl.h b/text/dali/internal/text-abstraction/font-client-plugin-impl.h index c1e158f..936a159 100644 --- a/text/dali/internal/text-abstraction/font-client-plugin-impl.h +++ b/text/dali/internal/text-abstraction/font-client-plugin-impl.h @@ -321,6 +321,11 @@ struct FontClient::Plugin */ bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ); + /** + * @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory() + */ + bool AddCustomFontDirectory( const char* path ); + private: /**