Skip to main content
Solved

Default font RichText control DevExpress

  • January 21, 2023
  • 4 replies
  • 265 views

rbiram
Hero
Forum|alt.badge.img+4

Hi,

 

Does anyone know how to change the default font of a RichText control in Devexpress? I have a html variable bound to it from my datasource, but instead of going for the default font set for the whole document it's presenting the data in TImes New Roman.

 

Html variable bound to it
Advies is in Times New Roman

I've found multiple custom scripts that change the font at runtime in some very old DevExpress support threads on their community, but those scripts make use of a library called RichEditDocumentServer. That library is nowhere to be found in the version of DevExpress that's available to us.

Maybe there's a way to change the font of an HTML field before we feed it to DevExpress? I've seen this solution: 

https://community.thinkwisesoftware.com/questions-conversations-78/how-to-set-a-default-font-and-fontsize-on-a-column-with-html-editor-386

 but I don't necessarily want to change the font in the HTML editor or the column itself in Universal.

Thanks!
 

Best answer by rbiram

I've found a way to do this. In the Html expression of the RichText control you can add the following:

FormatString('<div style="font-family:Verdana; font-size:9.75pt;">{0}</div>', [column] )

The only thing that's bothering me is the extra padding in red that gets added for the <p> paragraph that's bold. Tried to overwrite it in the above code and via the following solution but it didn't work: 


Stil curious if anybody knows of another way!

View original
This topic has been closed for comments

rbiram
Hero
Forum|alt.badge.img+4
  • Hero
  • January 23, 2023

I've found a way to do this. In the Html expression of the RichText control you can add the following:

FormatString('<div style="font-family:Verdana; font-size:9.75pt;">{0}</div>', [column] )

The only thing that's bothering me is the extra padding in red that gets added for the <p> paragraph that's bold. Tried to overwrite it in the above code and via the following solution but it didn't work: 

https://community.thinkwisesoftware.com/questions-conversations-78/how-to-set-a-default-font-and-fontsize-on-a-column-with-html-editor-386


Stil curious if anybody knows of another way!


Kasper Reijnders
Forum|alt.badge.img+5

Maybe you can add a little more css styling. Like lowering the line-height, or padding/margin from the top. 


Kasper Reijnders
Forum|alt.badge.img+5

If you cannot fix this with dev-express you can always try to modify the database value of the HTML field, maybe add some styling in the field itself so that there is no spacing in front of the content.


Jasper
Superhero
  • January 27, 2023

The only thing that's bothering me is the extra padding in red that gets added for the <p> paragraph that's bold.

 

Using a span instead of div might help.

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings