Add text wrapping hyphen mode support 78/254278/20
authorabdullah <abdullahhasan10@gmail.com>
Thu, 25 Feb 2021 11:56:44 +0000 (13:56 +0200)
committerabdullah <abdullahhasan10@gmail.com>
Thu, 29 Apr 2021 07:17:41 +0000 (10:17 +0300)
related to
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-toolkit/+/254279/2

Change-Id: I3172f6f4017c6901493d01105af27cb9f57118e4

14 files changed:
build/tizen/deps-check.cmake
build/tizen/profiles/common-profile.cmake
build/tizen/profiles/mobile-profile.cmake
build/tizen/profiles/tv-profile.cmake
build/tizen/profiles/ubuntu-profile.cmake
dali/devel-api/file.list
dali/devel-api/text-abstraction/hyphenation.cpp [new file with mode: 0644]
dali/devel-api/text-abstraction/hyphenation.h [new file with mode: 0644]
dali/devel-api/text-abstraction/text-abstraction-definitions.h
dali/devel-api/text-abstraction/text-abstraction.h
dali/internal/text/file.list
dali/internal/text/text-abstraction/hyphenation-impl.cpp [new file with mode: 0644]
dali/internal/text/text-abstraction/hyphenation-impl.h [new file with mode: 0644]
packaging/dali-adaptor.spec

index 8dee1e7..449d848 100644 (file)
@@ -74,6 +74,7 @@ CHECK_MODULE_AND_SET( LIBEXIF libexif [] )
 CHECK_MODULE_AND_SET( LIBDRM libdrm [] )
 CHECK_MODULE_AND_SET( LIBCURL libcurl [] )
 CHECK_MODULE_AND_SET( HARFBUZZ harfbuzz [] )
+CHECK_MODULE_AND_SET( HYPHEN libhyphen [] )
 CHECK_MODULE_AND_SET( FRIBIDI fribidi [] )
 CHECK_MODULE_AND_SET( CAIRO cairo [] )
 CHECK_MODULE_AND_SET( EVAS evas [] )
@@ -299,6 +300,13 @@ IF (NOT APPLE)
     -lturbojpeg
     -ljpeg
   )
+
+if( NOT ANDROID_PROFILE )
+  SET( DALI_LDFLAGS ${DALI_LDFLAGS}
+    -lhyphen
+  )
+ENDIF()
+
 ENDIF()
 
 # Android includes pthread with android lib
index 408643d..f2bcbc1 100755 (executable)
@@ -79,3 +79,26 @@ IF( COMPONENT_APPLICATION_SUPPORT )
       )
 ENDIF()
 
+# Set the linker flags
+SET(REQUIRED_LIBS
+  -lhyphen
+)
+
+FIND_LIBRARY( HYPHEN_LIBRARY NAMES hyphen )
+IF (${HYPHEN_LIBRARY} MATCHES "HYPHEN_LIBRARY-NOTFOUND")
+  UNSET (HYPHEN_LIBRARY_AVAILABLE)
+ELSE()
+  SET (HYPHEN_LIBRARY_AVAILABLE "HYPHEN_LIBRARY_AVAILABLE")
+  ADD_DEFINITIONS(-DHYPHEN_LIBRARY_AVAILABLE="${HYPHEN_LIBRARY_AVAILABLE}")
+
+  #The path of hyphen library dictionary
+  IF (NOT "${HYPHEN_DIC}")
+  FIND_PATH(HYPHEN_DIC hyph_en_US.dic HINTS "/usr/local/share/hyphen" "/usr/share/hyphen" )
+  IF ( NOT HYPHEN_DIC MATCHES  "HYPHEN_DIC-NOTFOUND")
+    ADD_DEFINITIONS(-DHYPHEN_DIC="${HYPHEN_DIC}")
+  ENDIF()
+  ENDIF()
+  MESSAGE (HYPHEN_DIC: "${HYPHEN_DIC}")
+
+ENDIF()
+
index 7726cc0..ef877a4 100755 (executable)
@@ -79,3 +79,25 @@ IF( COMPONENT_APPLICATION_SUPPORT )
       )
 ENDIF()
 
