Grapesjs: [QUESTION] Add custom font

Created on 2 Apr 2019  路  3Comments  路  Source: artf/grapesjs

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.

outdated

Most helpful comment

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

All 3 comments

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kosirm picture kosirm  路  3Comments

tribulant picture tribulant  路  3Comments

ryandeba picture ryandeba  路  3Comments

ionic666 picture ionic666  路  3Comments

adam-gpc picture adam-gpc  路  3Comments