Having trouble getting help?
Contact Support
Contact Support
Add google fonts in Angular Rich text editor component
27 Apr 20244 minutes to read
To use web fonts in RTE, it is not needed for the web fonts to be present in local machine. To add the web fonts to RTE, you need to refer the web font links and add the font names in the fontFamily
property.
import { RichTextEditorAllModule } from '@syncfusion/ej2-angular-richtexteditor'
import { Component, ViewChild } from '@angular/core';
import { ToolbarService, LinkService, ImageService, HtmlEditorService, RichTextEditorComponent } from '@syncfusion/ej2-angular-richtexteditor';
@Component({
imports: [
RichTextEditorAllModule
],
standalone: true,
selector: 'app-root',
template: `<ejs-richtexteditor id='defaultRTE' #sample [value]="value" [fontFamily]='fontFamily' [toolbarSettings]='toolbarSettings'></ejs-richtexteditor>`,
providers: [ToolbarService, LinkService, ImageService, HtmlEditorService ]
})
export class AppComponent {
@ViewChild('sample') public rteObj?: RichTextEditorComponent;
public fontFamily: Object = {
items: [
{text: "Segoe UI", value: "Segoe UI", class: "e-segoe-ui", command: "Font", subCommand: "FontName"},
{text: "Roboto", value: "Roboto", command: "Font", subCommand: "FontName"}, // here font is added
{text: "Great vibes", value: "Great Vibes,cursive", command: "Font", subCommand: "FontName"}, // here font is added
{text: "Noto Sans", value: "Noto Sans", command: "Font", subCommand: "FontName"},
{text: "Impact", value: "Impact,Charcoal,sans-serif", class: "e-impact", command: "Font", subCommand: "FontName"},
{text: "Tahoma", value: "Tahoma,Geneva,sans-serif", class: "e-tahoma", command: "Font", subCommand: "FontName"},
]
};
public toolbarSettings: Object = {
items: ['Bold', 'Italic', 'Underline', 'StrikeThrough','|',
'FontName', 'FontSize', 'FontColor', 'BackgroundColor',
'LowerCase', 'UpperCase', '|',
'Formats', 'Alignments', 'OrderedList', 'UnorderedList',
'Outdent', 'Indent', '|',
'CreateLink', 'Image', '|', 'ClearFormat', 'Print',
'SourceCode', 'FullScreen', '|', 'Undo', 'Redo']
};
public value:string = `<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> `;
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
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 you have added two Google web fonts (
Roboto
andGreat vibes
) toRTE
.