question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use obj style with @font-face

See original GitHub issue

I’m trying to do this:

<Global
  styles={{
    '@font-face': {
      fontFamily: 'Iosevka',
      src: 'url(woff2/iosevka-thinitalic.woff2) format(woff2)',
    },
  }}
/>

Description:

I can’t figure out if the src part needs to be a string like above, or 'url(\'fonts..\') format(\'..\') or something else?

Documentation links:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
Andaristcommented, Oct 8, 2021

You are probably looking for this:

<Global
  styles={[
    {
      "@font-face": {
        fontFamily: "Lato-Regular",
        src: 'url("/fonts/Lato-Regular.ttf") format("truetype")'
      }
    },
    {
      "@font-face": {
        fontFamily: "Lato-Bold",
        src: 'url("/fonts/Lato-Bold.ttf") format("truetype")'
      }
    }
  ]}
/>
3reactions
jvanderen1commented, Aug 28, 2021

How do you load multiple styles of the same font-family in object notation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

FontFace() - Web APIs - MDN Web Docs
Specifies a font family name that can be used to match against this font face when styling elements. Takes the same type of...
Read more >
Font-Face changing via JavaScript - css - Stack Overflow
You can create a new <style> element with the @font-face rule and append it to the document 's head : var newStyle =...
Read more >
FontFace · WebPlatform Docs
This is pretty straightforward; you create a FontFace with the JavaScript new keyword as you would any other object. var f = new...
Read more >
How To Define Custom Fonts in CSS with @font-face and font ...
In this step, we will apply our downloaded fonts using the @font-face property. Using nano or your preferred text editor, create and open...
Read more >
CSS @font-face Rule - W3Schools
In the @font-face rule you must first define a name for the font (e.g. myFirstFont), and then point to the font file. To...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found