Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Default font name and size
posted

Hello,

I am using the XamRichTextEditor control and I'm trying to figure out how I can change the default values for the font name and size.

I am NOT interested when loading content into the editor. I am interested when the end user starts typing in the editor when the editor is completely empty/blank.

The initial font size is 11 and the font name is null but it's themed "Minor".

I've already tried changing the DefaultCHaracterSettings property on the RootNode object, but that doesn't actually work. I've also tried changing the character settings on the first ParagraphNode created by the editor by default, but that only temporarily fixes it. I am assuming that those font name/size initial values come from somewhere in the editor object and I want to know where so I can overwrite them.

Any ideas?

Parents
  • 34810
    Verified Answer
    Offline posted

    Hello Corneliu,

    Thank you for your post!

    To change the initial font settings of the XamRichTextEditor, you will need to set the character settings on the XamRichTextEditor.Document. You can do this by using the ApplyCharacterSettings method on the RichTextDocument object that represents this document. That method will take a DocumentSpan as its first parameter. Since it is the initial load of the XamRichTextEditor, I would recommend setting that to DocumentSpan.All. The next parameter is your CharacterSettings object, and finally it takes an out string error, in case something goes wrong.

    Regarding the font family query, each CharacterSettings object has a FontSettings property. This takes a FontSettings object, which has Ascii, ComplexScript, EastAsia, and HighAnsi properties for their different corresponding script characters. In your corresponding property, you will want to place the string name of the font family that you wish to apply. Most commonly, you will likely be using the Ascii property for the English language.

    I have attached a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    RichTextInitialFontCase.zip
Reply Children