Inside my WPF application there is a RichTextBox
and by showing its text content in VS Immediate Window there is a f
character with a circumflex accent, but in the display window only renders the character without the diacritic.
This two methods set and retrieve the RTB content:
Function rtbText(rtb As RichTextBox) As String
Dim txtRng As New TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd)
Return txtRng.Text
End Function
Sub rtbSetText(rtb As RichTextBox, s As String)
Dim flowDoc As New FlowDocument
Dim r As New Run(s)
Dim p As New Paragraph
p.Inlines.Add(r)
flowDoc.Blocks.Add(p)
rtb.Document = flowDoc
End Sub
The Immediate Window reports for RTB control rtbString
:
?rtbtext(rtbString)
"f̂(x,y,t)=1/(n*h_x*h_y*h_t)¡∑_i=1^n▒k(x−X_i)/(h_x)×k(y−Y_i)/(h_y)×k(t−T_i)/(h_t)" & vbCrLf
The first character f̂ is present in rtbString
but it is not showing properly:
This is the font family related problem. Try to set it, for example, to Segoe UI
:
<RichTextBox FontFamily="Segoe UI" FontSize="22" ...
When a font doesn't contain the required character, the system tries to adapt the current font and does not always get the expected result.