Hello,
I have an issue with the RichEditControl. I use databinding to bind an html fragement. For all text that has no specific font I want to use the default font. I set this in a event handler using the DefaultCharacterProperties.FontName property of the document. But this does not work for Chinese characters. As soon as I have the (attached) FZShuTi font installed, this is always the default font, regardless of the DefaultCharacterProperties.FontName and DefaultCharacterProperties.FontNameEastAsia properties.
As seen in the screenshot and in the attached sample project the FZShuTi font is used instead of the SimSun font. The default non-Chinese font is applied correctly.
C#RichEditControl.ContentChanged += RichEditControl_ContentChanged;
private void RichEditControl_ContentChanged(object sender, EventArgs e)
{
var richtEditControl = (RichEditControl)sender;
var doc = richtEditControl.Document;
// First try
// doc.DefaultCharacterProperties.FontName = "SimSun";
// doc.DefaultCharacterProperties.FontSize = 12;
// Second try, which would be better
doc.DefaultCharacterProperties.FontName = "Courier New";
doc.DefaultCharacterProperties.FontSize = 12;
doc.DefaultCharacterProperties.FontNameEastAsia = "SimSun";
}
HtmlText = @"
<style>
.cs95E872D0{text-align:left;text-indent:0pt;margin:0pt 0pt 0pt 0pt;}
.cs29BB0978{color:#000000;background-color:transparent;font-weight:normal;font-style:normal;}
.useDefault{color:#000000;background-color:transparent;font-weight:normal;font-style:normal;}
.useSimSun{color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-family:SimSun}
.useFZShuTi{color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-family:FZShuTi}
.useJhengHei{color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-family:Microsoft JhengHei}
</style>
<body>
<p class=""cs95E872D0"">
<span class=""cs29BB0978"">Use default font (should be SimSun): </span>
<span class=""useDefault"">途的酸催化剂</span>
</p>
<p class=""cs95E872D0"">
<span class=""cs29BB0978"">SimSun: </span>
<span class=""useSimSun"">途的酸催化剂</span>
</p>
<p class=""cs95E872D0"">
<span class=""cs29BB0978"">FZShuTi: </span>
<span class=""useFZShuTi"">途的酸催化剂</span>
</p>
<p class=""cs95E872D0"">
<span class=""cs29BB0978"">Microsoft JhengHei: </span>
<span class=""useJhengHei"">途的酸催化剂</span>
</p>
</body>";
XAML<dxre:RichEditControl x:Name="RichEditControl" Content="{Binding Path=HtmlText, Mode=OneWay, Converter={StaticResource CustomHtmlConverter}}" ActiveViewType="Simple" />
Thanks for any help,
G.