private void SetText(string s) { s = System.Security.SecurityElement.Escape(s); String justification = "left"; String multiLineStyle = ""; String background = "#FFFFFF"; if (_writingSystem != null && WritingSystem.RightToLeftScript) { justification = "right"; } String editable = "true"; if (ReadOnly) { editable = "false"; background = System.Drawing.ColorTranslator.ToHtml(BackColor); } if (Multiline) { multiLineStyle = "word-wrap:break-word; "; } else { multiLineStyle = "white-space:nowrap; "; } Font font; if (_writingSystem != null) { font = WritingSystemDefinition.CreateFont(_writingSystem); } else { font = this.Parent.Font; } var html = new StringBuilder("<html>"); html.AppendLine("<head>"); html.AppendLine("<meta charset=\"UTF-8\">"); html.AppendLine("<style>"); html.AppendLine("@font-face {"); html.AppendFormat(" font-family: \"{0}\";\n", font.Name); html.AppendFormat(" src: local(\"{0}\");\n", font.Name); html.AppendLine("}"); html.AppendLine("</style>"); html.AppendLine("</head>"); html.AppendFormat("<body style='background:{1}' id='mainbody' {0}>", GetLanguageHtml(_writingSystem), background); html.AppendFormat("<div style='min-height:15px; font-family:{0}; font-size:{1}pt; text-align:{3} background:{5}; color:{6}; {7}' id='main' name='textArea' contentEditable='{4}'>{2}</div>", font.Name, font.Size.ToString(), s, justification, editable, System.Drawing.ColorTranslator.ToHtml(BackColor), System.Drawing.ColorTranslator.ToHtml(ForeColor), multiLineStyle); html.AppendLine("</body>"); html.AppendLine("</html>"); if (!_browserIsReadyToNavigate) { _pendingHtmlLoad = html.ToString(); } else { if (!_keyPressed) { _browser.LoadHtml(html.ToString()); } _keyPressed = false; } }