Issue #2716✓ SolvedOpened April 16, 2020by Sameedkhan255 reactions

Issue in adding custom font in grapejs

Quick answerby artf5

Just do this and you should never doing this styleManager.render()

Read full answer below ↓

Question

@artf i have followed the method below and successfully added the font in list but not all of the fonts are showing correct behavior, I want to add Avenir font in the system , When i added them it is not changing the font to Avenir but giving it some default value editor.on('load', function () { styleManager = editor.StyleManager; fontProperty = styleManager.getProperty('Typography', 'font-family'); var list = []; fontProperty.set('list', list); list = [ fontProperty.addOption({value: "'Oswald', sans-serif", name: 'Oswald'}), fontProperty.addOption({value: "Helvetica Neue,Helvetica,Arial,sans...

Answers (3)

👍 Most helpfulartfApril 20, 2020

Just do this

const prop = editor.StyleManager.getProperty('typography', 'font-family');
prop.set('options', [
    {value: "'Oswald', sans-serif", name: 'Oswald'},
	...
]);

and you should never doing this styleManager.render()

Sameedkhan25April 21, 2020

Just do this and you should never doing this styleManager.render() @artf thanku so much for this i have replaced my code with this i have successfully listed the fonts in the editor as show in the screenshot, but i want to add external CSS file to add local font in the editor. currently i m using t...

artfApril 21, 2020

is it the right method to import external css that i want to preload in the editor??

Yeah, you're doing it right, you should see it. Check your font is loading correctly (wrong path, browser compatibility with .otf, etc.)

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.