From e671199f1ebb4418bcaeb76adba35551df5d1b68 Mon Sep 17 00:00:00 2001 From: "Jinho, Lee" Date: Thu, 21 Sep 2017 17:28:07 +0900 Subject: [PATCH] [4.0] Support custom fonts registration Change-Id: I71c274d630ffa3caf967309567360ae9164f7d8c --- .../src/dali-toolkit-styling/utc-Dali-StyleManager.cpp | 6 +++++- .../internal/text/multi-language-support-impl.cpp | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp index e8348f1..a143f7e 100644 --- a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp +++ b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp @@ -1313,7 +1313,8 @@ int UtcDaliStyleManagerConfigSectionTest(void) " \"config\":\n" " {\n" " \"alwaysShowFocus\":false,\n" - " \"clearFocusOnEscape\":false\n" + " \"clearFocusOnEscape\":false,\n" + " \"customFontDirectory\":\"" DALI_STYLE_DIR "\"\n" " },\n" " \"styles\":\n" " {\n" @@ -1331,9 +1332,12 @@ int UtcDaliStyleManagerConfigSectionTest(void) DALI_TEST_CHECK( !alwaysShowFocus ); bool clearFocusOnEscape = config["clearFocusOnEscape"].Get(); DALI_TEST_CHECK( !clearFocusOnEscape ); + std::string customFontDirectory = config["customFontDirectory"].Get(); + DALI_TEST_EQUALS( customFontDirectory, DALI_STYLE_DIR, TEST_LOCATION ); // For coverage Toolkit::TextEditor editor = Toolkit::TextEditor::New(); + editor.SetProperty( TextEditor::Property::TEXT, "Test" ); editor.SetKeyboardFocusable( true ); Stage::GetCurrent().Add( editor ); diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index e88a286..d32809c 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -25,6 +25,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -106,6 +107,20 @@ MultilanguageSupport::MultilanguageSupport() // Initializes the valid fonts cache to NULL (no valid fonts). // Reserves space to cache the valid fonts and access them with the script as an index. mValidFontsPerScriptCache.Resize( TextAbstraction::UNKNOWN, NULL ); + + // Add custom font directory + Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get(); + if( styleManager ) + { + std::string path; + Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager ); + if( config["customFontDirectory"].Get( path ) ) + { + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.AddCustomFontDirectory( path.c_str() ); + } + } + } MultilanguageSupport::~MultilanguageSupport() -- 2.7.4