You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the loading is horribly slow. I always get load times of about 500ms. Given that node's require is synchronous, this means 500ms of blocking.
I found out that the slow load times are being caused by the fontkit dependency. I propose to fix it by only requiring fontkit "on the fly", so
classPDFFont@open: (document, src, family, id) -># Only require fontkit when we absolutely need it.fontkit=require'fontkit'iftypeof src is'string'ifStandardFont.isStandardFont src
returnnewStandardFontdocument, src, id
font=fontkit.openSync src, family
elseifBuffer.isBuffer(src)
font=fontkit.create src, family
elseif src instanceofUint8Arrayfont=fontkit.createnewBuffer(src), family
elseif src instanceofArrayBufferfont=fontkit.createnewBuffer(newUint8Array(src)), family
instead of
fontkit=require'fontkit'classPDFFont@open: (document, src, family, id) ->iftypeof src is'string'ifStandardFont.isStandardFont src
returnnewStandardFontdocument, src, id
font=fontkit.openSync src, family
elseifBuffer.isBuffer(src)
font=fontkit.create src, family
elseif src instanceofUint8Arrayfont=fontkit.createnewBuffer(src), family
elseif src instanceofArrayBufferfont=fontkit.createnewBuffer(newUint8Array(src)), family
I tested it and it solves my issue. Going to file a pull-request for this.
The text was updated successfully, but these errors were encountered:
When loading the library using
the loading is horribly slow. I always get load times of about 500ms. Given that node's require is synchronous, this means 500ms of blocking.
I found out that the slow load times are being caused by the fontkit dependency. I propose to fix it by only requiring fontkit "on the fly", so
instead of
I tested it and it solves my issue. Going to file a pull-request for this.
The text was updated successfully, but these errors were encountered: