Index: ui/gfx/render_text_harfbuzz.cc |
diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc |
index 042986f882721ba5c7876a7342d650335558d941..1db7d40e4c46d88dfd1ca17704fb2f1071bc2417 100644 |
--- a/ui/gfx/render_text_harfbuzz.cc |
+++ b/ui/gfx/render_text_harfbuzz.cc |
@@ -7,6 +7,8 @@ |
#include <limits> |
#include <set> |
+#include "base/command_line.h" |
+#include "base/i18n/base_i18n_switches.h" |
#include "base/i18n/bidi_line_iterator.h" |
#include "base/i18n/break_iterator.h" |
#include "base/i18n/char_iterator.h" |
@@ -606,6 +608,26 @@ struct CaseInsensitiveCompare { |
} |
}; |
+// Applies a forced text rendering direction if specified by a command-line |
+// switch. |
+void CheckForcedDirection(UBiDiLevel* level) { |
+ static bool has_switch = base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kForceTextDirection); |
+ if (!has_switch) |
+ return; |
+ |
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
+ if (command_line->HasSwitch(switches::kForceTextDirection)) { |
+ std::string force_flag = |
+ command_line->GetSwitchValueASCII(switches::kForceTextDirection); |
+ |
+ if (force_flag == switches::kForceDirectionRTL) |
+ *level = UBIDI_RTL; |
+ if (force_flag == switches::kForceDirectionLTR) |
+ *level = UBIDI_LTR; |
+ } |
+} |
+ |
} // namespace |
namespace internal { |
@@ -1382,6 +1404,7 @@ void RenderTextHarfBuzz::ItemizeTextToRuns( |
int32_t script_item_break = 0; |
bidi_iterator.GetLogicalRun(run_break, &script_item_break, &run->level); |
CHECK_GT(static_cast<size_t>(script_item_break), run_break); |
+ CheckForcedDirection(&run->level); |
// Odd BiDi embedding levels correspond to RTL runs. |
run->is_rtl = (run->level % 2) == 1; |
// Find the length and script of this script run. |