Giter Club home page Giter Club logo

Comments (3)

tmkx avatar tmkx commented on August 10, 2024 1

In extension's special pages(like popup and options), you can do this simply:

<style>
@font-face {
  font-family: 'Fira Code';
  src: url('/assets/FiraCode-Regular.ttf') format('truetype');
}

.font {
  font-family: 'Fira Code';
}
</style>

But in content-script, you need to specify the font assets full path:

@font-face {
  font-family: 'Fira Code';
  src: url('chrome-extension://ocihbmcjobflnakhfpiedhbiafbbdgfo/assets/FiraCode-Regular.ttf') format('truetype');
}

and make the assets are accessible via src/manifest.ts:

const manifest: Manifest.WebExtensionManifest = {
  //...
  web_accessible_resources: [
    'assets/FiraCode-Regular.ttf',
  ],
}

There are two more tips:

  1. If you don't know the extension id or want to make it flexible, you can call browser.runtime.getURL('assets/FiraCode-Regular.ttf') to get the full path.
  2. Just embedded the font file in CSS by base64 data URL

from vitesse-webext.

tmkx avatar tmkx commented on August 10, 2024

Does @font-face meet your requirements?

or Google Fonts

from vitesse-webext.

ruihildt avatar ruihildt commented on August 10, 2024

Yeah I want to use @font-face and host the fonts with my extension. I just don't know how to load them with this webext starter template.

I have put fonts in an /assets folder, but simply referencing them in the css file doesn't work, so there's probably some config to make with windi, but I can't figure out how.

from vitesse-webext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.