diff --git a/src/providers/fontshare.ts b/src/providers/fontshare.ts index 64bb1c6..a8df5e3 100644 --- a/src/providers/fontshare.ts +++ b/src/providers/fontshare.ts @@ -39,7 +39,10 @@ export default defineFontProvider('fontshare', async (_options, ctx) => { if (style.is_italic && !options.styles.includes('italic')) { continue } - if (!options.weights.includes(String(style.weight.number))) { + if (!style.is_italic && !options.styles.includes('normal')) { + continue + } + if (!options.weights.includes(String(style.weight.weight))) { continue } numbers.push(style.weight.number) diff --git a/test/providers/fontshare.test.ts b/test/providers/fontshare.test.ts index 4b0db55..9a2b717 100644 --- a/test/providers/fontshare.test.ts +++ b/test/providers/fontshare.test.ts @@ -36,4 +36,34 @@ describe('fontshare', () => { ] `) }) + + it('handles italic styles', async () => { + const unifont = await createUnifont([providers.fontshare()]) + const { fonts } = await unifont.resolveFont('Ranade', { + styles: ['italic'], + }) + expect(sanitizeFontSource(fonts)).toMatchInlineSnapshot(` + [ + { + "display": "swap", + "src": [ + { + "format": "woff2", + "url": "//cdn.fontshare.com/font", + }, + { + "format": "woff", + "url": "//cdn.fontshare.com/font", + }, + { + "format": "truetype", + "url": "//cdn.fontshare.com/font", + }, + ], + "style": "italic", + "weight": 400, + }, + ] + `) + }) })