Skip to content

Commit

Permalink
fix(font): 增加加载元素判断
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaojob committed May 17, 2024
1 parent 7aed103 commit 6c7383d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/core/plugin/FontPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 秦少卫
* @Date: 2024-04-21 23:51:01
* @LastEditors: 秦少卫
* @LastEditTime: 2024-05-17 16:13:03
* @LastEditTime: 2024-05-17 16:40:07
* @Description: 自定义字体
*/

Expand Down Expand Up @@ -67,9 +67,18 @@ class FontPlugin {
}

downFontByJSON(str: string) {
const fontFamilies: string[] = JSON.parse(str)
.objects.filter((item: Font) => item.type.includes('text') && item.fontFamily !== 'arial')
.map((item: Font) => item.fontFamily);
const object = JSON.parse(str);
let fontFamilies: string[] = [];
const skipFonts = ['arial'];
if (object.objects) {
fontFamilies = JSON.parse(str)
.objects.filter(
(item: Font) => item.type.includes('text') && !skipFonts.includes(item.fontFamily)
)
.map((item: Font) => item.fontFamily);
} else {
fontFamilies = skipFonts.includes(object.fontFamily) ? [] : [object.fontFamily];
}

const fontFamiliesAll = fontFamilies.map((fontName) => {
const font = new FontFaceObserver(fontName);
Expand Down

0 comments on commit 6c7383d

Please sign in to comment.