Issue #1940✓ SolvedOpened April 2, 2019by ankitjainOfficial3 reactions

Add custom font

Quick answerby artf3

Try using this editor.StyleManager.getProperty('typography', 'font-family')

Read full answer below ↓

Question

Hello,

I went through, the following GitHub issues: #857 #1622 #1215

Almost all of the issues, though a little different, provide a way to add font family to the list.

Most common way to tackle, as far as I've understood:

let styleManager = this.editor.StyleManager;
let typographySector = styleManager.getSector('Typography');
let fontProperty = styleManager.getProperty('Typography', 'font-family');

... Add fonts then
const styleManager = editor.StyleManager;
const fontProperty = styleManager.getProperty('Typography', 'font-family');

... Add fonts then

For both of this, I'm getting the typographySector and fontProperty as undefined. I don't know, if I'm doing something incorrect or, if I'm incorrectly implementing them.

Here's my snippet, of what I'm trying.

editor.on('load', () => {
      const styleManager = editor.StyleManager;
      const fontProperty = styleManager.getProperty('Typography', 'font-family');
      const typographySector = styleManager.getSector('Typography');
      console.log({fontProperty, typographySector}); // both are returned undefined
})

Thanks for putting your time on this.

Answers (3)

👍 Most helpfulartfApril 3, 2019

Try using this editor.StyleManager.getProperty('typography', 'font-family')

workadevApril 12, 2019

Hi @ankitjainOfficial, I'm new to this so can you please help me how to add some Google fonts in detail? Thanks in advance.

lock[bot]April 15, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.