I am importing some HTML to RadRichTextBox using HTMLFormatProvider Import. Some of the font-family values are changing to Arial when viewing the export of HTML or XAML.
This is the import code, where editor is a RadRichTextBox:
private void ImportHtml(string HTML){ HtmlFormatProvider _provider = new HtmlFormatProvider(); HtmlImportSettings settings = new HtmlImportSettings(); _provider.ImportSettings = settings; settings.UseDefaultStylesheetForFontProperties = true; editor.Document = _provider.Import(HTML);}
This is the HTML being imported:
<p> <span style="font-family:Arial;">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p><p> <span style="font-family:Helvetica;">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p><p> <span style="font-family:TimesNewRoman;">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p><p> <span style="font-family:Verdana;">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p>
This is the HTML after import (exported using HTMLFormatProvider). Notice that Verdana remains the same, but Helvetica and Times New Romans are changed to Arial in the class s_51202CB4:
"<style type=\"text/css\">\r\np { margin-top: 0px;margin-bottom: 0px;line-height: 1.15; } \r\nbody { font-family: 'Verdana'; } \r\n.Normal { telerik-style-type: paragraph;telerik-style-name: Normal;border-collapse: collapse; } \r\n.TableNormal { telerik-style-type: table;telerik-style-name: TableNormal;font-family: 'Verdana';margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;text-indent: 0px;line-height: 1.15;text-align: left;border-left: 0px none #000000;border-top: 0px none #000000;border-right: 0px none #000000;border-bottom: 0px none #000000;border-collapse: collapse; } \r\n.NormalWeb { telerik-style-type: paragraph;telerik-style-name: NormalWeb;margin-top: 0px;margin-bottom: 0px;border-collapse: collapse; } \r\n.s_51202CB4 { telerik-style-type: local;font-family: 'Arial'; } \r\n.s_DF7D34AD { telerik-style-type: local;font-family: 'Verdana'; } </style><p class=\"NormalWeb \"><span class=\"s_51202CB4\">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p><p class=\"NormalWeb \"><span class=\"s_51202CB4\">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p><p class=\"NormalWeb \"><span class=\"s_51202CB4\">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p><p class=\"NormalWeb \"><span class=\"s_DF7D34AD\">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span></p>"
This is the XAML:
"<t:RadDocument xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:t=\"clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents\" xmlns:s=\"clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents\" xmlns:r=\"clr-namespace:Telerik.Windows.Documents.Model.Revisions;assembly=Telerik.Windows.Documents\" xmlns:n=\"clr-namespace:Telerik.Windows.Documents.Model.Notes;assembly=Telerik.Windows.Documents\" xmlns:th=\"clr-namespace:Telerik.Windows.Documents.Model.Themes;assembly=Telerik.Windows.Documents\" version=\"1.4\" LayoutMode=\"Flow\" LineSpacing=\"1.15\" LineSpacingType=\"Auto\" ParagraphDefaultSpacingAfter=\"0\" ParagraphDefaultSpacingBefore=\"0\" StyleName=\"defaultDocumentStyle\">\r\n <t:RadDocument.Captions>\r\n <t:CaptionDefinition IsDefault=\"True\" IsLinkedToHeading=\"False\" Label=\"Figure\" LinkedHeadingLevel=\"0\" NumberingFormat=\"Arabic\" SeparatorType=\"Hyphen\" />\r\n <t:CaptionDefinition IsDefault=\"True\" IsLinkedToHeading=\"False\" Label=\"Table\" LinkedHeadingLevel=\"0\" NumberingFormat=\"Arabic\" SeparatorType=\"Hyphen\" />\r\n </t:RadDocument.Captions>\r\n <t:RadDocument.ProtectionSettings>\r\n <t:DocumentProtectionSettings EnableDocumentProtection=\"False\" Enforce=\"False\" HashingAlgorithm=\"None\" HashingSpinCount=\"0\" ProtectionMode=\"ReadOnly\" />\r\n </t:RadDocument.ProtectionSettings>\r\n <t:RadDocument.Styles>\r\n <s:StyleDefinition DisplayName=\"defaultDocumentStyle\" IsCustom=\"False\" IsDefault=\"False\" IsPrimary=\"True\" Name=\"defaultDocumentStyle\" Type=\"Default\">\r\n <s:StyleDefinition.ParagraphStyle>\r\n <s:ParagraphProperties LineSpacing=\"1.15\" />\r\n </s:StyleDefinition.ParagraphStyle>\r\n <s:StyleDefinition.SpanStyle>\r\n <s:SpanProperties FontFamily=\"Verdana\" FontSize=\"16\" FontStyle=\"Normal\" FontWeight=\"Normal\" ForeColor=\"#FF000000\" />\r\n </s:StyleDefinition.SpanStyle>\r\n </s:StyleDefinition>\r\n <s:StyleDefinition DisplayName=\"Normal\" IsCustom=\"False\" IsDefault=\"True\" IsPrimary=\"True\" Name=\"Normal\" Type=\"Paragraph\" UIPriority=\"0\" />\r\n <s:StyleDefinition DisplayName=\"Normal (Web)\" IsCustom=\"False\" IsDefault=\"False\" IsPrimary=\"False\" Name=\"NormalWeb\" Type=\"Paragraph\" UIPriority=\"99\">\r\n <s:StyleDefinition.ParagraphStyle>\r\n <s:ParagraphProperties AutomaticSpacingAfter=\"True\" AutomaticSpacingBefore=\"True\" SpacingAfter=\"0\" SpacingBefore=\"0\" />\r\n </s:StyleDefinition.ParagraphStyle>\r\n </s:StyleDefinition>\r\n <s:StyleDefinition DisplayName=\"Table Normal\" IsCustom=\"False\" IsDefault=\"True\" IsPrimary=\"False\" Name=\"TableNormal\" Type=\"Table\" UIPriority=\"59\" />\r\n </t:RadDocument.Styles>\r\n <t:Section>\r\n <t:Paragraph StyleName=\"NormalWeb\">\r\n <t:Span FontFamily=\"Arial\" Text=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" />\r\n </t:Paragraph>\r\n <t:Paragraph StyleName=\"NormalWeb\">\r\n <t:Span FontFamily=\"Arial\" Text=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" />\r\n </t:Paragraph>\r\n <t:Paragraph StyleName=\"NormalWeb\">\r\n <t:Span FontFamily=\"Arial\" Text=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" />\r\n </t:Paragraph>\r\n <t:Paragraph StyleName=\"NormalWeb\">\r\n <t:Span FontFamily=\"Verdana\" Text=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" />\r\n </t:Paragraph>\r\n </t:Section>\r\n</t:RadDocument>"
Please let me know if I am missing something here to maintain the correct font families.
