Add Google fonts

17 Feb 20225 minutes to read

To use web fonts in Rich Text Editor, it is not needed for the web fonts to be present in local machine. To add the web fonts to Rich Text Editor, we need to refer the web font links and add the font names in the FontFamily property.

@Html.EJS().RichTextEditor("google-font").FontFamily(e => e.Items((object)ViewBag.fontItems)).ToolbarSettings(e => e.Items((object)<div>
        The Rich Text Editor control is WYSIWYG ('what you see is what you get') editor that provides the best user experience to create and update the content.
        Users can format their content using standard toolbar commands.
    <p><b> Key features:</b></p>

        <li><p> Provides &lt; IFRAME &gt; and &lt; DIV &gt; modes </p></li>

        <li><p> Capable of handling markdown editing.</p></li>

        <li><p> Contains a modular library to load the necessary functionality on demand.</p></li>

        <li><p> Provides a fully customizable toolbar.</p></li>

        <li><p> Provides HTML view to edit the source directly for developers.</p></li>

        <li><p> Supports third - party library integration.</p></li>

        <li><p> Allows preview of modified content before saving it.</p></li>

        <li><p> Handles images, hyperlinks, video, hyperlinks, uploads, etc.</p></li>

        <li><p> Contains undo / redo manager.</p></li>

        <li><p> Creates bulleted and numbered lists.</p></li>

<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
public class HomeController : Controller

    public ActionResult Index()
        object item1 = new
            text = "Segoe UI",
            value = "Segoe UI"
        object item2 = new
            text = "Roboto",
            value = "Roboto"
        object item3 = new
            text = "Great vibes",
            value = "Great Vibes,cursive"
        object item4 = new
            text = "Noto Sans",
            value = "Noto Sans"
        object item5 = new
            text = "Impact",
            value = "Impact,Charcoal,sans-serif"
        object item6 = new
            text = "Tahoma",
            value = "Tahoma,Geneva,sans-serif"
        ViewBag.fontItems = new[] { item1, item2, item3, item4, item5, item6 }; = new[] {
        "Bold", "Italic", "Underline", "StrikeThrough",
        "FontName", "FontSize", "FontColor", "BackgroundColor",
        "LowerCase", "UpperCase", "|",
        "Formats", "Alignments", "OrderedList", "UnorderedList",
        "Outdent", "Indent", "|",
        "CreateLink", "Image", "CreateTable", "|", "ClearFormat", "Print",
        "SourceCode", "FullScreen", "|", "Undo", "Redo"
        return View();

The below font style links are referred in the page.

<link rel="stylesheet" href="">
<link rel="stylesheet" href="">

In the above sample, you can see that we have added two Google web fonts (Roboto and Great vibes) to Rich Text Editor.