-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Description
This security measure is not truly necessary in a local desktop application.
It appears that the user must interact with the application before gaining access to this API.
I resolved the issue by adding a Load System Fonts button, which slightly impairs the user experience (UX design).
This behavior remains inconsistent when interacting multiple times within the application.
It is essential that this functionality be triggered exclusively through a button to work !.
IDK if you can disable this rule in chromium or bypass, but i just want to warn.
// if you call this outside a button, it not work : will work in browser console
async function getSystemFonts(): Promise<string[]> {
try {
const availableFonts = await window.queryLocalFonts();
for ( const fontData of availableFonts ) {
console.log( fontData.postscriptName );
console.log( fontData.fullName );
console.log( fontData.family );
console.log( fontData.style );
}
} catch( err ) {
console.error( err );
}
return [ ];
}https://developer.mozilla.org/en-US/docs/Web/Security/User_activation#transient_activation
https://developer.mozilla.org/en-US/docs/Web/API/Window/queryLocalFonts
wood3n
Metadata
Metadata
Assignees
Labels
No labels