Having trouble getting help?
Contact Support
Contact Support
Add Google fonts
17 Feb 20224 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)ViewBag.tools)).Value(ViewBag.value).Render()
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Great+Vibes">
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 };
ViewBag.value = @"<p>The Syncfudion Rich Text Editor, a WYSIWYG (what you see is what you get) editor, is a user interface that allows you to create, edit, and format rich text content. You can try out a demo of this editor here.</p><p><b>Key features:</b></p><ul><li><p>Provides <IFRAME> and <DIV> modes.</p></li><li><p>Bulleted and numbered lists.</p></li><li><p>Handles images, hyperlinks, videos, hyperlinks, uploads, etc.</p></li><li><p>Contains undo/redo manager. </p></li></ul><div style='display: inline-block; width: 60%; vertical-align: top; cursor: auto;'><img alt='Sky with sun' src='https://cdn.syncfusion.com/ej2/richtexteditor-resources/RTE-Overview.png' width='309' style='min-width: 10px; min-height: 10px; width: 309px; height: 174px;' class='e-rte-image e-imginline e-rte-drag-image' height='174' /></div>";
ViewBag.tools = 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="http://fonts.googleapis.com/css?family=Roboto">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Great+Vibes">
In the above sample, you can see that we have added two Google web fonts (
Roboto
andGreat vibes
) toRich Text Editor
.