RadRichTextBox default font size?

51 posts, 0 answers
  1. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 13 Jan 2011 Link to this post

    Hi Uthaya,

     Printing the document in order to show it in a DataGrid is not a very good idea.

    If you are not finding HtmlDataProvider and HtmlExportSettings, then you need to update to a newer version of the controls. You can download a free trial as I have explained in an earlier post, namely:

    • When you log in to your account at http://www.telerik.com/login.aspx?ReturnUrl=/account.aspx, in the top-right corner, click "Your account". 
    • Choose "Internal Builds Downloads" in the bottom right corner. On the new page, choose the related items from the two combo boxes and  download the hot fix.
    Then, extract the files from the zip and replace the references in your project to match the new location where you have put the assemblies.
    Let us know if you experience further difficulties.

    Regards,
    Iva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  2. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 17 Mar 2011 Link to this post

    Hello,

    After upgrading telerik dll's to Q1 2011setting default font size does not work as expected. I'm using a RadRichTextBox as following:
    <telerik:RadRichTextBox x:Name="richTextBox" IsSelectionMiniToolBarEnabled="True" IsSpellCheckingEnabled="False"
                                        DocumentInheritsDefaultStyleSettings="True" FontFamily="Verdana" FontSize="12" Grid.Row="1">
                    <telerik:RadRichTextBox.Resources>
                        <telerikXaml:XamlDataProvider x:Name="xamlDataProvider" RichTextBox="{Binding ElementName=richTextBox}" Xaml="{Binding Path=XamlText, Mode=TwoWay}" ccBehaviors:DefaultLineSpacingBehavior.DefaultLineSpacing="1"/>
                        <telerikTxt:TxtDataProvider x:Name="txtDataProvider" RichTextBox="{Binding ElementName=richTextBox}" Text="{Binding Path=PlainText, Mode=TwoWay}" ccBehaviors:DefaultLineSpacingBehavior.DefaultLineSpacing="1"/>
                    </telerik:RadRichTextBox.Resources>
                </telerik:RadRichTextBox>

    It was working fine with Q3 2010 version, RadRichTextBoxRibbonUI FontFamily was set to "Verdana" by default and RadRichTextBoxRibbonUI FontSize was set to "9" by default.But now the FontSize is set to "8.2" by default.
  3. DevCraft banner
  4. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 18 Mar 2011 Link to this post

    Hello, 

    It seems is a measurement unity issue. Setting FontSize property in Xaml in conjuntion with DocumentInheritsDefaultStylesSettings results in getting the default font size at "8.2" regardless the FontSetize value set. Fortunately I'm using a custom attached property for the DataProviders to set the default line spacing, in this "behavior" I can set the RichTextBox FontSize by code and then it works fine.
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 18 Mar 2011 Link to this post

    Hello Daní,

    We were not able to reproduce the issue on our side - neither with XamlDataProvider, nor with TxtDataProvider. Which one of the two providers are you using when observing the problem?
    If it is Xaml, could you please verify that the font size is not specified in the document before the import? The default font values of the rich text box are only applied on spans/paragraphs that do not have explicit values set.
    On a side note, 11 dip (~8.2 points)  is the default value of the font size of the UserControl, so if you do not set a value for the font size, it will inherit that one.
    Could you please check once again if the behavior is not due to any of the above-listed reasons? If that is not the case, we would greatly appreciate a sample project to help us track down the causes.

    Best wishes,
    Iva
    the Telerik team
  6. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 21 Mar 2011 Link to this post

    Hi Iva,

    the issue is setting FontSize in xaml directly. It was working fine until I upgrade solution to Q1 2011 release. Since the upgrade, setting the FontSize, regardless the value provided, shows a "8.2" value in the ribbon's fontsise selector. The RichTextBox is inside a DataTemplate, and as I'm using a custom attached property to set the document's default line spacing I'm also setting the default size in this "behavior" and it works fine. Initially, RichTextBox is always empty, I'm using DataProviders to write a pair of my viewmodel properties.
  7. Vesko
    Admin
    Vesko avatar
    45 posts

    Posted 24 Mar 2011 Link to this post

    Hi Daní,

    Thanks for your question!
    In this release we have slightly changed the behavior of the XamlFormatProvider. Now, when exporting RadDocument in XAML, all properties  such as FontFamily, FontSize, ForeColor, etc. are explicitly set no matter what is their value source - local or inherited. The reason to make this change is because we wanted to have the document looking exactly the same after export/import no matter what are the settings of the RadRichTextBox.

    Probably that is the reason for your problem. You can check what is the XAML of the document set trough the XamlDataProvider and see whether these properties are explicitly set.

    If this is the case and you need further assistance, please open a support ticket such that we to be able to try helping you further.

    Kind regards,

    Vesko
    the Telerik team

     

  8. Brian
    Brian avatar
    10 posts
    Member since:
    Apr 2011

    Posted 30 Aug 2011 Link to this post

    UPDATE:
    I figured this out.  I was missing the following: DocumentInheritsDefaultStyleSettings="true"
    -----------------------------------


    I am trying to set the font size and family for my RichTextBox which uses a TxtDataProvider to receive it's data but I can't seem to get it to work.  No font changes are shown.  Here is my code:
    <telerikFormatProvider:TxtDataProvider x:Name="txtDP" RichTextBox="{Binding ElementName=rtbPFConsult}" Text="{Binding Path=PFConsult, Mode=TwoWay}" MinHeight="100" />
    <telerik:RadRichTextBox x:Name="rtbPFConsult" IsSpellCheckingEnabled="False" FontSize="14" FontFamily="Verdana" />

    I have tried putting the TxtFormatProvider inside the RichTextBox Resources section but then nothing shows up at all.  Right now, I see my text but it is not formatted with my specified font size or family. 

    How can I make this work?
  9. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 05 Nov 2011 Link to this post

    Hello Sir,

    Am Using Radrichtextbox inside my Datagrid, But I cannot able to bind the rad Document to that radrichtextbox. Code Snippet is given Bellow.

    <sdk:DataGrid AutoGenerateColumns="False" Grid.Column="1"  Name="dataGrid1"  >
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" >
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadRichTextBox x:Name="richTextBox" Height="60">
                                    <telerik:RadRichTextBox.Resources>
                                        <telerikXAML:XamlDataProvider x:Key="XamlDataProvider"  RichTextBox="{Binding ElementName=richTextBox}" Xaml="{Binding Data, Mode=TwoWay}"  />
                                    </telerik:RadRichTextBox.Resources>
                                </telerik:RadRichTextBox>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

    In CodeBehind Code Snippet is given bellow

      private void BindData(string[] result)
            {        
                System.Collections.ObjectModel.ObservableCollection<clsMyData> objcoll = new System.Collections.ObjectModel.ObservableCollection<clsMyData>();
              
                foreach (string strData in result)
                {
                    clsMyData obj = new clsMyData();
                    obj.Data = ImportXaml(strData);
                    objcoll.Add(obj);        
                }
                dataGrid1.ItemsSource = objcoll;
            }

            public RadDocument ImportXaml(string content)
            {
                XamlFormatProvider provider = new XamlFormatProvider();
                return provider.Import(content);
            }

            public string GetXamlFromDocument(RadDocument document)
            {
                IDocumentFormatProvider exporter = new XamlFormatProvider();
                string result = null;
                using (MemoryStream stream = new MemoryStream())
                {
                    exporter.Export(document, stream);
                    stream.Seek(0, SeekOrigin.Begin);
                    StreamReader reader = new StreamReader(stream);
                    result = reader.ReadToEnd();
                }
                return result;
            }

     public class clsMyData
        {
            RadDocument m_data;
            public RadDocument Data
            {
                get { return m_data; }
                set { m_data = value; }
            }
        }


    By this Code, It Creates RadRichTextBox in Datagrid. but it shows blank. can please help me? awaiting for your reply.


  10. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 05 Nov 2011 Link to this post

    Hi uthaya,

    Data property on class clsMyData should be string typed. You don't need to import your strings to RadDocument, this task is performed by XamlDataProvider. Xaml property in XamlDataProvider is string typed, so you need to bind it to an string value.
  11. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 07 Nov 2011 Link to this post

    Hello,

    Thank u for your response. Now the values are binded to the radrichtextbox in my datagrid, but if i bind 100 records to that datagrid, it creates 100 rows, but shows only 10 correct records, remaining 90 rows repeated the same 10 records 9 times. Can you please give me the solution. presently am using telerik trail controls, is trail control creates any problem? and also I need to print the datas which are shown in my datagrid, how to print the list of rad documents? please give your suggestion.
  12. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 07 Nov 2011 Link to this post

    Hi uthaya,

    I think it may be a row virtualization issue. By default, RadGridView enables row virtualization. That means that it only creates as many rows as the view port contains (the number of rows visibles in your screen). As you scroll the radgridview it resuses the rows, updating its content to the new scolled content. RadRichTextBox is a heavy control, you need a XamlDataProvider to bind it,... may be row reutization do not perform quite well in this scenario.

    Try to disable row virtualization, setting EnableRowVirtualization property on RadGridview control to false. That may solve your problem but create a new one: GridView performance!! In this scenario you may notice that scrolling is not smoothly at all. 

    I'm using RichTextBox in an scenatio very similar. What I did is:
    1. Disabling row virtualization.
    2. Using a DataPager to minimize the number of rows to create. 

    About printing, I posted a question some time ago in this forum. It may be useful for you.http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=378299

    PS: Telerik trial version shouldn't be any issue. It the same as release versio but it adds some delay and an telerik's watermark.
  13. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 08 Nov 2011 Link to this post

    Hi Dani,

    Thanks for your suggestion. But I am using ordinary silverlight datagrid, In that data grid am using radrichtextbox. so can you please give some other solution.

    For Printing, you already gave me a link, but its not your forum, its go for new support ticket creation page. so Please give me correct link.
    Thanks in advance.
  14. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 09 Nov 2011 Link to this post

    Hello Uthaya,

    It is possible that the context of the data providers is not updated properly because the data provider is declared in the resource dictionary of RadRichTextBox. As emphasized here, the data providers have to be in the visual tree in order to have their data context updated successfully.

    As for printing, RadRichTextBox can only print/export one document. Therefore, the only solution would be to "merge" all documents into one, and print them. Here is how you can insert the content of one document into another:
    documentToInsert.Selection.SelectAll();
    DocumentFragment fragment = documentToInsert.Selection.CopySelectedDocumentElements();
    this.radRichTextBox1.Document.InsertFragment(fragment);

    Using this method, the fragment will be inserted in the other document at the current caret position (which by default is at the beginning of the document). Manipulating the caret position can be done as described in this article.

    Regards,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  15. uthaya
    uthaya avatar
    9 posts
    Member since:
    Dec 2010

    Posted 09 Nov 2011 Link to this post

    Hai Iva,

    Thanks. Now XAML Binding problem solved.
  16. Philipp
    Philipp avatar
    2 posts
    Member since:
    Mar 2012

    Posted 21 Mar 2012 Link to this post

    Clearing values of Span element does not work. When you clear it - it retain the same value. Tested on WPF latest version of Telerik.
  17. Boby
    Admin
    Boby avatar
    595 posts

    Posted 26 Mar 2012 Link to this post

    Hi Philipp,
    We were not able to reproduce the problem you described. Could you please elaborate more on how to repeat it, or open a support ticket and send us a sample project that reproduces it?

    All the best,
    Boby
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  18. Philipp
    Philipp avatar
    2 posts
    Member since:
    Mar 2012

    Posted 27 Mar 2012 Link to this post

    I have application which allows user to input formatted text and store in as HTML. It must have limitation of formatting capabilities provided to end-user - it should only support bold and italic with <b> and <i> tags. No styles, font names are allowed.

    Here is the way to reproduce the issue:
    Copy some formatted text from MS Word, paste it to Telerik Rich Text Box, then execute this code that removes formatting from span and other elements. When you try to convert it to HTML after that you still will see inline styles with font details in result HTML. This details will include styling of properties which you removed using you code.

    Here is my XAML:
                <telerik:RadRichTextBox Grid.Row="1"
                                        IsContextMenuEnabled="True"
                                        IsSelectionMiniToolBarEnabled="False"
                                        IsSpellCheckingEnabled="False"
                                        Margin="8"
                                        Name="tbxIntroduction"
                                        AcceptsReturn="True"
                                        AcceptsTab="True"
                                        CommandExecuting="tbxIntroduction_CommandExecuting"
                                        DocumentInheritsDefaultStyleSettings="True"
                                        ShowFormattingSymbols="False"
                                        ShowMergeFieldsHighlight="True">
     
                </telerik:RadRichTextBox>
                <telerikHtml:HtmlDataProvider x:Name="htmlDataProvider"
                                              RichTextBox="{Binding ElementName=tbxIntroduction}"
                                              Html="{Binding Path=.,XamlExt.Path=(local:IInstructionsEditorModel.Introduction), Mode=TwoWay, Converter={x:Static local:IntroductionHtmlConverter.Global}}">
                    <telerikHtml:HtmlDataProvider.FormatProvider>
                        <telerikHtml:HtmlFormatProvider>
                            <telerikHtml:HtmlFormatProvider.ImportSettings>
                                <telerikDocumentsHtml:HtmlImportSettings  UseDefaultStylesheetForFontProperties="True" />
                            </telerikHtml:HtmlFormatProvider.ImportSettings>
                            <telerikHtml:HtmlFormatProvider.ExportSettings>
                                <telerikDocumentsHtml:HtmlExportSettings DocumentExportLevel="Fragment"
                                                                         ExportFontStylesAsTags="True"
                                                                         ExportStyleMetadata="False"
                                                                         ImageExportMode="None"
                                                                         StyleRepositoryExportMode="ExportStylesAsCssClasses"
                                                                         StylesExportMode="Inline" />
                            </telerikHtml:HtmlFormatProvider.ExportSettings>
                        </telerikHtml:HtmlFormatProvider>
                    </telerikHtml:HtmlDataProvider.FormatProvider>
  19. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 30 Mar 2012 Link to this post

    Hi Phillip,

    The methods that clear the values of a span's FontFamily, FontSize, FontWeight, etc. do remove the values of these properties of the Span. Therefore, the spans will be shown with the default font settings of RadRichTextBox - Verdana 12 pt (unless something else is specified in the properties of RadRichTextBox or its containers in the visual tree and DocumentInheritsDefaultStyleSettings="True").

    When it comes to the export to HTML, HtmlFormatProvider exports the values of the font family and font size, in order to ensure the same look of the document when it is previewed in a browser or another consumer of the HTML.

    What you can do with the current version of the control is to set-up the rich text box like this:

    <telerik:RadRichTextBox Grid.Row="2"
                IsContextMenuEnabled="True"
                IsSelectionMiniToolBarEnabled="False"
                IsSpellCheckingEnabled="False"
                Name="tbxIntroduction"
                AcceptsReturn="True"
                AcceptsTab="True"
                CommandExecuting="tbxIntroduction_CommandExecuting"
                ShowFormattingSymbols="False"
                ShowMergeFieldsHighlight="True">
    </telerik:RadRichTextBox>
    <telerikHtml:HtmlDataProvider x:Name="htmlDataProvider"
                                      RichTextBox="{Binding ElementName=tbxIntroduction}"
                                      Html="{Binding Path=.,XamlExt.Path=(local:IInstructionsEditorModel.Introduction), Mode=TwoWay, Converter={x:Static local:IntroductionHtmlConverter.Global}}">
        <telerikHtml:HtmlDataProvider.FormatProvider>
            <telerikHtml:HtmlFormatProvider>
                <telerikHtml:HtmlFormatProvider.ImportSettings>
                    <telerikDocumentsHtml:HtmlImportSettings  UseDefaultStylesheetForFontProperties="True" />
                </telerikHtml:HtmlFormatProvider.ImportSettings>
                <telerikHtml:HtmlFormatProvider.ExportSettings>
                    <telerikDocumentsHtml:HtmlExportSettings DocumentExportLevel="Fragment"
                          ImageExportMode="None"
                          ExportFontStylesAsTags="True"
                          ExportStyleMetadata="False"
                          StyleRepositoryExportMode="ExportStylesAsCssClasses"
                          StylesExportMode="Inline"
                       />
                </telerikHtml:HtmlFormatProvider.ExportSettings>
            </telerikHtml:HtmlFormatProvider>
        </telerikHtml:HtmlDataProvider.FormatProvider>
    </telerikHtml:HtmlDataProvider>


    And in the CommandExecuting handler clear the values you wish to ignore:
    private void tbxIntroduction_CommandExecuting(object sender, CommandExecutingEventArgs e)
    {
        if (e.Command is PasteCommand)
        {
            DocumentFragment fragment = ClipboardEx.GetDocument();
            foreach (Span span in fragment.EnumerateChildrenOfType<Span>())
            {
                span.ClearValue(Span.FontSizeProperty);
                span.ClearValue(Span.FontFamilyProperty);
                span.ClearValue(Span.ForeColorProperty);
            }
            ClipboardEx.SetDocument(fragment);
        }
    }

    I hope this solution suits your requirements.
    All the best,
    Iva Toteva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  20. Amruta
    Amruta avatar
    11 posts
    Member since:
    Mar 2015

    Posted 02 Apr 2015 in reply to Boby Link to this post

    Hi

    I used your code to change font from xaml by setting properties like font family and font size.
    Then I add some line in textbox and saved. Again when i open textbox I was expecting setting will retain, but again default font verdana was set.
    see html generated using Arial font as default :
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled</title><style type="text/css">
    p { text-indent: 0pt;padding: 0px 0px 0px 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 12px;margin-left: 0px;text-align: left;font-family: 'Verdana';font-style: Normal;font-weight: normal;font-size: 16px;color: #000000; } 
    .defaultDocumentStyle { telerik-style-type: default;telerik-style-name: defaultDocumentStyle;font-family: 'Arial';font-style: Normal;font-weight: normal;font-size: 14px;margin-bottom: 12px; } 
    .p_E2968D9D { telerik-style-type: local; } 
    .s_E2968D9D { telerik-style-type: local; } 
    </style></head><body><p class="p_E2968D9D"><span class="s_E2968D9D">TEST</span></p></body></html>





















  21. Petya
    Admin
    Petya avatar
    975 posts

    Posted 06 Apr 2015 Link to this post

    Hi Amruta,

    I'm not sure what version of the control you are using, but could not reproduce the behavior you are seeing. Are you setting additional properties to the control or maybe specifying export settings for the HtmlFormatProvider?

    I'd suggest upgrading the version of Telerik UI for Silverlight that you are using to the most recent one to take advantage of all new features and fixes we've implemented.

    Regards,
    Petya
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  22. Amruta
    Amruta avatar
    11 posts
    Member since:
    Mar 2015

    Posted 07 Apr 2015 in reply to Petya Link to this post

    Hi

     

    I am using Telerik.Windows.Controls 2011.3.1220.1050 .

    Also no export settings for HtmlDataProvider set. Please suggest a way to fix this issue?

     

Back to Top
DevCraft banner