简体   繁体   中英

How to add custom font and custom font size in a Vaadin RichTextArea

I have been trying to add custom fonts and custom sizes in select boxes provided with the RichTextArea of Vaadin.

在此处输入图片说明

How do I do this?

There is no "server-side" way to handle this (up to including Vaadin 7.4). As the Book of Vaadin states:

RichTextArea inherits TextField and does not add any API functionality over it. You can add new functionality by extending the client-side components VRichTextArea and VRichTextToolbar .

So now have a look at the source of VRichTextToolbar and see, that the font lists are build by private methods called in the c'tor. So basically you would have to write it for yourself. Then you would have to learn, how to actually add all those functionality on the client side.

So other tricks to make this work are: Use CSS to hide things from the toolbar (not feasable in your case, you want might want to also add) or use Javascript to add/remove/manipulate things. Of course this is very fragile in the long term.

In the end there is only one sound advice (at least for Vaadin up to 7.4):

Use an addon:

*) Ratings and download counts make this the best choice as of writing these lines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM