To reproduce:
-add 2 RadRichTextBoxes and use the following code:
public Form1()
{
InitializeComponent();
Load += Form1_Load;
}
void SetDefaults(RadRichTextBox rtfbox)
{
StyleDefinition style = rtfbox.Document.DefaultStyleSettings;
style.SetPropertyValue(Span.FontFamilyProperty, "Microsoft Sans Serif");
style.SetPropertyValue(Span.FontSizeProperty, (float)Math.Round(Unit.PointToDip(11), 1));
rtfbox.Document.Selection.SelectAll();
rtfbox.ChangeFontFamily("Microsoft Sans Serif");
rtfbox.ChangeFontSize((float)Math.Round(Unit.PointToDip(11), 1));
}
void Form1_Load(object sender, EventArgs e)
{
SetDefaults(rtf1);
SetDefaults(rtf2);
}
private void rtf1_CurrentEditingStyleChanged(object sender, EventArgs e)
{
radLabel1.Text = "Current font: " + (string)rtf1.CurrentEditingStyle.GetPropertyValue(Span.FontFamilyProperty);
float fontSize = (float)rtf1.CurrentEditingStyle.GetPropertyValue(Span.FontSizeProperty);
fontSize = (float)Math.Round(Unit.DipToPoint(fontSize), 1);
radLabel2.Text = "Current fontsize: " + fontSize.ToString();
}
private void rtf2_CurrentEditingStyleChanged(object sender, EventArgs e)
{
radLabel3.Text = "Current font: " + (string)rtf2.CurrentEditingStyle.GetPropertyValue(Span.FontFamilyProperty);
float fontSize = (float)rtf2.CurrentEditingStyle.GetPropertyValue(Span.FontSizeProperty);
fontSize = (float)Math.Round(Unit.DipToPoint(fontSize), 1);
radLabel4.Text = "Current fontsize: " + fontSize.ToString();
}
private void radButton1_Click(object sender, EventArgs e)
{
RtfFormatProvider rtfFormatProvider = new RtfFormatProvider();
RadDocument doc = rtfFormatProvider.Import(File.ReadAllText("RadRichTextBox.rtf"));
rtf2.Document = doc;
}
private void radButton2_Click(object sender, EventArgs e)
{
RtfFormatProvider rtfProv1 = new RtfFormatProvider();
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.DefaultExt = ".rtf";
saveDialog.Filter = "Documents|*.rtf";
DialogResult dialogResult = saveDialog.ShowDialog();
string exp=string.Empty ;
if (dialogResult == System.Windows.Forms.DialogResult.OK)
{
//use "RadRichTextBox.rtf"
using (Stream output = saveDialog.OpenFile())
{
rtfProv1.Export(rtf1.Document, output);
exp = rtfProv1.Export(rtf1.Document);
}
}
RtfFormatProvider rtfProv2 = new RtfFormatProvider();
rtf2.Document = rtfProv2.Import(exp);
}
Steps to perform:
1. Write some text in the fisrt RadRichTextBox and click the button for exporting. As a result the .rtf file content is correct (considering the desired Font - "Microsoft Sans Serif").
2.The imported content (from the exported .rtf file) in the second RadRichTextBox has incorrect Font: the default Calibri Font.
Resolution:
This issue is addressed in the new version of the control - RadRichTextEditor. Please use the new control instead the RadRichTextBox.