From 48d54faeed36f9ebd95884731cbe59077b61be46 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 24 Mar 2020 22:14:08 +0800 Subject: [PATCH] fix textbox rendering issue wrong background color for selected text of RTL languges --- source/gui/widgets/skeletons/text_editor.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index d669c806..6cf84ac1 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -3483,9 +3483,14 @@ namespace nana { void rtl_string(point strpos, const wchar_t* str, std::size_t len, std::size_t str_px, unsigned glyph_front, unsigned glyph_selected, bool has_focused) { - editor_._m_draw_parse_string(parser_, true, strpos, selection_color(true, has_focused), str, len); + //Draw twices for RTL language in order to avoid character transforming. + //one is to draw whole string as unselected, another one is to draw whole string as selected. + + //Draw as unselected + editor_._m_draw_parse_string(parser_, true, strpos, editor_.scheme_->foreground, str, len); - //Draw selected part + + //Draw as selected, and copy the selected part to the graph. paint::graphics graph({ glyph_selected, line_px_ }); graph.typeface(this->graph_.typeface()); graph.rectangle(true, selection_color(false, has_focused));