mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
This commit is contained in:
1 parent
f361c61dcc
commit
a3435d5d8d
12 files changed
+339
-58
No files matched your search
+10
-2
@@ -861,9 +861,17 @@ function uniqueLocalFonts(fonts) {
|
||||
}
|
||||
|
||||
function selectLocalFonts(fonts, names, limit) {
|
||||
const available = new Map(uniqueLocalFonts(fonts).map((font) => [localFontName(font), font]));
|
||||
const available = new Map();
|
||||
for (const font of uniqueLocalFonts(fonts)) {
|
||||
available.set(localFontName(font), font);
|
||||
for (const name of [font.postscriptName, [font.family, font.style].filter(Boolean).join(" ")]) {
|
||||
if (name) {
|
||||
available.set(`${name}.ttf`, font);
|
||||
}
|
||||
}
|
||||
}
|
||||
const matched = callWASM("ofdgoFontFileMatches", [...available.keys()], names);
|
||||
return matched.slice(0, limit).map((name) => available.get(name));
|
||||
return uniqueLocalFonts(matched.map((name) => available.get(name))).slice(0, limit);
|
||||
}
|
||||
|
||||
async function fontData(fonts) {
|
||||
|
||||
Reference in new issue
Block a user