Skip to content

feat(preset-web-fonts): add fetch option to LocalFontProcessor#4894

Merged
zyyv merged 2 commits intounocss:mainfrom
runyasak:feat/local-fonts-custom-fetch
Aug 30, 2025
Merged

feat(preset-web-fonts): add fetch option to LocalFontProcessor#4894
zyyv merged 2 commits intounocss:mainfrom
runyasak:feat/local-fonts-custom-fetch

Conversation

@runyasak
Copy link
Contributor

@runyasak runyasak commented Aug 20, 2025

fix: #4886

Overview

This PR resolves issue #4886 where _downloadFont in the LocalFontProcessor was hardcoded to use the default ofetch instead of adding the fetch option.
This prevented font downloading when using proxy configurations.

Scope of Work

  • Added fetch property to LocalFontProcessorOptions interface
  • Now uses options?.fetch ?? fetch to suppor fetch implementations

Example Usage

const processor = createLocalFontProcessor({
  fetch: (url: string) => 
    axios.get(url, { httpsAgent: new ProxyAgent() })
      .then(response => ({
        arrayBuffer: () => response.data
      })),
  // ... other options
})

This is my first PR for Unocss. If you have any feedback or suggestions, please let me know.

@runyasak runyasak requested review from antfu and zyyv as code owners August 20, 2025 17:26
@netlify
Copy link

netlify bot commented Aug 20, 2025

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f2524a3
🔍 Latest deploy log https://app.netlify.com/projects/unocss/deploys/68a6775a9d0a7e00072911ab
😎 Deploy Preview https://deploy-preview-4894--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

/**
* Custom fetch function to provide the font data.
*/
customFetch?: (url: string) => Promise<any>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
customFetch?: (url: string) => Promise<any>
fetch?: typeof fetch

@runyasak runyasak changed the title feat: add customFetch support to LocalFontProcessor for proxy scenarios feat: add fetch option to LocalFontProcessor Aug 21, 2025
@runyasak runyasak requested a review from antfu August 21, 2025 01:38
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 21, 2025

Open in StackBlitz

commit: f2524a3

@zyyv zyyv changed the title feat: add fetch option to LocalFontProcessor feat(preset-web-fonts): add fetch option to LocalFontProcessor Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_DownloadFont does not use customFetch

3 participants