Set proper locale to harfbuzz 63/167363/2
authorminho.sun <minho.sun@samsung.com>
Wed, 17 Jan 2018 06:49:12 +0000 (15:49 +0900)
committerminho.sun <minho.sun@samsung.com>
Wed, 17 Jan 2018 08:17:28 +0000 (17:17 +0900)
Some country have their own cyrillic alphabets.
To draw it, DALi should set proper locale to harfbuzz.

Change-Id: I84eef22342765ac98a49ee9821f7693856069125
Signed-off-by: minho.sun <minho.sun@samsung.com>
text/dali/internal/text-abstraction/shaping-impl.cpp

index 3eb3488..24c542c 100644 (file)
@@ -29,6 +29,7 @@
 #include <harfbuzz/hb-ft.h>
 
 #include <ft2build.h>
+#include <iostream>
 
 namespace Dali
 {
@@ -194,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 );