Merge "[4.0] clear cache when locale is changed" into tizen_4.0
[platform/core/uifw/dali-adaptor.git] / text / dali / internal / text-abstraction / shaping-impl.cpp
index 270c406..4d389c5 100644 (file)
@@ -29,6 +29,7 @@
 #include <harfbuzz/hb-ft.h>
 
 #include <ft2build.h>
+#include <iostream>
 
 namespace Dali
 {
@@ -100,6 +101,7 @@ const hb_script_t SCRIPT_TO_HARFBUZZ[] =
   HB_SCRIPT_ETHIOPIC,
   HB_SCRIPT_OL_CHIKI,
   HB_SCRIPT_TAGALOG,
+  HB_SCRIPT_MEETEI_MAYEK,
 
   HB_SCRIPT_UNKNOWN, // EMOJI
   HB_SCRIPT_UNKNOWN, // SYMBOLS1
@@ -193,9 +195,13 @@ struct Shaping::Plugin
     hb_buffer_set_script( harfBuzzBuffer,
                           SCRIPT_TO_HARFBUZZ[ script ] ); /* see hb-unicode.h */
 
-    hb_buffer_set_language( harfBuzzBuffer,
-                            hb_language_from_string( DEFAULT_LANGUAGE,
-                                                     DEFAULT_LANGUAGE_LENGTH ) );
+
+    char* currentLocale = setlocale(LC_MESSAGES,NULL);
+
+    std::istringstream stringStream( currentLocale );
+    std::string localeString;
+    std::getline(stringStream, localeString, '.');
+    hb_buffer_set_language( harfBuzzBuffer, hb_language_from_string( localeString.c_str(), localeString.size() ) );
 
     /* Layout the text */
     hb_buffer_add_utf32( harfBuzzBuffer, text, numberOfCharacters, 0u, numberOfCharacters );
@@ -207,6 +213,7 @@ struct Shaping::Plugin
     hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( harfBuzzBuffer, &glyphCount );
     hb_glyph_position_t *glyphPositions = hb_buffer_get_glyph_positions( harfBuzzBuffer, &glyphCount );
     const GlyphIndex lastGlyphIndex = glyphCount - 1u;
+
     for( GlyphIndex i = 0u; i < glyphCount; )
     {
       if( rtlDirection )