From ebad146d7f01640a6ab086b6c453b1da4fb1eaa5 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Mon, 17 Jun 2024 16:33:01 +0200 Subject: [PATCH] Find missing fonts in all the document (#170) * Find missing fonts in all the document * add changelog --- .changeset/nervous-spoons-remember.md | 5 +++++ plugin-src/findAllTextnodes.ts | 9 +++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .changeset/nervous-spoons-remember.md diff --git a/.changeset/nervous-spoons-remember.md b/.changeset/nervous-spoons-remember.md new file mode 100644 index 0000000..6d8fe79 --- /dev/null +++ b/.changeset/nervous-spoons-remember.md @@ -0,0 +1,5 @@ +--- +"penpot-exporter": patch +--- + +Fix fonts detection traversal on the whole document diff --git a/plugin-src/findAllTextnodes.ts b/plugin-src/findAllTextnodes.ts index 3856e22..564407b 100644 --- a/plugin-src/findAllTextnodes.ts +++ b/plugin-src/findAllTextnodes.ts @@ -1,6 +1,5 @@ import { isGoogleFont } from '@plugin/translators/text/font/gfonts'; import { isLocalFont } from '@plugin/translators/text/font/local'; -import { sleep } from '@plugin/utils'; import { registerChange } from './registerChange'; @@ -10,12 +9,10 @@ export const findAllTextNodes = async () => { for (const page of figma.root.children) { await page.loadAsync(); - for (const node of page.children) { - if (node.type === 'TEXT') { - extractMissingFonts(node, fonts); - } + const nodes = page.findAll(node => node.type === 'TEXT') as TextNode[]; - await sleep(0); + for (const node of nodes) { + extractMissingFonts(node, fonts); } }