Page 1 of 1
Change font programmatically
Posted: Sun May 11, 2025 3:29 pm
by fatih
Hello, I'm newbie. I want to change font settings programmatically. The code below works but RVFontComboBox1 doesn't respect the change. It still shows the default font name.
Code: Select all
RichViewEdit1.Style.TextStyles[0].FontName:='Times New Roman';
Any idea?
Re: Change font programmatically
Posted: Sun May 11, 2025 5:17 pm
by Sergey Tkachenko
After changing properties of TextSTyles, call RichViewEdit1.Format;
If the combobox is still not updated, call RichViewEdit1.CurTextStyleChange.
Re: Change font programmatically
Posted: Sun May 11, 2025 5:45 pm
by Sergey Tkachenko
By the way, if you want to change font for new documents in RichViewActions (File | New command, or for loaded text styles). it must be done differently depending on using StyleTemplates (named styles).
If you use named styles (RichViewEdit1.UseStyleTemplates = True), change properties of "Normal" style template in rvActionNew.StyleTemplates: assign its properties:
TextStyle.FontName = 'Times New Roman';
ValidTextProperties = [rvfiFontName];
You can do it at designtime using the Object Inspector (but please note that ValidTextProperties are available as ValidTextPropertiesEditor in the Object Inspector).
If you do not use style templates, use rvActionNew1.OnNew event, see the example in the topic
https://www.trichview.com/help-actions/ ... _onnew.htm