+# Set the linker flags
+SET(REQUIRED_LIBS
+  -lhyphen
+)
+
+FIND_LIBRARY( HYPHEN_LIBRARY NAMES hyphen )
+IF (${HYPHEN_LIBRARY} MATCHES "HYPHEN_LIBRARY-NOTFOUND")
+  UNSET (HYPHEN_LIBRARY_AVAILABLE)
+ELSE()
+  SET (HYPHEN_LIBRARY_AVAILABLE "HYPHEN_LIBRARY_AVAILABLE")
+  ADD_DEFINITIONS(-DHYPHEN_LIBRARY_AVAILABLE="${HYPHEN_LIBRARY_AVAILABLE}")
+
+  #The path of hyphen library dictionary
+  IF (NOT "${HYPHEN_DIC}")
+  FIND_PATH(HYPHEN_DIC hyph_en_US.dic HINTS "/usr/local/share/hyphen" "/usr/share/hyphen" )
+  IF ( NOT HYPHEN_DIC MATCHES  "HYPHEN_DIC-NOTFOUND")
+    ADD_DEFINITIONS(-DHYPHEN_DIC="${HYPHEN_DIC}")
+  ENDIF()
+  ENDIF()
+  MESSAGE (HYPHEN_DIC: "${HYPHEN_DIC}")
+
+ENDIF()
index b7858ed..5f8e8e1 100755 (executable)
@@ -79,3 +79,26 @@ IF( COMPONENT_APPLICATION_SUPPORT )
       )
 ENDIF()
 
+# Set the linker flags
+SET(REQUIRED_LIBS
+  -lhyphen
+)
+
+FIND_LIBRARY( HYPHEN_LIBRARY NAMES hyphen )
+IF (${HYPHEN_LIBRARY} MATCHES "HYPHEN_LIBRARY-NOTFOUND")
+  UNSET (HYPHEN_LIBRARY_AVAILABLE)
+ELSE()
+  SET (HYPHEN_LIBRARY_AVAILABLE "HYPHEN_LIBRARY_AVAILABLE")
+  ADD_DEFINITIONS(-DHYPHEN_LIBRARY_AVAILABLE="${HYPHEN_LIBRARY_AVAILABLE}")
+
+  #The path of hyphen library dictionary
+  IF (NOT "${HYPHEN_DIC}")
+  FIND_PATH(HYPHEN_DIC hyph_en_US.dic HINTS "/usr/local/share/hyphen" "/usr/share/hyphen" )
+  IF ( NOT HYPHEN_DIC MATCHES  "HYPHEN_DIC-NOTFOUND")
+    ADD_DEFINITIONS(-DHYPHEN_DIC="${HYPHEN_DIC}")
+  ENDIF()
+  ENDIF()
+  MESSAGE (HYPHEN_DIC: "${HYPHEN_DIC}")
+
+ENDIF()
+
index 6e35138..26abe3e 100755 (executable)
@@ -147,4 +147,25 @@ SET(REQUIRED_LIBS ${ECORE_LDFLAGS}
   -lpthread
   -lturbojpeg
   -ljpeg
+  -lhyphen
 )
+
+
+FIND_LIBRARY( HYPHEN_LIBRARY NAMES hyphen )
+IF (${HYPHEN_LIBRARY} MATCHES "HYPHEN_LIBRARY-NOTFOUND")
+  UNSET (HYPHEN_LIBRARY_AVAILABLE)
+ELSE()
+  SET (HYPHEN_LIBRARY_AVAILABLE "HYPHEN_LIBRARY_AVAILABLE")
+  ADD_DEFINITIONS(-DHYPHEN_LIBRARY_AVAILABLE="${HYPHEN_LIBRARY_AVAILABLE}")
+
+  #The path of hyphen library dictionary
+  IF (NOT "${HYPHEN_DIC}")
+  FIND_PATH(HYPHEN_DIC hyph_en_US.dic HINTS "/usr/local/share/hyphen" "/usr/share/hyphen" )
+  IF ( NOT HYPHEN_DIC MATCHES  "HYPHEN_DIC-NOTFOUND")
+    ADD_DEFINITIONS(-DHYPHEN_DIC="${HYPHEN_DIC}")
+  ENDIF()
+  ENDIF()
+  MESSAGE (HYPHEN_DIC: "${HYPHEN_DIC}")
+
+ENDIF()
+
index edf8862..9564cc7 100755 (executable)
@@ -135,6 +135,7 @@ SET( devel_api_text_abstraction_src_files
    ${adaptor_devel_api_dir}/text-abstraction/shaping.cpp
    ${adaptor_devel_api_dir}/text-abstraction/text-renderer.cpp
    ${adaptor_devel_api_dir}/text-abstraction/text-renderer-layout-helper.cpp
+   ${adaptor_devel_api_dir}/text-abstraction/hyphenation.cpp
 )
 
 
