From: taeyoon0.lee Date: Wed, 11 Oct 2017 09:00:05 +0000 (+0900) Subject: [4.0] Support custom fonts registration X-Git-Tag: accepted/tizen/4.0/unified/20171012.230021~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=cc06bc9577950bea77b30f1482980b1e52131562 [4.0] Support custom fonts registration This reverts commit 84ec2918accb98eae3cfc8d2bea198b166228eaa. Change-Id: I4d6f96f8595f499c9c0bfa288cb3318a9c9f1981 --- 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: /**