'vis.js with Google Fonts

I am trying to use Open Sans with vis.js. While

  options: {
    nodes: {
      font: "22px arial #222222",
    },

works, I don't know how to get it to work with Google Fonts. Or rather with a font where the name isn't a single word.

This one doesn't work, but shows what I want to do:

  options: {
    nodes: {
      font: "22px OpenSans #222222",
    },

Edit: the problem is not the Google Font import, since this one works:

  options: {
    nodes: {
      font: "22px Nunito #222222",
    },


Solution 1:[1]

According to vis.js docs, the font option can be either a string or an object. Try configuring it as an object with this form:

    font: {
        size: 22,
        face: 'OpenSans',
        color: '#222222'
    }

Note that the size should be an integer if you choose this option. Make sure that the font name you pass to the face property is the same as your font family name provided by Google Fonts if you added the font via font (eg. 'Open Sans')

https://visjs.github.io/vis-network/docs/network/nodes.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1