@@ -152,4 +153,5 @@ SET( text_abstraction_header_files
    ${adaptor_devel_api_dir}/text-abstraction/text-abstraction-definitions.h
    ${adaptor_devel_api_dir}/text-abstraction/text-renderer.h
    ${adaptor_devel_api_dir}/text-abstraction/text-renderer-layout-helper.h
+   ${adaptor_devel_api_dir}/text-abstraction/hyphenation.h
 )
diff --git a/dali/devel-api/text-abstraction/hyphenation.cpp b/dali/devel-api/text-abstraction/hyphenation.cpp
new file mode 100644 (file)
index 0000000..40a0da4
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/devel-api/text-abstraction/hyphenation.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/text/text-abstraction/hyphenation-impl.h>
+
+namespace Dali
+{
+namespace TextAbstraction
+{
+Hyphenation::Hyphenation()
+{
+}
+
+Hyphenation::~Hyphenation()
+{
+}
+
+Hyphenation::Hyphenation(Internal::Hyphenation* impl)
+: BaseHandle(impl)
+{
+}
+
+Hyphenation Hyphenation::Get()
+{
+  return Internal::Hyphenation::Get();
+}
+
+const char* Hyphenation::GetDictionaryEncoding(const char* lang)
+{
+  return GetImplementation(*this).GetDictionaryEncoding(lang);
+}
+
+Vector<bool> Hyphenation::GetWordHyphens(const char* word,
+                                         Length      wordSize,
+                                         const char* lang)
+{
+  return GetImplementation(*this).GetWordHyphens(word,
+                                                 wordSize,
+                                                 lang);
+}
+
+} // namespace TextAbstraction
+
+} // namespace Dali
diff --git a/dali/devel-api/text-abstraction/hyphenation.h b/dali/devel-api/text-abstraction/hyphenation.h
new file mode 100644 (file)
index 0000000..b8d5cfe
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef DALI_PLATFORM_TEXT_ABSTRACTION_HYPHENATION_H
+#define DALI_PLATFORM_TEXT_ABSTRACTION_HYPHENATION_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
+#include <dali/public-api/dali-adaptor-common.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+
+namespace Dali
+{
+namespace TextAbstraction
+{
+namespace Internal DALI_INTERNAL
+{
+class Hyphenation;
+
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief Hyphenation provides an interface to retrieve possible hyphenation of the text.
+ *
+ * This module get the hyphen positions for a word.
+ * To get the hyphen positions it needs to load the dictionary for the word language.
+ * also it need the word to be send using the correct encoding which can be known using
+ *
+ * @code
+ * Hyphenation hyphenation = Hyphenation::Get();
+ *
+ * Character* text = "Hyphenation";
+ *
+ * // get a vector of booleans that indicates possible hyphen locations.
+ * Vector<bool> *hyphens = hyphenation.GetWordHyphens(text, 11, "en_US");
+ *
+ * @endcode
+ */
+class DALI_ADAPTOR_API Hyphenation : public BaseHandle
+{
+public:
+  /**
+   * @brief Create an uninitialized Hyphenation handle.
+   *
+   */
+  Hyphenation();
+
+  /**
+   * @brief Destructor
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~Hyphenation();
+
+  /**
+   * @brief This constructor is used by Hyphenation::Get().
+   *
+   * @param[in] implementation A pointer to the internal hyphenation object.
+   */
+  explicit DALI_INTERNAL Hyphenation(Internal::Hyphenation* implementation);
+
+  /**
+   * @brief Retrieve a handle to the Hyphenation instance.
+   *
+   * @return A handle to the Hyphenation.
+   */
+  static Hyphenation Get();
+
+  /**
+   *
+   * Gets the encoding of the dictionary for the given language
+   *
+   * @param[in] lang language to get encoding for (en_US).
+   *
+   * @return The encoding of the language (UTF-32).
+   */
+  const char* GetDictionaryEncoding(const char* lang);
+
+  /**
+   * Gets a vector booleans that indicates possible hyphen locations.
+   *
+   * @param[in] word the word to get possible hyphens for.
+   * @param[in] wordSize the word size in bytes.
+   * @param[in] lang the language for the word
+   *
+   * @return vector of boolean, true if possible to hyphenate at this character position.
+   */
+  Vector<bool> GetWordHyphens(const char* word,
+                              Length      wordSize,
+                              const char* lang);
+};
+
+} // namespace TextAbstraction
+
+} // namespace Dali
+
+#endif // DALI_PLATFORM_TEXT_ABSTRACTION_HYPHENATION_H
index 9159653..e100ef8 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEXT_ABSTRACTION_DEFINITIONS_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,9 +43,12 @@ typedef uint32_t ColorIndex;         ///< An index into an array of colors.
  */
 enum
 {
-  LINE_MUST_BREAK  = 0u, ///< Text must be broken into a new line.
-  LINE_ALLOW_BREAK = 1u, ///< Is possible to break the text into a new line.
-  LINE_NO_BREAK    = 2u  ///< Text can't be broken into a new line.
+  LINE_MUST_BREAK        = 0u, ///< Text must be broken into a new line.
+  LINE_ALLOW_BREAK       = 1u, ///< Is possible to break the text into a new line.
+  LINE_NO_BREAK          = 2u, ///< Text can't be broken into a new line.
+  LINE_INSIDEACHAR       = 3u, ///< A UTF-8/16 sequence is unfinished.
+  LINE_INDETERMINATE     = 4u, ///< End of input on a non-EOL char.
+  LINE_HYPHENATION_BREAK = 5u  ///< Text can be broken with adding hyphen.
 };
 
 /**
index 3a9309e..9361f17 100755 (executable)
@@ -26,5 +26,6 @@
 #include <dali/devel-api/text-abstraction/script.h>
 #include <dali/devel-api/text-abstraction/segmentation.h>
 #include <dali/devel-api/text-abstraction/shaping.h>
+#include <dali/devel-api/text-abstraction/hyphenation.h>
 
 #endif // DALI_TEXT_ABSTRACTION_H
index 8530a7b..1a420de 100644 (file)
@@ -1,13 +1,14 @@
 
 # module: text, backend: common
-SET( adaptor_text_common_src_files 
-    ${adaptor_text_dir}/text-abstraction/bidirectional-support-impl.cpp 
-    ${adaptor_text_dir}/text-abstraction/cairo-renderer.cpp 
-    ${adaptor_text_dir}/text-abstraction/font-client-helper.cpp 
-    ${adaptor_text_dir}/text-abstraction/font-client-impl.cpp 
-    ${adaptor_text_dir}/text-abstraction/font-client-plugin-impl.cpp 
-    ${adaptor_text_dir}/text-abstraction/segmentation-impl.cpp 
-    ${adaptor_text_dir}/text-abstraction/shaping-impl.cpp 
+SET( adaptor_text_common_src_files
+    ${adaptor_text_dir}/text-abstraction/bidirectional-support-impl.cpp
+    ${adaptor_text_dir}/text-abstraction/cairo-renderer.cpp
+    ${adaptor_text_dir}/text-abstraction/font-client-helper.cpp
+    ${adaptor_text_dir}/text-abstraction/font-client-impl.cpp
+    ${adaptor_text_dir}/text-abstraction/font-client-plugin-impl.cpp
+    ${adaptor_text_dir}/text-abstraction/segmentation-impl.cpp
+    ${adaptor_text_dir}/text-abstraction/shaping-impl.cpp
     ${adaptor_text_dir}/text-abstraction/text-renderer-impl.cpp
+    ${adaptor_text_dir}/text-abstraction/hyphenation-impl.cpp
 )
 
diff --git a/dali/internal/text/text-abstraction/hyphenation-impl.cpp b/dali/internal/text/text-abstraction/hyphenation-impl.cpp
new file mode 100644 (file)
index 0000000..eef2fe9
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS  HEADER
+#include <dali/internal/text/text-abstraction/hyphenation-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+#include <dali/devel-api/common/singleton-service.h>
+
+// EXTERNAL INCLUDES
+#ifdef HYPHEN_LIBRARY_AVAILABLE
+#include <hyphen.h>
+#else
+#define HyphenDict void
+#endif
+
+#ifndef HYPHEN_DIC
+#define HYPHEN_DIC "abc"
+#endif
+
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_HYPHENATION");
+#endif
+
+} // namespace
+
+namespace Dali
+{
+namespace TextAbstraction
+{
+namespace Internal
+{
+const char* const  DEFAULT_LANGUAGE        = "en_US";
+const unsigned int DEFAULT_LANGUAGE_LENGTH = 5u;
+
+struct Hyphenation::HyphenDictionary
+{
+  HyphenDictionary(std::string lang, HyphenDict* dict)
+  {
+    mLanguage   = lang;
+    mDictionary = dict;
+  }
+
+  ~HyphenDictionary()
+  {
+  }
+
+  std::string mLanguage;
+  HyphenDict* mDictionary;
+};
+
+struct Hyphenation::Plugin
+{
+  Plugin()
+  : mHyphenDictionary()
+  {
+  }
+
+  ~Plugin()
+  {
+#ifdef HYPHEN_LIBRARY_AVAILABLE
+    for(auto&& it : mHyphenDictionary)
+    {
+      hnj_hyphen_free(it.mDictionary);
+    }
+#endif
+  }
+
+  std::string GetPathForLanguage(const char* lang)
+  {
+    std::string path    = HYPHEN_DIC;
+    std::string filName = "/hyph_";
+    filName.append(lang);
+    filName.append(".dic");
+    path.append(filName);
+
+    return path; // must be ..../hyph_en_US.dic
+  }
+
+  HyphenDict* LoadDictionary(const char* language)
+  {
+#ifdef HYPHEN_LIBRARY_AVAILABLE
+    const char* lang = (language ? language : DEFAULT_LANGUAGE);
+
+    for(auto&& it : mHyphenDictionary)
+    {
+      if(!it.mLanguage.compare(lang))
+      {
+        return it.mDictionary;
+      }
+    }
+
+    std::string path = GetPathForLanguage(lang);
+    HyphenDict* dict = hnj_hyphen_load(path.c_str());
+    if(!dict)
+    {
+      DALI_LOG_ERROR("Couldn't load hyphen dictionary:%s\n", lang);
+    }
+    else
+    {
+      mHyphenDictionary.push_back(HyphenDictionary(lang, dict));
+    }
+
+    return dict;
+#else
+    return nullptr;
+#endif
+  }
+
+  const char* GetDictionaryEncoding(const char* lang)
+  {
+#ifdef HYPHEN_LIBRARY_AVAILABLE
+    HyphenDict* dict = LoadDictionary(lang);
+    if(!dict)
+    {
+      return nullptr;
+    }
+
+    return dict->cset;
+#else
+    return "UTF_32";
+#endif
+  }
+
+  Vector<bool> GetWordHyphens(const char* word,
+                              Length      wordLength,
+                              const char* lang)
+  {
+    Vector<bool> hyphensList;
+
+#ifdef HYPHEN_LIBRARY_AVAILABLE
+    char*       hyphens = nullptr;
+    char**      rep     = nullptr;
+    int*        pos     = nullptr;
+    int*        cut     = nullptr;
+    HyphenDict* dict;
+
+    if((!word) || (wordLength < 1))
+    {
+      return hyphensList;
+    }
+
+    dict = LoadDictionary(lang);
+    if(!dict)
+    {
+      return hyphensList;
+    }
+
+    hyphens = (char*)malloc(wordLength + 5);
+
+    hnj_hyphen_hyphenate2(dict, (char*)(word), wordLength, hyphens, NULL, &rep, &pos, &cut);
+
+    hyphensList.PushBack(false);
+
+    for(Length i = 0; i < wordLength - 1; i++)
+    {
+      hyphensList.PushBack((bool)(hyphens[i + 1] & 1));
+    }
+
+    free(hyphens);
+#endif
+
+    return hyphensList;
+  }
+
+  std::vector<HyphenDictionary> mHyphenDictionary;
+};
+
+Hyphenation::Hyphenation()
+: mPlugin(nullptr)
+{
+}
+
+Hyphenation::~Hyphenation()
+{
+}
+
+TextAbstraction::Hyphenation Hyphenation::Get()
+{
+  TextAbstraction::Hyphenation hyphenationHandle;
+
+  SingletonService service(SingletonService::Get());
+  if(service)
+  {
+    // Check whether the singleton is already created
+    Dali::BaseHandle handle = service.GetSingleton(typeid(TextAbstraction::Hyphenation));
+    if(handle)
+    {
+      // If so, downcast the handle
+      Hyphenation* impl = dynamic_cast<Internal::Hyphenation*>(handle.GetObjectPtr());
+      hyphenationHandle = TextAbstraction::Hyphenation(impl);
+    }
+    else // create and register the object
+    {
+      hyphenationHandle = TextAbstraction::Hyphenation(new Hyphenation);
+      service.Register(typeid(hyphenationHandle), hyphenationHandle);
+    }
+  }
+
+  return hyphenationHandle;
+}
+
+const char* Hyphenation::GetDictionaryEncoding(const char* lang)
+{
+  CreatePlugin();
+
+  return mPlugin->GetDictionaryEncoding(lang);
+}
+
+Vector<bool> Hyphenation::GetWordHyphens(const char* word,
+                                         Length      wordLength,
+                                         const char* lang)
+{
+  CreatePlugin();
+
+  return mPlugin->GetWordHyphens(word, wordLength, lang);
+}
+
+void Hyphenation::CreatePlugin()
+{
+  if(!mPlugin)
+  {
+    mPlugin = std::make_unique<Plugin>();
+  }
+}
+
+} // namespace Internal
+
+} // namespace TextAbstraction
+
+} // namespace Dali
diff --git a/dali/internal/text/text-abstraction/hyphenation-impl.h b/dali/internal/text/text-abstraction/hyphenation-impl.h
new file mode 100644 (file)
index 0000000..53bc059
--- /dev/null
@@ -0,0 +1,106 @@
+#ifndef DALI_INTERNAL_TEXT_ABSTRACTION_HYPHENATION_IMPL_H
+#define DALI_INTERNAL_TEXT_ABSTRACTION_HYPHENATION_IMPL_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/text-abstraction/hyphenation.h>
+#include <dali/public-api/common/dali-vector.h>
+
+namespace Dali
+{
+namespace TextAbstraction
+{
+namespace Internal
+{
+/**
+ * Implementation of the Hyphenation
+ */
+class Hyphenation : public BaseObject
+{
+public:
+  /**
+   * Constructor
+   */
+  Hyphenation();
+
+  /**
+   * Destructor
+   */
+  ~Hyphenation();
+
+  /**
+   * @copydoc Dali::Hyphenation::Get()
+   */
+  static TextAbstraction::Hyphenation Get();
+
+  /**
+   * @copydoc Dali::Hyphenation::GetDictionaryEncoding()
+   */
+  const char* GetDictionaryEncoding(const char* lang);
+
+  /**
+   * @copydoc Dali::Hyphenation::GetWordHyphens()
+   */
+  Vector<bool> GetWordHyphens(const char* word,
+                              Length      wordLength,
+                              const char* lang);
+
+private:
+  /**
+   * Helper for lazy initialization.
+   */
+  void CreatePlugin();
+
+private:
+  // Undefined copy constructor.
+  Hyphenation(const Hyphenation&);
+
+  // Undefined assignment constructor.
+  Hyphenation& operator=(const Hyphenation&);
+
+  struct HyphenDictionary;
+  struct Plugin;
+  std::unique_ptr<Plugin> mPlugin;
+
+}; // class Hyphenation
+
+} // namespace Internal
+
+} // namespace TextAbstraction
+
+inline static TextAbstraction::Internal::Hyphenation& GetImplementation(TextAbstraction::Hyphenation& hyphenation)
+{
+  DALI_ASSERT_ALWAYS(hyphenation && "hyphenation handle is empty");
+  BaseObject& handle = hyphenation.GetBaseObject();
+  return static_cast<TextAbstraction::Internal::Hyphenation&>(handle);
+}
+
+inline static const TextAbstraction::Internal::Hyphenation& GetImplementation(const TextAbstraction::Hyphenation& hyphenation)
+{
+  DALI_ASSERT_ALWAYS(hyphenation && "hyphenation handle is empty");
+  const BaseObject& handle = hyphenation.GetBaseObject();
+  return static_cast<const TextAbstraction::Internal::Hyphenation&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TEXT_ABSTRACTION_HYPHENATION_IMPL_H
index 4dc33df..647a892 100644 (file)
@@ -61,6 +61,7 @@ BuildRequires:  pkgconfig(libpng)
 BuildRequires:  pkgconfig(egl)
 BuildRequires:  libcurl-devel
 BuildRequires:  pkgconfig(harfbuzz)
+BuildRequires:  hyphen-devel
 BuildRequires:  fribidi-devel
 
 BuildRequires:  pkgconfig(capi-system-info)