Skip to content

Commit

Permalink
Merge pull request #13445 from calixteman/ps_name
Browse files Browse the repository at this point in the history
Fix Postscript name in font to avoid bug when saving in pdf
  • Loading branch information
calixteman committed May 27, 2021
2 parents 3da9f07 + 0c69834 commit f587d59
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ function createPostTable(properties) {
); // maxMemType1
}

function createPostscriptName(name) {
// See https://docs.microsoft.com/en-us/typography/opentype/spec/recom#name.
return name.replace(/[^\x21-\x7E]|[[\](){}<>/%]/g, "").slice(0, 63);
}

function createNameTable(name, proto) {
if (!proto) {
proto = [[], []]; // no strings and unicode strings
Expand All @@ -734,7 +739,7 @@ function createNameTable(name, proto) {
proto[0][3] || "uniqueID", // 3.Unique ID
proto[0][4] || name, // 4.Full font name
proto[0][5] || "Version 0.11", // 5.Version
proto[0][6] || "", // 6.Postscript name
proto[0][6] || createPostscriptName(name), // 6.Postscript name
proto[0][7] || "Unknown", // 7.Trademark
proto[0][8] || "Unknown", // 8.Manufacturer
proto[0][9] || "Unknown", // 9.Designer
Expand Down

0 comments on commit f587d59

Please sign in to comment.