Skip to content

Commit beb11b5

Browse files
authored
Update-more-robust way
1 parent bf6cca2 commit beb11b5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/type/p5.Font.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,9 @@ async function create(pInst, name, path, descriptors, rawFont) {
983983

984984
function createFontFace(name, path, descriptors, rawFont) {
985985

986-
if (name.includes(' ') || name.includes(',')) name = "'" + name + "'"; // NOTE: must be single-quotes
986+
if (!/^[A-Za-z_][\w-]*$/.test(name)) {
987+
name = "'" + name.replace(/'/g, "\\'") + "'"; // single quotes
988+
}
987989

988990
let fontArg = rawFont?._compressedData ?? rawFont?._data;
989991
if (!fontArg) {

0 commit comments

Comments
 (0)