#Question about building custom font providers with the Experimental Fonts API

12 messages · Page 1 of 1 (latest)

velvet matrix
#

Hey guys!
Has anyone tried building a custom font provider using the Experimental Fonts API?

I'm a bit confused about Step 3 in the docs: provider: fontProviders.myProvider()

How does Astro know where myProvider comes from?
Do I just put my provider implementation in a certain folder and it’s automatically detected as part of fontProviders, or do I need to import or register it somewhere manually?

normal junco
#

CC @icy yacht

untold wave
icy yacht
#

The example from docs (step 3) is wrong actually, bad copy paste! It should be something like this:

import { defineConfig } from 'astro/config';
import { myProvider } from "./provider/config"

export default defineConfig({
  experimental: {
    fonts: [{
      provider: myProvider(),
      // ...
    }]
  }
})
#

Does anyone want to send a PR to docs to fix it?

untold wave
icy yacht
#

@velvet matrix does it answer your questions?

velvet matrix
untold sandalBOT
#
If your issue is resolved, please help by doing the following two steps:
  1. From the ellipses (3-dot menu) in the top-right corner of the post (not the first message), edit the tags to include the Solved tag.
  2. From the same ellipses, select Close Post.
    Your post will still be available to search and can be re-opened simply by replying in it. Closing a post moves it down with older posts, so we can more easily focus on issues that still need to be resolved.
    Thank you for your help!
icy yacht
#

Btw what font provider are you building?

velvet matrix
#

I’m using a Chinese cdn font service called ZSFT to handle i18n.

#

But due to some api issues of that provider, it still feels a bit weird 🙁