Generate non-embedded standard fonts with Hellbox

Replace bundled font programs with glyph data. Generate replacement fonts
with PDF widths and substitutes for missing XFA fonts. Use a JavaScript
fallback when WASM is disabled or fails to load.
This commit is contained in:
Calixte Denizet
2026-11-03 18:03:47 +01:00
parent c7ca8a32e5
commit f16437faec
70 changed files with 2390 additions and 1439 deletions
+1
View File
@@ -5,6 +5,7 @@ node_modules/
external/bcmaps/
external/builder/fixtures/
external/builder/fixtures_babel/
external/hellbox/
external/openjpeg/
external/qcms/
external/quickjs/
+1 -1
View File
@@ -142,7 +142,7 @@ PDF.js uses a Web Worker architecture:
Located in `external/`:
- **bcmaps**: Binary CMaps for CJK fonts
- **standard_fonts**: Core 14 PDF fonts metrics
- **hellbox**: Font generator for the non-embedded standard fonts (WASM) and its glyph data
- **cmapscompress**: Tools for compressing CMaps
- **openjpeg**: JPEG2000 decoder (WASM)
- **quickjs**: JavaScript engine for sandboxed execution
+1
View File
@@ -38,6 +38,7 @@ export default [
"external/brotli/",
"external/builder/fixtures/",
"external/builder/fixtures_babel/",
"external/hellbox/",
"external/openjpeg/",
"external/qcms/",
"external/jbig2/",
+4
View File
@@ -24,6 +24,9 @@ const CMAP_PACKED = true;
const STANDARD_FONT_DATA_URL =
"../../../node_modules/pdfjs-dist/standard_fonts/";
// WASM modules and their JavaScript fallbacks.
const WASM_URL = "../../../node_modules/pdfjs-dist/wasm/";
// Loading file from file system into typed array.
const pdfPath =
process.argv[2] || "../../../web/compressed.tracemonkey-pldi-09.pdf";
@@ -35,6 +38,7 @@ const loadingTask = getDocument({
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
standardFontDataUrl: STANDARD_FONT_DATA_URL,
wasmUrl: WASM_URL,
});
try {
+93
View File
@@ -0,0 +1,93 @@
Copyright 2026 The Arimo Project Authors (https://github.com/googlefonts/Arimo)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+373
View File
@@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
+102
View File
@@ -0,0 +1,102 @@
Digitized data copyright (c) 2010 Google Corporation
with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc.
with Reserved Font Name Liberation.
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
PREAMBLE The goals of the Open Font License (OFL) are to stimulate
worldwide development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to provide
a free and open framework in which fonts may be shared and improved in
partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves.
The fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such.
This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components
as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting ? in part or in whole ?
any of the components of the Original Version, by changing formats or
by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer
or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a
copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole, must
be distributed entirely under this license, and must not be distributed
under any other license. The requirement for fonts to remain under
this license does not apply to any document created using the Font
Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
DEALINGS IN THE FONT SOFTWARE.
+95
View File
@@ -0,0 +1,95 @@
Copyright 2022 Google LLC. All Rights Reserved.
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/symbols)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+93
View File
@@ -0,0 +1,93 @@
Copyright 2026 The Tinos Project Authors (https://github.com/googlefonts/tinos)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+39
View File
@@ -0,0 +1,39 @@
UNICODE LICENSE V3
COPYRIGHT AND PERMISSION NOTICE
Copyright © 1991-2026 Unicode, Inc.
NOTICE TO USER: Carefully read the following legal agreement. BY
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a
copy of data files and any associated documentation (the "Data Files") or
software and any associated documentation (the "Software") to deal in the
Data Files or Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, and/or sell
copies of the Data Files or Software, and to permit persons to whom the
Data Files or Software are furnished to do so, provided that either (a)
this copyright and permission notice appear with all copies of the Data
Files or Software, or (b) this copyright and permission notice appear in
associated Documentation.
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
FILES OR SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall
not be used in advertising or otherwise to promote the sale, use or other
dealings in these Data Files or Software without prior written
authorization of the copyright holder.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
## Build
Requires Docker. In a [Hellbox](https://github.com/mozilla/hellbox/) checkout, run:
```bash
node build.js -C
node build.js -co /pdf.js/external/hellbox/ --no-embedded-data --js-fallback
```
Copy `rust/data/LICENSE_*` here. Omit `Wingdings.hbgd`, which PDF.js doesn't use.
## Usage
`src/core/hellbox.js` generates TrueType substitutes for non-embedded standard
and XFA fonts. Viewer builds put `hellbox_bg.wasm` and
`hellbox_nowasm_fallback.js` in `wasm/`, and glyph data in `standard_fonts/`
(`standardFontDataUrl`).
Glyph data comes from [Arimo](https://github.com/googlefonts/arimo),
[Tinos](https://github.com/googlefonts/tinos),
[Liberation Mono](https://github.com/liberationfonts/liberation-fonts),
and [Noto](https://notofonts.github.io/) fonts.
## Licensing
- Hellbox: MPL-2.0 (`LICENSE_HELLBOX`).
- Font data: SIL Open Font License 1.1 (`LICENSE_ARIMO`, `LICENSE_TINOS`,
`LICENSE_LIBERATION`, `LICENSE_NOTO`).
- `unicode.bin`: Unicode License v3 (`LICENSE_UNICODE`).
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+597
View File
@@ -0,0 +1,597 @@
/* THIS FILE IS GENERATED - DO NOT EDIT */
/**
* Data files needed for the family and style passed to `generate_font`.
* @param {number} family
* @param {boolean} bold
* @param {boolean} italic
* @param {number} weight
* @param {number} stem_v
* @param {number} italic_angle
* @returns {string[]}
*/
export function font_data_files(family, bold, italic, weight, stem_v, italic_angle) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.font_data_files(retptr, family, bold, italic, weight, stem_v, italic_angle);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v1 = getArrayJsValueFromWasm0(r0, r1);
wasm.__wbindgen_free(r0, r1 * 4, 4);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Generates a TrueType font from the requested glyphs (glyph id i + 1 for
* request i). Requests after the first 65534 are ignored.
*
* - `codepoints`: the codepoints of the texts of all the glyphs, one after
* the other (a text is usually a single codepoint, but it can be e.g. a
* ligature "ffi" or a letter followed by combining marks),
* - `lengths`: the number of codepoints of each glyph,
* - `widths`: the advance width of each glyph, in 1/1000 em (PDF glyph space
* units); NaN for the natural width. Can be empty (natural widths).
* - `char_codes`: the code mapped to each glyph in the cmap, 0xFFFFFFFF for
* the first codepoint of its text. Can be empty.
* - `family`: 0 for sans-serif, 1 for serif, 2 for monospace.
* - `bold`, `italic`: the style.
* - `weight` (positive values override `bold`, clamped to 1..=1000), `stem_v` (the
* expected vertical stem width, it has precedence over `weight`),
* `italic_angle` (degrees, negative for a font leaning to the right, -16.33
* for any negative angle with the serif family, which has an italic style),
* `cap_height` (the glyphs are vertically scaled to match it): 0 or NaN
* when unknown.
* - `ascent` (optional): the ascent as a fraction of the em (between 0 and
* 1), the descent being the rest, without line gap (e.g. for a text layer,
* whose lines are an em high).
* - `kerning` (optional): the kerning of some pairs of glyphs, as triples
* (index of the left glyph, index of the right one, adjustment of the
* advance of the left one in 1/1000 em): at most 10920 pairs, the first
* ones in the order of the glyphs.
* @param {Uint32Array} codepoints
* @param {Uint32Array} lengths
* @param {Float64Array} widths
* @param {Uint32Array} char_codes
* @param {number} family
* @param {boolean} bold
* @param {boolean} italic
* @param {number} weight
* @param {number} stem_v
* @param {number} italic_angle
* @param {number} cap_height
* @param {number | null} [ascent]
* @param {Float64Array | null} [kerning]
* @returns {Uint8Array}
*/
export function generate_font(codepoints, lengths, widths, char_codes, family, bold, italic, weight, stem_v, italic_angle, cap_height, ascent, kerning) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray32ToWasm0(codepoints, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray32ToWasm0(lengths, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArrayF64ToWasm0(widths, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ptr3 = passArray32ToWasm0(char_codes, wasm.__wbindgen_malloc);
const len3 = WASM_VECTOR_LEN;
var ptr4 = isLikeNone(kerning) ? 0 : passArrayF64ToWasm0(kerning, wasm.__wbindgen_malloc);
var len4 = WASM_VECTOR_LEN;
wasm.generate_font(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, family, bold, italic, weight, stem_v, italic_angle, cap_height, !isLikeNone(ascent), isLikeNone(ascent) ? 0 : ascent, ptr4, len4);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v6 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v6;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Generates a standard font of PDF (e.g. "Helvetica-Bold", see
* `StandardFont`) from the requested glyphs (the glyph id of the
* i-th one is i + 1): the arguments are the ones
* of `generate_font`, without the style (it's the one of the standard font).
* @param {Uint32Array} codepoints
* @param {Uint32Array} lengths
* @param {Float64Array} widths
* @param {Uint32Array} char_codes
* @param {string} name
* @param {number | null} [ascent]
* @param {Float64Array | null} [kerning]
* @returns {Uint8Array}
*/
export function generate_standard_font(codepoints, lengths, widths, char_codes, name, ascent, kerning) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray32ToWasm0(codepoints, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray32ToWasm0(lengths, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArrayF64ToWasm0(widths, wasm.__wbindgen_malloc);
const len2 = WASM_VECTOR_LEN;
const ptr3 = passArray32ToWasm0(char_codes, wasm.__wbindgen_malloc);
const len3 = WASM_VECTOR_LEN;
const ptr4 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len4 = WASM_VECTOR_LEN;
var ptr5 = isLikeNone(kerning) ? 0 : passArrayF64ToWasm0(kerning, wasm.__wbindgen_malloc);
var len5 = WASM_VECTOR_LEN;
wasm.generate_standard_font(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(ascent), isLikeNone(ascent) ? 0 : ascent, ptr5, len5);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v7 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v7;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Whether a named data file is embedded or registered.
* @param {string} name
* @returns {boolean}
*/
export function has_data(name) {
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.has_data(ptr0, len0);
return ret !== 0;
}
/**
* The indices of the glyphs (same `codepoints` and `lengths` as for
* `generate_font`) which can't be rendered with a family.
* @param {Uint32Array} codepoints
* @param {Uint32Array} lengths
* @param {number} family
* @returns {Uint32Array}
*/
export function missing_glyphs(codepoints, lengths, family) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray32ToWasm0(codepoints, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray32ToWasm0(lengths, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
wasm.missing_glyphs(retptr, ptr0, len0, ptr1, len1, family);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v3 = getArrayU32FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 4, 4);
return v3;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* The indices of the glyphs (same `codepoints` and `lengths` as for
* `generate_font`) which can't be rendered with a standard font.
* @param {Uint32Array} codepoints
* @param {Uint32Array} lengths
* @param {string} name
* @returns {Uint32Array}
*/
export function missing_standard_glyphs(codepoints, lengths, name) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray32ToWasm0(codepoints, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray32ToWasm0(lengths, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len2 = WASM_VECTOR_LEN;
wasm.missing_standard_glyphs(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v4 = getArrayU32FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 4, 4);
return v4;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Registers a data file for the module lifetime. Load the files listed by
* `standard_font_data_files` or `font_data_files` before generating a font.
* @param {string} name
* @param {Uint8Array} bytes
*/
export function set_data(name, bytes) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
wasm.set_data(retptr, ptr0, len0, ptr1, len1);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
if (r1) {
throw takeObject(r0);
}
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* The codepoints of the glyph data of a standard font (e.g. to generate a
* font with all its glyphs).
* @param {string} name
* @returns {Uint32Array}
*/
export function standard_font_codepoints(name) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
wasm.standard_font_codepoints(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v2 = getArrayU32FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 4, 4);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* The data files needed by a standard font (see `generate_standard_font`).
* @param {string} name
* @returns {string[]}
*/
export function standard_font_data_files(name) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
wasm.standard_font_data_files(retptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v2 = getArrayJsValueFromWasm0(r0, r1);
wasm.__wbindgen_free(r0, r1 * 4, 4);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
function __wbg_get_imports() {
const import0 = {
__proto__: null,
__wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
const ret = Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
},
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
// Cast intrinsic for `Ref(String) -> Externref`.
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
},
};
return {
__proto__: null,
"./hellbox_bg.js": import0,
};
}
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function dropObject(idx) {
if (idx < 1028) return;
heap[idx] = heap_next;
heap_next = idx;
}
function getArrayJsValueFromWasm0(ptr, len) {
ptr = ptr >>> 0;
const mem = getDataViewMemory0();
const result = [];
for (let i = ptr; i < ptr + 4 * len; i += 4) {
result.push(takeObject(mem.getUint32(i, true)));
}
return result;
}
function getArrayU32FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}
let cachedDataViewMemory0 = null;
function getDataViewMemory0() {
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
}
return cachedDataViewMemory0;
}
let cachedFloat64ArrayMemory0 = null;
function getFloat64ArrayMemory0() {
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.buffer !== wasm.memory.buffer) {
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
}
return cachedFloat64ArrayMemory0;
}
function getStringFromWasm0(ptr, len) {
return decodeText(ptr >>> 0, len);
}
let cachedUint32ArrayMemory0 = null;
function getUint32ArrayMemory0() {
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.buffer !== wasm.memory.buffer) {
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
}
return cachedUint32ArrayMemory0;
}
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.buffer !== wasm.memory.buffer) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
function getObject(idx) { return heap[idx]; }
let heap = new Array(1024).fill(undefined);
heap.push(undefined, null, true, false);
let heap_next = heap.length;
function isLikeNone(x) {
return x === undefined || x === null;
}
function passArray32ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 4, 4) >>> 0;
getUint32ArrayMemory0().set(arg, ptr / 4);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8ArrayMemory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function passArrayF64ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 8, 8) >>> 0;
getFloat64ArrayMemory0().set(arg, ptr / 8);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = cachedTextEncoder.encodeInto(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
const MAX_SAFARI_DECODE_BYTES = 2146435072;
let numBytesDecoded = 0;
function decodeText(ptr, len) {
numBytesDecoded += len;
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
numBytesDecoded = len;
}
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
const cachedTextEncoder = new TextEncoder();
if (!('encodeInto' in cachedTextEncoder)) {
cachedTextEncoder.encodeInto = function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
};
}
let WASM_VECTOR_LEN = 0;
let wasmModule, wasmInstance, wasm;
function __wbg_finalize_init(instance, module) {
wasmInstance = instance;
wasm = instance.exports;
wasmModule = module;
cachedDataViewMemory0 = null;
cachedFloat64ArrayMemory0 = null;
cachedUint32ArrayMemory0 = null;
cachedUint8ArrayMemory0 = null;
return wasm;
}
async function __wbg_load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (!module.ok) {
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
}
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
const validResponse = expectedResponseType(module.type);
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else { throw e; }
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return { instance, module };
} else {
return instance;
}
}
function expectedResponseType(type) {
switch (type) {
case 'basic': case 'cors': case 'default': return true;
}
return false;
}
}
function initSync(module) {
if (wasm !== undefined) return wasm;
if (module !== undefined) {
if (Object.getPrototypeOf(module) === Object.prototype) {
({module} = module)
} else {
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
}
}
const imports = __wbg_get_imports();
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
const instance = new WebAssembly.Instance(module, imports);
return __wbg_finalize_init(instance, module);
}
async function __wbg_init(module_or_path) {
if (wasm !== undefined) return wasm;
if (module_or_path !== undefined) {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
const imports = __wbg_get_imports();
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
module_or_path = fetch(module_or_path);
}
const { instance, module } = await __wbg_load(await module_or_path, imports);
return __wbg_finalize_init(instance, module);
}
export { initSync, __wbg_init as default };
/**
* Initializes the JS fallback using its default export as `instantiate`.
*/
function initJs(instantiate) {
if (wasm !== undefined) return wasm;
return __wbg_finalize_init({ exports: instantiate(__wbg_get_imports()) }, undefined);
}
export { initJs };
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-27
View File
@@ -1,27 +0,0 @@
// Copyright 2014 PDFium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-363
View File
@@ -1,363 +0,0 @@
LICENSE AGREEMENT AND LIMITED PRODUCT WARRANTY
LIBERATION FONT SOFTWARE
This agreement governs the use of the Software and any updates to the Software, regardless of the delivery mechanism. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to the user ("Client") a license to this work pursuant to the GNU General Public License v.2 with the exceptions set forth below and such other terms as are set forth in this End User License Agreement.
1. The Software and License Exception. LIBERATION font software (the "Software") consists of TrueType-OpenType formatted font software for rendering LIBERATION typefaces in sans-serif, serif, and monospaced character styles. You are licensed to use, modify, copy, and distribute the Software pursuant to the GNU General Public License v.2 with the following exceptions:
(a) As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
(b) As a further exception, any distribution of the object code of the Software in a physical product must provide you the right to access and modify the source code for the Software and to reinstall that modified version of the Software in object code form on the same physical product on which you received it.
2. Intellectual Property Rights. The Software and each of its components, including the source code, documentation, appearance, structure and organization are owned by Red Hat and others and are protected under copyright and other laws. Title to the Software and any component, or to any copy, modification, or merged portion shall remain with the aforementioned, subject to the applicable license. The "LIBERATION" trademark is a trademark of Red Hat, Inc. in the U.S. and other countries. This agreement does not permit Client to distribute modified versions of the Software using Red Hat's trademarks. If Client makes a redistribution of a modified version of the Software, then Client must modify the files names to remove any reference to the Red Hat trademarks and must not use the Red Hat trademarks in any way to reference or promote the modified Software.
3. Limited Warranty. To the maximum extent permitted under applicable law, the Software is provided and licensed "as is" without warranty of any kind, expressed or implied, including the implied warranties of merchantability, non-infringement or fitness for a particular purpose. Red Hat does not warrant that the functions contained in the Software will meet Client's requirements or that the operation of the Software will be entirely error free or appear precisely as described in the accompanying documentation.
4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential damages, including lost profits or lost savings arising out of the use or inability to use the Software, even if Red Hat or such dealer has been advised of the possibility of such damages.
5. General. If any provision of this agreement is held to be unenforceable, that shall not affect the enforceability of the remaining provisions. This agreement shall be governed by the laws of the State of North Carolina and of the United States, without regard to any conflict of laws provisions, except that the United Nations Convention on the International Sale of Goods shall not apply.
Copyright © 2007-2011 Red Hat, Inc. All rights reserved. LIBERATION is a trademark of Red Hat, Inc.
------------------------------------------------------------------------------
The text of the GNU General Public License, version 2, referenced above:
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-31
View File
@@ -1,31 +0,0 @@
## Foxit fonts
The pfb files in this directory were extracted from Pdfium
Original copyright notice:
```
Copyright 2014 PDFium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
```
See `LICENSE_FOXIT`.
## Liberation fonts
The `LiberationSans-*.ttf` files are the unmodified upstream release of
Liberation Sans **1.07.4**, which is licensed under the GNU General Public
License v2 with the Liberation font exception (see `LICENSE_LIBERATION`, a copy
of the `License.txt` and `COPYING` files shipped with that release):
https://fedoraproject.org/wiki/Licensing:LiberationFontLicense
Note that Liberation 2.0 and later are licensed under the SIL Open Font License
1.1 instead, so `LICENSE_LIBERATION` must be updated as well whenever these font
files are replaced.
The glyph order of these files is baked into `src/core/liberationsans_widths.js`
and into the per-glyph scale factors in `src/core/*_factors.js`, so those files
need to be regenerated when the fonts are updated.
+12 -8
View File
@@ -747,12 +747,13 @@ function createICCBundle() {
function createStandardFontBundle() {
return gulp.src(
[
"external/standard_fonts/*.pfb",
"external/standard_fonts/*.ttf",
"external/standard_fonts/LICENSE_*",
"external/hellbox/*.hbgd",
"external/hellbox/unicode.bin",
"external/hellbox/LICENSE_*",
"!external/hellbox/LICENSE_HELLBOX",
],
{
base: "external/standard_fonts",
base: "external/hellbox",
encoding: false,
}
);
@@ -762,6 +763,7 @@ function createWasmBundle({ includeQuickJS = true } = {}) {
const modules = [
["openjpeg", ["*.wasm", "openjpeg_nowasm_fallback.js", "LICENSE_*"]],
["qcms", ["*.wasm", "LICENSE_*"]],
["hellbox", ["*.wasm", "hellbox_nowasm_fallback.js", "LICENSE_HELLBOX"]],
["jbig2", ["*.wasm", "jbig2_nowasm_fallback.js", "LICENSE_*"]],
];
if (includeQuickJS) {
@@ -1781,12 +1783,13 @@ async function buildMozcentral(changedFiles = null) {
create: createICCBundle,
},
{
files: /^external\/standard_fonts\//,
files:
/^external\/hellbox\/(?:.*\.hbgd|unicode\.bin|LICENSE_(?!HELLBOX))/,
dest: MOZCENTRAL_WEB_DIR + "/standard_fonts",
create: createStandardFontBundle,
},
{
files: /^external\/(jbig2|openjpeg|qcms)\//,
files: /^external\/(hellbox|jbig2|openjpeg|qcms)\//,
dest: MOZCENTRAL_WEB_DIR + "/wasm",
create: () => createWasmBundle({ includeQuickJS: false }),
},
@@ -2079,11 +2082,11 @@ function watchMozcentral(done) {
"!web/wasm/**", // Generated by the `dev-wasm` task.
"l10n/en-US/*.ftl",
"external/bcmaps/*",
"external/hellbox/*",
"external/iccs/*",
"external/jbig2/*",
"external/openjpeg/*",
"external/qcms/*",
"external/standard_fonts/*",
"LICENSE",
];
@@ -2402,7 +2405,7 @@ function buildLib(defines, dir) {
encoding: false,
sourcemaps: enableSourceMaps,
}),
...["openjpeg", "qcms", "jbig2", "brotli"].map(name =>
...["openjpeg", "qcms", "hellbox", "jbig2", "brotli"].map(name =>
gulp.src(`external/${name}/*.js`, {
base: `${name}/`,
encoding: false,
@@ -3168,6 +3171,7 @@ gulp.task(
function watchWasm() {
gulp.watch(
[
"external/hellbox/*",
"external/openjpeg/*",
"external/qcms/*",
"external/jbig2/*",
-3
View File
@@ -144,8 +144,6 @@ class Catalog {
pageKidsCountCache = new RefMap();
standardFontDataCache = new Map();
systemFontCache = new Map();
constructor(pdfManager, xref) {
@@ -1290,7 +1288,6 @@ class Catalog {
}
this.fontCache.clear();
this.builtInCMapCache.clear();
this.standardFontDataCache.clear();
this.systemFontCache.clear();
}
+1 -4
View File
@@ -102,10 +102,7 @@ class CFFFont {
return charCodeToGlyphId;
}
let encoding = cff.encoding ? cff.encoding.encoding : null;
if (properties.isInternalFont) {
encoding = properties.defaultEncoding;
}
const encoding = cff.encoding ? cff.encoding.encoding : null;
return type1FontGlyphMapping(properties, encoding, charsets);
}
+1 -6
View File
@@ -95,7 +95,6 @@ class Page {
globalIdFactory,
fontCache,
builtInCMapCache,
standardFontDataCache,
globalColorSpaceCache,
globalImageCache,
systemFontCache,
@@ -109,7 +108,6 @@ class Page {
this.ref = ref;
this.fontCache = fontCache;
this.builtInCMapCache = builtInCMapCache;
this.standardFontDataCache = standardFontDataCache;
this.globalColorSpaceCache = globalColorSpaceCache;
this.globalImageCache = globalImageCache;
this.systemFontCache = systemFontCache;
@@ -146,7 +144,6 @@ class Page {
idFactory: this._localIdFactory,
fontCache: this.fontCache,
builtInCMapCache: this.builtInCMapCache,
standardFontDataCache: this.standardFontDataCache,
globalColorSpaceCache: this.globalColorSpaceCache,
globalImageCache: this.globalImageCache,
systemFontCache: this.systemFontCache,
@@ -1076,7 +1073,6 @@ class PDFDocument {
globalIdFactory: this._globalIdFactory,
fontCache: catalog.fontCache,
builtInCMapCache: catalog.builtInCMapCache,
standardFontDataCache: catalog.standardFontDataCache,
globalColorSpaceCache: catalog.globalColorSpaceCache,
globalImageCache: catalog.globalImageCache,
systemFontCache: catalog.systemFontCache,
@@ -1390,7 +1386,7 @@ class PDFDocument {
this.pdfManager.evaluatorOptions,
{ useSystemFonts: false }
);
const { builtInCMapCache, fontCache, standardFontDataCache } = this.catalog;
const { builtInCMapCache, fontCache } = this.catalog;
const partialEvaluator = new PartialEvaluator({
xref: this.xref,
@@ -1399,7 +1395,6 @@ class PDFDocument {
idFactory: this._globalIdFactory,
fontCache,
builtInCMapCache,
standardFontDataCache,
options,
});
const operatorList = new OperatorList();
+28 -93
View File
@@ -57,7 +57,6 @@ import {
ZapfDingbatsEncoding,
} from "./encodings.js";
import {
getFontNameToFileMap,
getSerifFonts,
getStandardFontName,
getStdFontMap,
@@ -87,6 +86,7 @@ import { getFontSubstitution } from "./font_substitutions.js";
import { getGlyphsUnicode } from "./glyphlist.js";
import { getMetrics } from "./metrics.js";
import { getUnicodeForGlyph } from "./unicode.js";
import { Hellbox } from "./hellbox.js";
import { MurmurHash3_64 } from "../shared/murmurhash3.js";
import { PDFImage } from "./image.js";
import { Stream } from "./stream.js";
@@ -233,7 +233,6 @@ class PartialEvaluator {
idFactory,
fontCache,
builtInCMapCache,
standardFontDataCache,
globalColorSpaceCache,
globalImageCache,
systemFontCache,
@@ -246,7 +245,6 @@ class PartialEvaluator {
this.idFactory = idFactory;
this.fontCache = fontCache;
this.builtInCMapCache = builtInCMapCache;
this.standardFontDataCache = standardFontDataCache;
this.globalColorSpaceCache = globalColorSpaceCache;
this.globalImageCache = globalImageCache;
this.systemFontCache = systemFontCache;
@@ -427,52 +425,6 @@ class PartialEvaluator {
return data;
}
async fetchStandardFontData(name) {
const cachedData = this.standardFontDataCache.get(name);
if (cachedData) {
return new Stream(cachedData);
}
// The symbol fonts are not consistent across platforms, always load the
// standard font data for them.
if (
this.options.useSystemFonts &&
name !== "Symbol" &&
name !== "ZapfDingbats"
) {
return null;
}
const standardFontNameToFileName = getFontNameToFileMap(),
filename = standardFontNameToFileName[name];
let data;
try {
if (this.options.useWorkerFetch) {
data = await fetchBinaryData(
`${this.options.standardFontDataUrl}${filename}`
);
} else {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Only worker-thread fetching supported.");
}
// Get the data on the main-thread instead.
data = await this.handler.sendWithPromise("FetchBinaryData", {
kind: "standardFontDataUrl",
filename,
});
}
} catch (ex) {
warn(ex);
return null;
}
// Cache the "raw" standard font data, to avoid fetching it repeatedly
// (see e.g. issue 11399).
this.standardFontDataCache.set(name, data);
return new Stream(data);
}
async buildFormXObject(
resources,
xobj,
@@ -1093,7 +1045,7 @@ class PartialEvaluator {
const font = state.font;
const glyphs = font.charsToGlyphs(chars);
if (font.data) {
if (font.data && !font.missingFile) {
const isAddToPathSet = !!(
state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG
);
@@ -3736,7 +3688,7 @@ class PartialEvaluator {
}
}
const nonEmbeddedFont = !properties.file || properties.isInternalFont,
const nonEmbeddedFont = !properties.file,
isSymbolsFontName = getSymbolsFonts()[properties.name];
// Ignore an incorrectly specified named encoding for non-embedded
// symbol fonts (fixes issue16464.pdf).
@@ -4558,19 +4510,12 @@ class PartialEvaluator {
};
const widths = dict.get("Widths");
const standardFontName = getStandardFontName(baseFontName);
let file = null;
if (standardFontName) {
file = await this.fetchStandardFontData(standardFontName);
properties.isInternalFont = !!file;
}
if (!properties.isInternalFont && this.options.useSystemFonts) {
if (this.options.useSystemFonts) {
properties.systemFontInfo = getFontSubstitution(
this.systemFontCache,
this.idFactory,
this.options.standardFontDataUrl,
baseFontName,
standardFontName,
getStandardFontName(baseFontName),
type
);
}
@@ -4596,7 +4541,9 @@ class PartialEvaluator {
newProperties
);
}
return new Font(baseFontName, file, newProperties, this.options);
const font = new Font(baseFontName, null, newProperties, this.options);
await Hellbox.generate(this, font);
return font;
}
}
@@ -4681,8 +4628,6 @@ class PartialEvaluator {
warn(`translateFont - fetching "${fontName.name}" font file: "${ex}".`);
fontFile = null;
}
let isInternalFont = false;
let glyphScaleFactors = null;
let systemFontInfo = null;
if (fontFile) {
if (fontFile.dict) {
@@ -4696,37 +4641,29 @@ class PartialEvaluator {
}
} else if (cssFontInfo) {
// We've a missing XFA font.
const standardFontName = getXfaFontName(fontName.name);
if (standardFontName) {
const xfaFont = getXfaFontName(fontName.name);
if (xfaFont) {
cssFontInfo.fontFamily = `${cssFontInfo.fontFamily}-PdfJS-XFA`;
cssFontInfo.metrics = standardFontName.metrics || null;
glyphScaleFactors = standardFontName.factors || null;
fontFile = await this.fetchStandardFontData(standardFontName.name);
isInternalFont = !!fontFile;
// We're using a substitution font but for example widths (if any)
// are related to the glyph positions in the font.
// So we overwrite everything here to be sure that widths are
// correct.
cssFontInfo.metrics = xfaFont.metrics || null;
baseDict = dict = getXfaFontDict(fontName.name);
composite = true;
}
} else if (!isType3Font) {
const standardFontName = getStandardFontName(fontName.name);
if (standardFontName) {
fontFile = await this.fetchStandardFontData(standardFontName);
isInternalFont = !!fontFile;
}
if (!isInternalFont && this.options.useSystemFonts) {
systemFontInfo = getFontSubstitution(
this.systemFontCache,
this.idFactory,
this.options.standardFontDataUrl,
fontName.name,
standardFontName,
type
const data = await Hellbox.generateXfaFont(
this,
xfaFont.name,
dict.get("W")
);
if (data) {
fontFile = new Stream(data);
}
}
} else if (!isType3Font && this.options.useSystemFonts) {
systemFontInfo = getFontSubstitution(
this.systemFontCache,
this.idFactory,
fontName.name,
getStandardFontName(fontName.name),
type
);
}
const fontMatrix = lookupMatrix(
@@ -4771,7 +4708,6 @@ class PartialEvaluator {
length1,
length2,
length3,
isInternalFont,
loadedName: baseDict.loadedName,
composite,
fixedPitch: false,
@@ -4788,7 +4724,6 @@ class PartialEvaluator {
italicAngle,
isType3Font,
cssFontInfo,
scaleFactors: glyphScaleFactors,
systemFontInfo,
};
@@ -4824,7 +4759,6 @@ class PartialEvaluator {
const substitution = getFontSubstitution(
this.systemFontCache,
this.idFactory,
this.options.standardFontDataUrl,
fontName.name,
standardFontName,
type
@@ -4837,6 +4771,7 @@ class PartialEvaluator {
font.systemFontInfo = substitution;
}
}
await Hellbox.generate(this, font);
return font;
}
@@ -4911,7 +4846,7 @@ class TranslatedFont {
}
fallback(handler, evaluatorOptions) {
if (!this.font.data) {
if (!this.font.data || this.font.missingFile) {
return;
}
// When font loading failed, fall back to the built-in font renderer.
+4 -24
View File
@@ -111,7 +111,6 @@ const substitutionMap = new Map([
"Apple Symbols",
"Cantarell",
],
path: "LiberationSans-Regular.ttf",
style: NORMAL,
ultimate: "sans-serif",
},
@@ -120,7 +119,6 @@ const substitutionMap = new Map([
"Helvetica-Bold",
{
alias: "Helvetica",
path: "LiberationSans-Bold.ttf",
style: BOLD,
ultimate: "sans-serif",
},
@@ -129,7 +127,6 @@ const substitutionMap = new Map([
"Helvetica-Oblique",
{
alias: "Helvetica",
path: "LiberationSans-Italic.ttf",
style: ITALIC,
ultimate: "sans-serif",
},
@@ -138,7 +135,6 @@ const substitutionMap = new Map([
"Helvetica-BoldOblique",
{
alias: "Helvetica",
path: "LiberationSans-BoldItalic.ttf",
style: BOLDITALIC,
ultimate: "sans-serif",
},
@@ -627,25 +623,19 @@ function getFamilyName(str) {
* @param {string} [substitution.alias] - Key of another substitution to
* inherit the src values from.
* @param {Array<string>} [substitution.local] - Local font names.
* @param {string} [substitution.path] - Font file name, relative to
* `localFontPath`.
* @param {string} [substitution.fallback] - Key of the substitution to take
* the ultimate font from.
* @param {object} [substitution.style] - CSS `font-style` and `font-weight`.
* @param {string} [substitution.ultimate] - Ultimate (generic) font family.
* @param {Array<string>} src - Contains src values (local(...) or url(...)).
* @param {string} localFontPath - Path to local fonts.
* @param {Array<string>} src - Local font sources.
* @param {boolean} useFallback - Whether to use fallback font.
* @param {boolean} usePath - Whether to use path to font.
* @param {string} append - Style (Bold, Italic, ...) to append to font name.
* @returns {object} The resolved `style` and `ultimate` values.
*/
function generateFont(
{ alias, local, path, fallback, style, ultimate },
{ alias, local, fallback, style, ultimate },
src,
localFontPath,
useFallback = true,
usePath = true,
append = ""
) {
const result = {
@@ -666,9 +656,7 @@ function generateFont(
generateFont(
substitution,
src,
localFontPath,
/* useFallback = */ useFallback && !fallback,
/* usePath = */ usePath && !path,
aliasAppend
)
);
@@ -684,16 +672,11 @@ function generateFont(
const { ultimate: fallbackUltimate } = generateFont(
fallbackInfo,
src,
localFontPath,
useFallback,
/* usePath = */ usePath && !path,
append
);
result.ultimate ||= fallbackUltimate;
}
if (usePath && path && localFontPath) {
src.push(`url(${localFontPath}${path})`);
}
return result;
}
@@ -704,15 +687,13 @@ function generateFont(
* rule like this:
* {
* font-family: 'Times';
* src: local('Times New Roman'), local('Subst1'), local('Subst2'),
* url(.../TimesNewRoman.ttf)
* src: local('Times New Roman'), local('Subst1'), local('Subst2');
* font-weight: normal;
* font-style: normal;
* }
* or use the FontFace API.
* @param {Map} systemFontCache The cache of local fonts.
* @param {object} idFactory The ids factory.
* @param {string} localFontPath Path to the fonts directory.
* @param {string} baseFontName The font name to be substituted.
* @param {string | undefined} standardFontName The standard font name to use
* if the base font is not available.
@@ -723,7 +704,6 @@ function generateFont(
function getFontSubstitution(
systemFontCache,
idFactory,
localFontPath,
baseFontName,
standardFontName,
type
@@ -805,7 +785,7 @@ function getFontSubstitution(
if (mustAddBaseFont && validateFontName(baseFontName)) {
src.push(`local(${baseFontName})`);
}
const { style, ultimate } = generateFont(substitution, src, localFontPath);
const { style, ultimate } = generateFont(substitution, src);
const guessFallback = ultimate === null;
const fallback = guessFallback ? "" : `,${ultimate}`;
+107 -55
View File
@@ -58,7 +58,6 @@ import {
getSupplementalGlyphMapForCalibri,
getSupplementalGlyphMapForTrebuchetMS,
} from "./standard_fonts.js";
import { GlyfTable, pruneCompositeGlyphCycles } from "./glyf.js";
import { IdentityToUnicodeMap, ToUnicodeMap } from "./to_unicode_map.js";
import { CFFFont } from "./cff_font.js";
import { CharCodeMap } from "./char_code_map.js";
@@ -69,6 +68,7 @@ import { getFontBasicMetrics } from "./metrics.js";
import { getLookupTableFactory } from "./core_utils.js";
import { MathClamp } from "../shared/math_clamp.js";
import { OpenTypeFileBuilder } from "./opentype_file_builder.js";
import { pruneCompositeGlyphCycles } from "./glyf.js";
import { Stream } from "./stream.js";
import { Type1Font } from "./type1_font.js";
@@ -93,6 +93,7 @@ const EXPORT_DATA_PROPERTIES = [
"fallbackName",
"fontExtraProperties",
"fontMatrix",
"generatedFontName",
"isInvalidPDFjsFont",
"isType3Font",
"italic",
@@ -140,9 +141,6 @@ function adjustWidths(properties) {
}
function adjustTrueTypeToUnicode(properties, isSymbolicFont, nameRecords) {
if (properties.isInternalFont) {
return;
}
if (properties.hasIncludedToUnicodeMap) {
return; // The font dictionary has a `ToUnicode` entry.
}
@@ -187,9 +185,6 @@ function adjustTrueTypeToUnicode(properties, isSymbolicFont, nameRecords) {
}
function adjustType1ToUnicode(properties, builtInEncoding) {
if (properties.isInternalFont) {
return;
}
if (properties.hasIncludedToUnicodeMap) {
return; // The font dictionary has a `ToUnicode` entry.
}
@@ -1051,8 +1046,17 @@ class Font {
#glyphCache = new Map();
#generatedCodePoints = null;
#id = null;
// Unlike `missingFile`, still set when a generated font replaces this one.
#withoutFile = false;
charProcOperatorList;
standardFontName = null;
toFontChar = new Map();
constructor(name, file, properties, evaluatorOptions) {
@@ -1061,7 +1065,7 @@ class Font {
this.disableFontFace = evaluatorOptions.disableFontFace;
this.fontExtraProperties = evaluatorOptions.fontExtraProperties;
this.loadedName = properties.loadedName;
this.loadedName = this.#id = properties.loadedName;
this.isType3Font = properties.isType3Font;
this.missingFile = false;
this.cssFontInfo = properties.cssFontInfo;
@@ -1247,7 +1251,7 @@ class Font {
}
fallbackToSystemFont(properties) {
this.missingFile = true;
this.missingFile = this.#withoutFile = true;
// The file data is not specified. Trying to fix the font name
// to be used with the canvas.font.
const { name, type } = this;
@@ -1260,6 +1264,9 @@ class Font {
);
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
if (isStandardFont || isMappedToStandardFont) {
this.standardFontName = stdFontMap[fontName];
}
const fontBasicMetricsMap = getFontBasicMetrics();
const metrics = fontBasicMetricsMap[fontName];
@@ -1418,6 +1425,89 @@ class Font {
this.loadedName = fontName.split("-", 1)[0];
}
/**
* @param {boolean} distinctWidths - Keep widths, or mark conflicts as NaN.
* @returns {Array<{codePoint: number, width: number,
* charCodes: Array<number>}>}
*/
getMissingFileGlyphs(distinctWidths) {
const charCodes = new Set(this.toFontChar.keys());
const isIdentity =
this.composite && this.cidEncoding.startsWith("Identity-");
if (!this.composite || isIdentity) {
for (const charCode of Object.keys(this.widths || {})) {
charCodes.add(+charCode);
}
}
if (isIdentity) {
const glyphsUnicode = getGlyphsUnicode();
for (const encoding of [
StandardEncoding,
WinAnsiEncoding,
MacRomanEncoding,
]) {
for (const glyphName of encoding) {
const codePoint = glyphsUnicode[glyphName];
if (codePoint !== undefined) {
// Added last, after the font's own char codes.
charCodes.add(codePoint);
}
}
}
}
const glyphs = new Map();
for (const charCode of charCodes) {
const { fontChar, width } = this._charToGlyph(charCode);
const codePoint = fontChar.codePointAt(0);
if (codePoint === undefined) {
continue;
}
const key = distinctWidths ? `${codePoint}_${width}` : codePoint;
let glyph = glyphs.get(key);
if (!glyph) {
glyph = { codePoint, width, charCodes: [] };
glyphs.set(key, glyph);
} else if (!distinctWidths && !Object.is(glyph.width, width)) {
glyph.width = NaN;
}
glyph.charCodes.push(charCode);
}
return Array.from(glyphs.values());
}
/**
* @param {object} generated
* @param {Uint8Array} generated.data
* @param {Uint32Array} generated.codePoints - Cmap code points.
* @param {Map<number, number>} generated.toFontChar - PDF character codes
* mapped to private-use code points.
* @param {boolean} replacesFont - Use as the primary font, or as a fallback.
*/
setGeneratedFont({ data, codePoints, toFontChar }, replacesFont) {
const name = `${this.#id}_generated`;
this.data = data;
this.generatedFontName = name;
this.#generatedCodePoints = new Set(codePoints);
for (const [charCode, fontCharCode] of toFontChar) {
this.toFontChar.set(charCode, fontCharCode);
}
this.#glyphCache.clear();
if (replacesFont) {
this.systemFontInfo = null;
this.loadedName = name;
this.missingFile = false;
this.remeasure = false;
return;
}
// Copy the shared substitution info; insert before the generic families.
const families = this.systemFontInfo.css.split(",");
families.splice(2, 0, `"${name}"`);
this.systemFontInfo = {
...this.systemFontInfo,
css: families.join(","),
};
}
checkAndRepair(name, font, properties) {
const VALID_TABLES = [
"OS/2",
@@ -2849,7 +2939,7 @@ class Font {
writeUint32(tables.maxp.data, 0, version);
}
let isGlyphLocationsLong = int16(
const isGlyphLocationsLong = int16(
tables.head.data[50],
tables.head.data[51]
);
@@ -2877,41 +2967,6 @@ class Font {
}
}
if (properties.scaleFactors?.length === numGlyphs && isTrueType) {
const { scaleFactors } = properties;
const glyphs = new GlyfTable({
glyfTable: tables.glyf.data,
isGlyphLocationsLong,
locaTable: tables.loca.data,
numGlyphs,
});
glyphs.scale(scaleFactors);
const { glyf, loca, isLocationLong } = glyphs.write();
tables.glyf.data = glyf;
tables.loca.data = loca;
if (isLocationLong !== !!isGlyphLocationsLong) {
tables.head.data[50] = 0;
isGlyphLocationsLong = tables.head.data[51] = isLocationLong ? 1 : 0;
}
const metrics = tables.hmtx.data;
for (let i = 0; i < numGlyphs; i++) {
const j = 4 * i;
const advanceWidth = Math.round(
scaleFactors[i] * int16(metrics[j], metrics[j + 1])
);
metrics[j] = (advanceWidth >> 8) & 0xff;
metrics[j + 1] = advanceWidth & 0xff;
const lsb = Math.round(
scaleFactors[i] * signedInt16(metrics[j + 2], metrics[j + 3])
);
writeSignedInt16(metrics, j + 2, lsb);
}
}
// Glyph 0 is duplicated and appended.
let numGlyphsOut = numGlyphs + 1;
let dupFirstEntry = true;
@@ -3214,14 +3269,8 @@ class Font {
// in a symbol font) and the page content draws it with the char code 0,
// so map it explicitly when it would otherwise be left unmapped, but
// only when the glyph is non-empty to avoid displaying a ".notdef" box
// for fonts that don't (issue 17333). This is restricted to embedded
// fonts since the ".notdef" glyph of a standard substitution font must
// never be rendered.
if (
!properties.isInternalFont &&
!charCodeToGlyphId.has(0) &&
hasGlyph(0)
) {
// for fonts that don't (issue 17333).
if (!charCodeToGlyphId.has(0) && hasGlyph(0)) {
charCodeToGlyphId.set(0, 0);
}
}
@@ -3610,7 +3659,7 @@ class Font {
// First try the toFontChar map, if it's not there then try falling
// back to the char code.
fontCharCode = this.toFontChar.get(charcode) || charcode;
if (this.missingFile) {
if (this.#withoutFile) {
const glyphName =
this.differences.get(charcode) || this.defaultEncoding[charcode];
if (
@@ -3657,10 +3706,13 @@ class Font {
warn(`charToGlyph - invalid fontCharCode: ${fontCharCode}`);
}
}
if (this.#generatedCodePoints?.has(fontChar.codePointAt(0))) {
isInFont = true;
}
let isRotated = false;
if (
this.missingFile &&
this.#withoutFile &&
this.vertical &&
fontChar.length === 1 &&
this.#hasVerticalVariant(charcode)
+1 -3
View File
@@ -121,9 +121,7 @@ function buildMapping(baseEncoding, glyphNames) {
function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
let charCodeToGlyphId, glyphsUnicodeMap;
if (properties.isInternalFont) {
charCodeToGlyphId = buildMapping(builtInEncoding, glyphNames);
} else if (properties.baseEncodingName) {
if (properties.baseEncodingName) {
// If a valid base encoding name was used, the mapping is initialized with
// that.
charCodeToGlyphId = buildMapping(
+2 -664
View File
@@ -15,16 +15,8 @@
import { makeSet } from "../shared/util.js";
const ON_CURVE_POINT = 1 << 0;
const X_SHORT_VECTOR = 1 << 1;
const Y_SHORT_VECTOR = 1 << 2;
const REPEAT_FLAG = 1 << 3;
const X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR = 1 << 4;
const Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR = 1 << 5;
const OVERLAP_SIMPLE = 1 << 6;
const ARG_1_AND_2_ARE_WORDS = 1 << 0;
const ARGS_ARE_XY_VALUES = 1 << 1;
// const ARGS_ARE_XY_VALUES = 1 << 1;
// const ROUND_XY_TO_GRID = 1 << 2;
const WE_HAVE_A_SCALE = 1 << 3;
const MORE_COMPONENTS = 1 << 5;
@@ -38,660 +30,6 @@ const WE_HAVE_INSTRUCTIONS = 1 << 8;
const GLYPH_HEADER_SIZE = 10;
/**
* GlyfTable object represents a glyf table containing glyph information:
* - glyph header (xMin, yMin, xMax, yMax);
* - contours if any;
* - components if the glyph is a composite.
*
* It's possible to re-scale each glyph in order to have a new font which
* exactly fits an other one: the goal is to be able to build some substitution
* font for well-known fonts (Myriad, Arial, ...).
*
* A full description of glyf table can be found here
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html
*/
class GlyfTable {
constructor({ glyfTable, isGlyphLocationsLong, locaTable, numGlyphs }) {
this.glyphs = [];
const loca = new DataView(
locaTable.buffer,
locaTable.byteOffset,
locaTable.byteLength
);
const glyf = new DataView(
glyfTable.buffer,
glyfTable.byteOffset,
glyfTable.byteLength
);
const offsetSize = isGlyphLocationsLong ? 4 : 2;
let prev = isGlyphLocationsLong ? loca.getUint32(0) : 2 * loca.getUint16(0);
let pos = 0;
for (let i = 0; i < numGlyphs; i++) {
pos += offsetSize;
const next = isGlyphLocationsLong
? loca.getUint32(pos)
: 2 * loca.getUint16(pos);
if (next === prev) {
this.glyphs.push(new Glyph({}));
continue;
}
const glyph = Glyph.parse(prev, glyf);
this.glyphs.push(glyph);
prev = next;
}
}
getSize() {
return Math.sumPrecise(
// Round to next multiple of 4 if needed.
this.glyphs.map(g => (g.getSize() + 3) & ~3)
);
}
write() {
const totalSize = this.getSize();
const glyfTable = new DataView(new ArrayBuffer(totalSize));
const isLocationLong = totalSize > /* 0xffff * 2 */ 0x1fffe;
const offsetSize = isLocationLong ? 4 : 2;
const locaTable = new DataView(
new ArrayBuffer((this.glyphs.length + 1) * offsetSize)
);
if (isLocationLong) {
locaTable.setUint32(0, 0);
} else {
locaTable.setUint16(0, 0);
}
let pos = 0;
let locaIndex = 0;
for (const glyph of this.glyphs) {
pos += glyph.write(pos, glyfTable);
// Round to next multiple of 4 if needed.
pos = (pos + 3) & ~3;
locaIndex += offsetSize;
if (isLocationLong) {
locaTable.setUint32(locaIndex, pos);
} else {
locaTable.setUint16(locaIndex, pos >> 1);
}
}
return {
isLocationLong,
loca: new Uint8Array(locaTable.buffer),
glyf: new Uint8Array(glyfTable.buffer),
};
}
scale(factors) {
for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
this.glyphs[i].scale(factors[i]);
}
}
}
class Glyph {
constructor({ header = null, simple = null, composites = null }) {
this.header = header;
this.simple = simple;
this.composites = composites;
}
static parse(pos, glyf) {
const [read, header] = GlyphHeader.parse(pos, glyf);
pos += read;
if (header.numberOfContours < 0) {
// Composite glyph.
const composites = [];
while (true) {
const [n, composite] = CompositeGlyph.parse(pos, glyf);
pos += n;
composites.push(composite);
if (!(composite.flags & MORE_COMPONENTS)) {
break;
}
}
return new Glyph({ header, composites });
}
const simple = SimpleGlyph.parse(pos, glyf, header.numberOfContours);
return new Glyph({ header, simple });
}
getSize() {
if (!this.header) {
return 0;
}
const size = this.simple
? this.simple.getSize()
: Math.sumPrecise(this.composites.map(c => c.getSize()));
return this.header.getSize() + size;
}
write(pos, buf) {
if (!this.header) {
return 0;
}
const spos = pos;
pos += this.header.write(pos, buf);
if (this.simple) {
pos += this.simple.write(pos, buf);
} else {
for (const composite of this.composites) {
pos += composite.write(pos, buf);
}
}
return pos - spos;
}
scale(factor) {
if (!this.header) {
return;
}
const xMiddle = (this.header.xMin + this.header.xMax) / 2;
this.header.scale(xMiddle, factor);
if (this.simple) {
this.simple.scale(xMiddle, factor);
} else {
for (const composite of this.composites) {
composite.scale(xMiddle, factor);
}
}
}
}
class GlyphHeader {
constructor({ numberOfContours, xMin, yMin, xMax, yMax }) {
this.numberOfContours = numberOfContours;
this.xMin = xMin;
this.yMin = yMin;
this.xMax = xMax;
this.yMax = yMax;
}
static parse(pos, glyf) {
return [
GLYPH_HEADER_SIZE,
new GlyphHeader({
numberOfContours: glyf.getInt16(pos),
xMin: glyf.getInt16(pos + 2),
yMin: glyf.getInt16(pos + 4),
xMax: glyf.getInt16(pos + 6),
yMax: glyf.getInt16(pos + 8),
}),
];
}
getSize() {
return GLYPH_HEADER_SIZE;
}
write(pos, buf) {
buf.setInt16(pos, this.numberOfContours);
buf.setInt16(pos + 2, this.xMin);
buf.setInt16(pos + 4, this.yMin);
buf.setInt16(pos + 6, this.xMax);
buf.setInt16(pos + 8, this.yMax);
return GLYPH_HEADER_SIZE;
}
scale(x, factor) {
this.xMin = Math.round(x + (this.xMin - x) * factor);
this.xMax = Math.round(x + (this.xMax - x) * factor);
}
}
class Contour {
constructor({ flags, xCoordinates, yCoordinates }) {
this.xCoordinates = xCoordinates;
this.yCoordinates = yCoordinates;
this.flags = flags;
}
}
class SimpleGlyph {
constructor({ contours, instructions }) {
this.contours = contours;
this.instructions = instructions;
}
static parse(pos, glyf, numberOfContours) {
const endPtsOfContours = [];
for (let i = 0; i < numberOfContours; i++) {
const endPt = glyf.getUint16(pos);
pos += 2;
endPtsOfContours.push(endPt);
}
const numberOfPt = endPtsOfContours[numberOfContours - 1] + 1;
const instructionLength = glyf.getUint16(pos);
pos += 2;
const instructions = new Uint8Array(glyf).slice(
pos,
pos + instructionLength
);
pos += instructionLength;
const flags = [];
for (let i = 0; i < numberOfPt; pos++, i++) {
let flag = glyf.getUint8(pos);
flags.push(flag);
if (flag & REPEAT_FLAG) {
const count = glyf.getUint8(++pos);
flag ^= REPEAT_FLAG;
for (let m = 0; m < count; m++) {
flags.push(flag);
}
i += count;
}
}
const allXCoordinates = [];
let xCoordinates = [];
let yCoordinates = [];
let pointFlags = [];
const contours = [];
let endPtsOfContoursIndex = 0;
let lastCoordinate = 0;
// Get x coordinates.
for (let i = 0; i < numberOfPt; i++) {
const flag = flags[i];
if (flag & X_SHORT_VECTOR) {
// 8-bits unsigned value.
const x = glyf.getUint8(pos++);
lastCoordinate += flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR ? x : -x;
xCoordinates.push(lastCoordinate);
} else if (flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR) {
// IS_SAME.
xCoordinates.push(lastCoordinate);
} else {
lastCoordinate += glyf.getInt16(pos);
pos += 2;
xCoordinates.push(lastCoordinate);
}
if (endPtsOfContours[endPtsOfContoursIndex] === i) {
// Next entry is the first one of a new contour.
endPtsOfContoursIndex++;
allXCoordinates.push(xCoordinates);
xCoordinates = [];
}
}
lastCoordinate = 0;
endPtsOfContoursIndex = 0;
for (let i = 0; i < numberOfPt; i++) {
const flag = flags[i];
if (flag & Y_SHORT_VECTOR) {
// 8-bits unsigned value.
const y = glyf.getUint8(pos++);
lastCoordinate += flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR ? y : -y;
yCoordinates.push(lastCoordinate);
} else if (flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR) {
// IS_SAME.
yCoordinates.push(lastCoordinate);
} else {
lastCoordinate += glyf.getInt16(pos);
pos += 2;
yCoordinates.push(lastCoordinate);
}
pointFlags.push((flag & ON_CURVE_POINT) | (flag & OVERLAP_SIMPLE));
if (endPtsOfContours[endPtsOfContoursIndex] === i) {
// Next entry is the first one of a new contour.
xCoordinates = allXCoordinates[endPtsOfContoursIndex];
endPtsOfContoursIndex++;
contours.push(
new Contour({
flags: pointFlags,
xCoordinates,
yCoordinates,
})
);
yCoordinates = [];
pointFlags = [];
}
}
return new SimpleGlyph({
contours,
instructions,
});
}
getSize() {
let size = this.contours.length * 2 + 2 + this.instructions.length;
let lastX = 0;
let lastY = 0;
for (const contour of this.contours) {
size += contour.flags.length;
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
const x = contour.xCoordinates[i];
const y = contour.yCoordinates[i];
let abs = Math.abs(x - lastX);
if (abs > 255) {
size += 2;
} else if (abs > 0) {
size += 1;
}
lastX = x;
abs = Math.abs(y - lastY);
if (abs > 255) {
size += 2;
} else if (abs > 0) {
size += 1;
}
lastY = y;
}
}
return size;
}
write(pos, buf) {
const spos = pos;
const xCoordinates = [];
const yCoordinates = [];
const flags = [];
let lastX = 0;
let lastY = 0;
for (const contour of this.contours) {
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
let flag = contour.flags[i];
const x = contour.xCoordinates[i];
let delta = x - lastX;
if (delta === 0) {
flag |= X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;
xCoordinates.push(0);
} else {
const abs = Math.abs(delta);
if (abs <= 255) {
flag |=
delta >= 0
? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR
: X_SHORT_VECTOR;
xCoordinates.push(abs);
} else {
xCoordinates.push(delta);
}
}
lastX = x;
const y = contour.yCoordinates[i];
delta = y - lastY;
if (delta === 0) {
flag |= Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;
yCoordinates.push(0);
} else {
const abs = Math.abs(delta);
if (abs <= 255) {
flag |=
delta >= 0
? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR
: Y_SHORT_VECTOR;
yCoordinates.push(abs);
} else {
yCoordinates.push(delta);
}
}
lastY = y;
flags.push(flag);
}
// Write endPtsOfContours entry.
buf.setUint16(pos, xCoordinates.length - 1);
pos += 2;
}
// Write instructionLength.
buf.setUint16(pos, this.instructions.length);
pos += 2;
if (this.instructions.length) {
// Write instructions.
new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(
this.instructions,
pos
);
pos += this.instructions.length;
}
// Write flags.
for (const flag of flags) {
buf.setUint8(pos++, flag);
}
// Write xCoordinates.
for (let i = 0, ii = xCoordinates.length; i < ii; i++) {
const x = xCoordinates[i];
const flag = flags[i];
if (flag & X_SHORT_VECTOR) {
buf.setUint8(pos++, x);
} else if (!(flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR)) {
buf.setInt16(pos, x);
pos += 2;
}
}
// Write yCoordinates.
for (let i = 0, ii = yCoordinates.length; i < ii; i++) {
const y = yCoordinates[i];
const flag = flags[i];
if (flag & Y_SHORT_VECTOR) {
buf.setUint8(pos++, y);
} else if (!(flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR)) {
buf.setInt16(pos, y);
pos += 2;
}
}
return pos - spos;
}
scale(x, factor) {
for (const contour of this.contours) {
if (contour.xCoordinates.length === 0) {
continue;
}
for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
contour.xCoordinates[i] = Math.round(
x + (contour.xCoordinates[i] - x) * factor
);
}
}
}
}
class CompositeGlyph {
constructor({
flags,
glyphIndex,
argument1,
argument2,
transf,
instructions,
}) {
this.flags = flags;
this.glyphIndex = glyphIndex;
this.argument1 = argument1;
this.argument2 = argument2;
this.transf = transf;
this.instructions = instructions;
}
static parse(pos, glyf) {
const spos = pos;
const transf = [];
let flags = glyf.getUint16(pos);
const glyphIndex = glyf.getUint16(pos + 2);
pos += 4;
let argument1, argument2;
if (flags & ARG_1_AND_2_ARE_WORDS) {
if (flags & ARGS_ARE_XY_VALUES) {
argument1 = glyf.getInt16(pos);
argument2 = glyf.getInt16(pos + 2);
} else {
argument1 = glyf.getUint16(pos);
argument2 = glyf.getUint16(pos + 2);
}
pos += 4;
flags ^= ARG_1_AND_2_ARE_WORDS;
} else {
if (flags & ARGS_ARE_XY_VALUES) {
argument1 = glyf.getInt8(pos);
argument2 = glyf.getInt8(pos + 1);
} else {
argument1 = glyf.getUint8(pos);
argument2 = glyf.getUint8(pos + 1);
}
pos += 2;
}
if (flags & WE_HAVE_A_SCALE) {
// Single F2.14.
transf.push(glyf.getUint16(pos));
pos += 2;
} else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
// Two F2.14.
transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2));
pos += 4;
} else if (flags & WE_HAVE_A_TWO_BY_TWO) {
// Four F2.14.
transf.push(
glyf.getUint16(pos),
glyf.getUint16(pos + 2),
glyf.getUint16(pos + 4),
glyf.getUint16(pos + 6)
);
pos += 8;
}
let instructions = null;
if (flags & WE_HAVE_INSTRUCTIONS) {
const instructionLength = glyf.getUint16(pos);
pos += 2;
instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
pos += instructionLength;
}
return [
pos - spos,
new CompositeGlyph({
flags,
glyphIndex,
argument1,
argument2,
transf,
instructions,
}),
];
}
getSize() {
let size = 2 + 2 + this.transf.length * 2;
if (this.flags & WE_HAVE_INSTRUCTIONS) {
size += 2 + this.instructions.length;
}
size += 2;
if (this.flags & 2) {
// Arguments are signed.
if (!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)) {
size += 2;
}
} else if (!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)) {
size += 2;
}
return size;
}
write(pos, buf) {
const spos = pos;
if (this.flags & ARGS_ARE_XY_VALUES) {
// Arguments are signed.
if (!(
this.argument1 >= -128 &&
this.argument1 <= 127 &&
this.argument2 >= -128 &&
this.argument2 <= 127
)) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
}
} else if (!(
this.argument1 >= 0 &&
this.argument1 <= 255 &&
this.argument2 >= 0 &&
this.argument2 <= 255
)) {
this.flags |= ARG_1_AND_2_ARE_WORDS;
}
buf.setUint16(pos, this.flags);
buf.setUint16(pos + 2, this.glyphIndex);
pos += 4;
if (this.flags & ARG_1_AND_2_ARE_WORDS) {
if (this.flags & ARGS_ARE_XY_VALUES) {
buf.setInt16(pos, this.argument1);
buf.setInt16(pos + 2, this.argument2);
} else {
buf.setUint16(pos, this.argument1);
buf.setUint16(pos + 2, this.argument2);
}
pos += 4;
} else {
buf.setUint8(pos, this.argument1);
buf.setUint8(pos + 1, this.argument2);
pos += 2;
}
if (this.flags & WE_HAVE_INSTRUCTIONS) {
buf.setUint16(pos, this.instructions.length);
pos += 2;
// Write instructions.
if (this.instructions.length) {
new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(
this.instructions,
pos
);
pos += this.instructions.length;
}
}
return pos - spos;
}
scale(x, factor) {}
}
function pruneCompositeGlyphCycles(glyfTable, locaEntries, numGlyphs) {
const glyf = new DataView(
glyfTable.buffer,
@@ -798,4 +136,4 @@ function pruneCompositeGlyphCycles(glyfTable, locaEntries, numGlyphs) {
return droppedGlyphs;
}
export { GlyfTable, pruneCompositeGlyphCycles };
export { pruneCompositeGlyphCycles };
+223
View File
@@ -0,0 +1,223 @@
/* Copyright 2026 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
font_data_files as fontDataFiles,
generate_font as generateFont,
generate_standard_font as generateStandardFont,
has_data as hasData,
initJs,
missing_glyphs as missingGlyphs,
missing_standard_glyphs as missingStandardGlyphs,
set_data as setData,
standard_font_codepoints as standardFontCodePoints,
standard_font_data_files as standardFontDataFiles,
} from "../../external/hellbox/hellbox.js";
import { makeMap, warn } from "../shared/util.js";
import { WasmLoader } from "./wasm_loader.js";
const FAMILIES = new Map([
["Courier", 2],
["Helvetica", 0],
["Times", 1],
]);
// Hellbox's request limit; it also keeps the PUA codes in plane 15.
const MAX_GLYPHS = 65534;
const PRIVATE_USE_START = 0xf0000;
/**
* Generates substitutes for non-embedded standard and XFA fonts.
*/
class Hellbox {
static #isLoaded = false;
static #loadPromises = new WeakMap();
static #pendingData = new WeakMap();
/**
* @param {object} context - Document handler and evaluator options.
* @returns {Promise<boolean>} Whether the generator is available.
*/
static async #load(context) {
const { standardFontDataUrl, useWorkerFetch, wasmUrl } = context.options;
if (useWorkerFetch && (!wasmUrl || !standardFontDataUrl)) {
return false;
}
return (
this.#isLoaded ||
this.#loadPromises.getOrInsertComputed(context.handler, () =>
WasmLoader.load(
context,
"hellbox_bg.wasm",
"hellbox_nowasm_fallback.js",
instantiate => {
initJs(instantiate);
this.#isLoaded = true;
}
)
)
);
}
/**
* Load missing glyph data.
* @param {object} context
* @param {Array<string>} files
*/
static #loadData(context, files) {
const pending = this.#pendingData.getOrInsertComputed(
context.handler,
makeMap
);
return Promise.all(
files.map(file => {
if (hasData(file)) {
return null;
}
return pending.getOrInsertComputed(file, () =>
WasmLoader.fetch(context, "standardFontDataUrl", file)
.then(data => {
if (!hasData(file)) {
setData(file, data);
}
})
.finally(() => pending.delete(file))
);
})
);
}
/**
* Generate a replacement or fallback for a non-embedded standard font.
* @param {object} context - Document handler and evaluator options.
* @param {Font} font
*/
static async generate(context, font) {
const { standardFontName } = font;
if (!standardFontName || font.vertical || font.cssFontInfo) {
return;
}
const replacesFont =
!font.systemFontInfo ||
standardFontName === "Symbol" ||
standardFontName === "ZapfDingbats";
if (context.options.disableFontFace && !replacesFont) {
return;
}
if (!(await this.#load(context))) {
return;
}
const weight = font.black ? 900 : 0;
const family = weight
? FAMILIES.get(standardFontName.split("-", 1)[0])
: undefined;
const italic = /Oblique|Italic/.test(standardFontName);
const glyphs = font.getMissingFileGlyphs(replacesFont);
const codePoints = Uint32Array.from(glyphs, glyph => glyph.codePoint);
const lengths = new Uint32Array(codePoints.length).fill(1);
try {
const files =
family === undefined
? standardFontDataFiles(standardFontName)
: [
...fontDataFiles(family, false, false, 0, 0, 0),
...fontDataFiles(family, false, italic, weight, 0, 0),
];
await this.#loadData(context, files);
const missing = new Set(
family === undefined
? missingStandardGlyphs(codePoints, lengths, standardFontName)
: missingGlyphs(codePoints, lengths, family)
);
const available = glyphs
.filter((_, i) => !missing.has(i))
.slice(0, MAX_GLYPHS);
if (available.length === 0) {
return;
}
const toFontChar = new Map();
const mappedCodePoints = new Set();
let privateUseCode = PRIVATE_USE_START;
const fontCharCodes = Uint32Array.from(
available,
({ codePoint, charCodes }) => {
if (!mappedCodePoints.has(codePoint)) {
mappedCodePoints.add(codePoint);
return codePoint;
}
for (const charCode of charCodes) {
toFontChar.set(charCode, privateUseCode);
}
return privateUseCode++;
}
);
const args = [
Uint32Array.from(available, glyph => glyph.codePoint),
lengths.subarray(0, available.length),
Float64Array.from(available, glyph => glyph.width ?? NaN),
fontCharCodes,
];
const data =
family === undefined
? generateStandardFont(...args, standardFontName)
: generateFont(...args, family, false, italic, weight, 0, 0, 0);
font.setGeneratedFont(
{ data, codePoints: fontCharCodes, toFontChar },
replacesFont
);
} catch (ex) {
warn(`Hellbox.generate - "${font.name}": "${ex}".`);
}
}
/**
* Generate an XFA substitute with Unicode-based widths.
* @param {object} context - Document handler and evaluator options.
* @param {string} standardFontName
* @param {Array} widths - Unicode-based PDF `W` array.
* @returns {Promise<Uint8Array | null>}
*/
static async generateXfaFont(context, standardFontName, widths) {
if (!(await this.#load(context))) {
return null;
}
try {
await this.#loadData(context, standardFontDataFiles(standardFontName));
const widthByCodePoint = new Map();
for (let i = 0, ii = widths.length - 1; i < ii; i += 2) {
const start = widths[i];
for (const [j, width] of widths[i + 1].entries()) {
widthByCodePoint.set(start + j, width);
}
}
const codePoints = standardFontCodePoints(standardFontName);
return generateStandardFont(
codePoints,
new Uint32Array(codePoints.length).fill(1),
Float64Array.from(codePoints, cp => widthByCodePoint.get(cp) ?? NaN),
new Uint32Array(0),
standardFontName
);
} catch (ex) {
warn(`Hellbox.generateXfaFont - "${standardFontName}": "${ex}".`);
return null;
}
}
}
export { Hellbox };
-23
View File
@@ -99,28 +99,6 @@ const getStdFontMap = getLookupTableFactory(function (t) {
t["TimesNewRomanPSMT-Italic"] = "Times-Italic";
});
// Contains mapping for standard fonts and xfa fonts.
const getFontNameToFileMap = getLookupTableFactory(function (t) {
t.Courier = "FoxitFixed.pfb";
t["Courier-Bold"] = "FoxitFixedBold.pfb";
t["Courier-BoldOblique"] = "FoxitFixedBoldItalic.pfb";
t["Courier-Oblique"] = "FoxitFixedItalic.pfb";
t.Helvetica = "LiberationSans-Regular.ttf";
t["Helvetica-Bold"] = "LiberationSans-Bold.ttf";
t["Helvetica-BoldOblique"] = "LiberationSans-BoldItalic.ttf";
t["Helvetica-Oblique"] = "LiberationSans-Italic.ttf";
t["Times-Roman"] = "FoxitSerif.pfb";
t["Times-Bold"] = "FoxitSerifBold.pfb";
t["Times-BoldItalic"] = "FoxitSerifBoldItalic.pfb";
t["Times-Italic"] = "FoxitSerifItalic.pfb";
t.Symbol = "FoxitSymbol.pfb";
t.ZapfDingbats = "FoxitDingbats.pfb";
t["LiberationSans-Regular"] = "LiberationSans-Regular.ttf";
t["LiberationSans-Bold"] = "LiberationSans-Bold.ttf";
t["LiberationSans-Italic"] = "LiberationSans-Italic.ttf";
t["LiberationSans-BoldItalic"] = "LiberationSans-BoldItalic.ttf";
});
/**
* Holds the map of the non-standard fonts that might be included as
* a standard fonts without glyph data.
@@ -1077,7 +1055,6 @@ function isKnownFontName(name) {
}
export {
getFontNameToFileMap,
getGlyphMapForMacOrderedFonts,
getGlyphMapForStandardFonts,
getNonStdFontMap,
+2
View File
@@ -25,8 +25,10 @@ const getSpecialPUASymbols = getLookupTableFactory(function (t) {
t[63194] = 0x00ae; // registerserif (0xF6DA) => registered
t[63722] = 0x2122; // trademarksans (0xF8EA) => trademark
t[63195] = 0x2122; // trademarkserif (0xF6DB) => trademark
t[63717] = 0x203e; // radicalex (0xF8E5) => overline
t[63718] = 0x23d0; // arrowvertex (0xF8E6)
t[63719] = 0x23af; // arrowhorizex (0xF8E7)
t[63732] = 0x23aa; // braceex (0xF8F4)
t[63733] = 0x23ae; // integralex (0xF8F5)
t[63729] = 0x23a7; // bracelefttp (0xF8F1)
t[63730] = 0x23a8; // braceleftmid (0xF8F2)
+20 -20
View File
@@ -69,14 +69,14 @@ import { normalizeFontName } from "./fonts_utils.js";
const getXFAFontMap = getLookupTableFactory(function (t) {
t["MyriadPro-Regular"] = t["PdfJS-Fallback-Regular"] = {
name: "LiberationSans-Regular",
name: "Helvetica",
factors: MyriadProRegularFactors,
baseWidths: LiberationSansRegularWidths,
baseMapping: LiberationSansRegularMapping,
metrics: MyriadProRegularMetrics,
};
t["MyriadPro-Bold"] = t["PdfJS-Fallback-Bold"] = {
name: "LiberationSans-Bold",
name: "Helvetica-Bold",
factors: MyriadProBoldFactors,
baseWidths: LiberationSansBoldWidths,
baseMapping: LiberationSansBoldMapping,
@@ -86,7 +86,7 @@ const getXFAFontMap = getLookupTableFactory(function (t) {
t["MyriadPro-Italic"] =
t["PdfJS-Fallback-Italic"] =
{
name: "LiberationSans-Italic",
name: "Helvetica-Oblique",
factors: MyriadProItalicFactors,
baseWidths: LiberationSansItalicWidths,
baseMapping: LiberationSansItalicMapping,
@@ -96,7 +96,7 @@ const getXFAFontMap = getLookupTableFactory(function (t) {
t["MyriadPro-BoldItalic"] =
t["PdfJS-Fallback-BoldItalic"] =
{
name: "LiberationSans-BoldItalic",
name: "Helvetica-BoldOblique",
factors: MyriadProBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
baseMapping: LiberationSansBoldItalicMapping,
@@ -106,104 +106,104 @@ const getXFAFontMap = getLookupTableFactory(function (t) {
t.Arial =
t["Arial-Regular"] =
{
name: "LiberationSans-Regular",
name: "Helvetica",
baseWidths: LiberationSansRegularWidths,
baseMapping: LiberationSansRegularMapping,
};
t["Arial-BoldMT"] = t["Arial-Bold"] = {
name: "LiberationSans-Bold",
name: "Helvetica-Bold",
baseWidths: LiberationSansBoldWidths,
baseMapping: LiberationSansBoldMapping,
};
t["Arial-ItalicMT"] = t["Arial-Italic"] = {
name: "LiberationSans-Italic",
name: "Helvetica-Oblique",
baseWidths: LiberationSansItalicWidths,
baseMapping: LiberationSansItalicMapping,
};
t["Arial-BoldItalicMT"] = t["Arial-BoldItalic"] = {
name: "LiberationSans-BoldItalic",
name: "Helvetica-BoldOblique",
baseWidths: LiberationSansBoldItalicWidths,
baseMapping: LiberationSansBoldItalicMapping,
};
t["Calibri-Regular"] = {
name: "LiberationSans-Regular",
name: "Helvetica",
factors: CalibriRegularFactors,
baseWidths: LiberationSansRegularWidths,
baseMapping: LiberationSansRegularMapping,
metrics: CalibriRegularMetrics,
};
t["Calibri-Bold"] = {
name: "LiberationSans-Bold",
name: "Helvetica-Bold",
factors: CalibriBoldFactors,
baseWidths: LiberationSansBoldWidths,
baseMapping: LiberationSansBoldMapping,
metrics: CalibriBoldMetrics,
};
t["Calibri-Italic"] = {
name: "LiberationSans-Italic",
name: "Helvetica-Oblique",
factors: CalibriItalicFactors,
baseWidths: LiberationSansItalicWidths,
baseMapping: LiberationSansItalicMapping,
metrics: CalibriItalicMetrics,
};
t["Calibri-BoldItalic"] = {
name: "LiberationSans-BoldItalic",
name: "Helvetica-BoldOblique",
factors: CalibriBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
baseMapping: LiberationSansBoldItalicMapping,
metrics: CalibriBoldItalicMetrics,
};
t["Segoeui-Regular"] = {
name: "LiberationSans-Regular",
name: "Helvetica",
factors: SegoeuiRegularFactors,
baseWidths: LiberationSansRegularWidths,
baseMapping: LiberationSansRegularMapping,
metrics: SegoeuiRegularMetrics,
};
t["Segoeui-Bold"] = {
name: "LiberationSans-Bold",
name: "Helvetica-Bold",
factors: SegoeuiBoldFactors,
baseWidths: LiberationSansBoldWidths,
baseMapping: LiberationSansBoldMapping,
metrics: SegoeuiBoldMetrics,
};
t["Segoeui-Italic"] = {
name: "LiberationSans-Italic",
name: "Helvetica-Oblique",
factors: SegoeuiItalicFactors,
baseWidths: LiberationSansItalicWidths,
baseMapping: LiberationSansItalicMapping,
metrics: SegoeuiItalicMetrics,
};
t["Segoeui-BoldItalic"] = {
name: "LiberationSans-BoldItalic",
name: "Helvetica-BoldOblique",
factors: SegoeuiBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
baseMapping: LiberationSansBoldItalicMapping,
metrics: SegoeuiBoldItalicMetrics,
};
t["Helvetica-Regular"] = t.Helvetica = {
name: "LiberationSans-Regular",
name: "Helvetica",
factors: HelveticaRegularFactors,
baseWidths: LiberationSansRegularWidths,
baseMapping: LiberationSansRegularMapping,
metrics: HelveticaRegularMetrics,
};
t["Helvetica-Bold"] = {
name: "LiberationSans-Bold",
name: "Helvetica-Bold",
factors: HelveticaBoldFactors,
baseWidths: LiberationSansBoldWidths,
baseMapping: LiberationSansBoldMapping,
metrics: HelveticaBoldMetrics,
};
t["Helvetica-Italic"] = {
name: "LiberationSans-Italic",
name: "Helvetica-Oblique",
factors: HelveticaItalicFactors,
baseWidths: LiberationSansItalicWidths,
baseMapping: LiberationSansItalicMapping,
metrics: HelveticaItalicMetrics,
};
t["Helvetica-BoldItalic"] = {
name: "LiberationSans-BoldItalic",
name: "Helvetica-BoldOblique",
factors: HelveticaBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
baseMapping: LiberationSansBoldItalicMapping,
+72 -45
View File
@@ -163,32 +163,46 @@ class FontLoader {
);
}
async #loadFontFace(font) {
if (!this.isFontLoadingAPISupported) {
return;
}
const fontFace = font.createNativeFontFace();
if (!fontFace) {
return;
}
this.addNativeFontFace(fontFace);
try {
await fontFace.loaded;
} catch (ex) {
warn(`Failed to load font '${fontFace.family}': '${ex}'.`);
this.removeNativeFontFace(fontFace);
if (!font.missingFile) {
// Use paths when an embedded or replacement font fails to load.
font.disableFontFace = true;
throw ex;
}
}
}
async bind(font) {
// Add the font to the DOM only once; skip if the font is already loaded.
if (font.attached || (font.missingFile && !font.systemFontInfo)) {
if (
font.attached ||
(font.missingFile && !font.systemFontInfo && !font.generatedFontName)
) {
return;
}
font.attached = true;
if (font.systemFontInfo) {
await this.loadSystemFont(font);
// A generated font can be the fallback of the system font.
await Promise.all([this.loadSystemFont(font), this.#loadFontFace(font)]);
return;
}
if (this.isFontLoadingAPISupported) {
const nativeFontFace = font.createNativeFontFace();
if (nativeFontFace) {
this.addNativeFontFace(nativeFontFace);
try {
await nativeFontFace.loaded;
} catch (ex) {
warn(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);
// When font loading failed, fall back to the built-in font renderer.
font.disableFontFace = true;
throw ex;
}
}
await this.#loadFontFace(font);
return; // The font was, asynchronously, loaded.
}
@@ -422,29 +436,41 @@ class FontFaceObject {
}
}
#getFontFaceProperties() {
const { generatedFontName } = this;
let family = generatedFontName || this.loadedName;
const css = Object.create(null);
if (generatedFontName) {
// Match CanvasGraphics.setFont; these outlines already include the style.
css.style = this.italic ? "italic" : "normal";
css.weight = "normal";
if (this.black) {
css.weight = "900";
} else if (this.bold) {
css.weight = "bold";
}
} else if (this.cssFontInfo) {
family = serializeFontFamily(this.cssFontInfo.fontFamily);
css.weight = this.cssFontInfo.fontWeight;
if (this.cssFontInfo.italicAngle) {
css.style = `oblique ${this.cssFontInfo.italicAngle}deg`;
}
}
return { family, css };
}
createNativeFontFace() {
const { data } = this; // Get `data` just once, since it's not shadowed.
if (!data || this.disableFontFace) {
return null;
}
let nativeFontFace;
if (!this.cssFontInfo) {
nativeFontFace = new FontFace(this.loadedName, data, {});
} else {
const css = {
weight: this.cssFontInfo.fontWeight,
};
if (this.cssFontInfo.italicAngle) {
css.style = `oblique ${this.cssFontInfo.italicAngle}deg`;
}
nativeFontFace = new FontFace(
serializeFontFamily(this.cssFontInfo.fontFamily),
data,
css
);
}
const { family, css } = this.#getFontFaceProperties();
const nativeFontFace = new FontFace(family, data, css);
this._inspectFont?.(this);
if (!this.generatedFontName) {
this._inspectFont?.(this);
}
return nativeFontFace;
}
@@ -459,21 +485,18 @@ class FontFaceObject {
}
// Add the @font-face rule to the document.
const url = `url(data:${this.mimetype};base64,${data.toBase64()});`;
let rule;
if (!this.cssFontInfo) {
rule = `@font-face {font-family:"${this.loadedName}";src:${url}}`;
} else {
let css = `font-weight: ${this.cssFontInfo.fontWeight};`;
if (this.cssFontInfo.italicAngle) {
css += `font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;
}
// The font family originates from the PDF document, hence it must be
// serialized as a <string> to prevent arbitrary rule injection.
const fontFamily = serializeFontFamily(this.cssFontInfo.fontFamily);
rule = `@font-face {font-family:${fontFamily};${css}src:${url}}`;
const { family, css } = this.#getFontFaceProperties();
// The font family can originate from the PDF document, hence it must be
// serialized as a <string> to prevent arbitrary rule injection.
let rule = `@font-face {font-family:${serializeFontFamily(family)};`;
for (const [property, value] of Object.entries(css)) {
rule += `font-${property}: ${value};`;
}
rule += `src:${url}}`;
this._inspectFont?.(this, url);
if (!this.generatedFontName) {
this._inspectFont?.(this, url);
}
return rule;
}
@@ -556,6 +579,10 @@ class FontFaceObject {
return this.#fontData.fallbackName;
}
get generatedFontName() {
return this.#fontData.generatedFontName;
}
get loadedName() {
return this.#fontData.loadedName;
}
+5 -1
View File
@@ -217,8 +217,12 @@ class FontInfo {
return shadow(this, "fallbackName", this.#readString(0));
}
get generatedFontName() {
return shadow(this, "generatedFontName", this.#readString(1));
}
get loadedName() {
return shadow(this, "loadedName", this.#readString(1));
return shadow(this, "loadedName", this.#readString(2));
}
#getBufferOffset(index) {
+1 -1
View File
@@ -37,7 +37,7 @@ class FONT_INFO {
"vertical",
];
static strings = ["fallbackName", "loadedName"];
static strings = ["fallbackName", "generatedFontName", "loadedName"];
static OFFSET_BBOX = Math.ceil((this.bools.length * 2) / 8);
+10 -8
View File
@@ -34,17 +34,19 @@ const ROOT_URL = new URL("../../", import.meta.url);
const CMAP_URL = new URL("external/bcmaps/", ROOT_URL).pathname;
const ICC_URL = new URL("external/iccs/", ROOT_URL).pathname;
const STANDARD_FONT_DATA_URL = new URL("external/standard_fonts/", ROOT_URL)
.pathname;
const STANDARD_FONT_DATA_URL = new URL("external/hellbox/", ROOT_URL).pathname;
const WASM_URL = new URL("wasm/", ROOT_URL).pathname;
const WASM_PATHS = new Map(
["jbig2/jbig2.wasm", "openjpeg/openjpeg.wasm", "qcms/qcms_bg.wasm"].map(
path => [
`${WASM_URL}${path.split("/")[1]}`,
new URL(`external/${path}`, ROOT_URL).pathname,
]
)
[
"hellbox/hellbox_bg.wasm",
"jbig2/jbig2.wasm",
"openjpeg/openjpeg.wasm",
"qcms/qcms_bg.wasm",
].map(path => [
`${WASM_URL}${path.split("/")[1]}`,
new URL(`external/${path}`, ROOT_URL).pathname,
])
);
function readFile(relativePath) {
+1 -1
View File
@@ -119,7 +119,7 @@ async function captureFonts(filename, filter, options) {
"extractWidths",
() => processPdf(filename, options),
(evaluator, [, , properties]) =>
properties.file && !properties.isInternalFont && filter(properties)
properties.file && filter(properties)
? new FontInput(properties, evaluator.options)
: undefined
);
-1
View File
@@ -136,7 +136,6 @@ describe("annotation", function () {
idFactory: createIdFactory(/* pageIndex = */ 0),
fontCache: new RefMap(),
builtInCMapCache,
standardFontDataCache: new Map(),
systemFontCache: new Map(),
});
});
+342 -4
View File
@@ -35,10 +35,13 @@ import {
import {
buildGetDocumentParams,
CMAP_URL,
DefaultBinaryDataFactory,
DefaultFileReaderFactory,
getCrossOriginHostname,
STANDARD_FONT_DATA_URL,
TEST_PDFS_PATH,
TestPdfsServer,
WASM_URL,
} from "./test_utils.js";
import {
getDocument,
@@ -54,6 +57,7 @@ import { Lexer, Parser } from "../../src/core/parser.js";
import { AutoPrintRegExp } from "../../web/ui_utils.js";
import { CipherTransformFactory } from "../../src/core/crypto.js";
import { fetchData as fetchDataDOM } from "../../src/display/dom_utils.js";
import { FontRendererFactory } from "../../src/core/font_renderer.js";
import { GlobalImageCache } from "../../src/core/image_utils.js";
import { GlobalWorkerOptions } from "../../src/display/worker_options.js";
import { MessageHandler } from "../../src/shared/message_handler.js";
@@ -5060,10 +5064,8 @@ page 1 / 3`);
});
expect(styles[fontName]).toEqual({
fontFamily: "serif",
// `useSystemFonts` has a different value in web environments
// and in Node.js.
ascent: isNodeJS ? NaN : 0.683,
descent: isNodeJS ? NaN : -0.217,
ascent: 0.683,
descent: -0.217,
vertical: false,
});
@@ -8141,6 +8143,342 @@ have written that much by now. So, here’s to squashing bugs.`);
});
});
describe("Generated fonts", function () {
const loadingTasks = new Set();
let worker = null;
afterEach(async function () {
await Promise.all(Array.from(loadingTasks, task => task.destroy()));
loadingTasks.clear();
worker?.destroy();
worker = null;
});
function loadDocument(params) {
const loadingTask = getDocument({
standardFontDataUrl: STANDARD_FONT_DATA_URL,
wasmUrl: WASM_URL,
useSystemFonts: false,
fontExtraProperties: true,
...params,
});
loadingTasks.add(loadingTask);
return loadingTask;
}
function buildFontPdf(fonts, content = "BT /F1 60 Tf 10 50 Td (A) Tj ET") {
return assemblePdf([
"1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n",
"2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n",
"3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 200] " +
"/Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>\n" +
"endobj\n",
`4 0 obj\n<< /Length ${content.length} >>\nstream\n${content}\n` +
"endstream\nendobj\n",
...fonts.map((font, i) => `${i + 5} 0 obj\n${font}\nendobj\n`),
]);
}
async function getFonts(pdfPage, { fnArray, argsArray }) {
const ids = new Set(
argsArray.filter((_, i) => fnArray[i] === OPS.setFont).map(([id]) => id)
);
return new Map(
await Promise.all(
Array.from(
ids,
id =>
new Promise(resolve => {
pdfPage.commonObjs.get(id, font => resolve([id, font]));
})
)
)
);
}
async function getGeneratedFonts(pdfPage, opList) {
const fonts = await getFonts(pdfPage, opList);
return fonts
.values()
.filter(font => font?.generatedFontName)
.toArray();
}
function readFontTables(data) {
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
const tables = new Map();
for (let i = 0, ii = view.getUint16(4); i < ii; i++) {
const tag = String.fromCharCode(
...data.subarray(12 + 16 * i, 16 + 16 * i)
);
tables.set(tag, view.getUint32(20 + 16 * i));
}
return { view, tables };
}
function getGeneratedAdvance(data, codePoint) {
const { view, tables } = readFontTables(data);
const { cmap } = FontRendererFactory.create({ data });
const range = cmap.find(
({ start, end }) => codePoint >= start && codePoint <= end
);
const glyphId =
((range.ids?.[codePoint - range.start] ?? codePoint) + range.idDelta) &
0xffff;
const numberOfHMetrics = view.getUint16(tables.get("hhea") + 34);
const index = Math.min(glyphId, numberOfHMetrics - 1);
const advance = view.getUint16(tables.get("hmtx") + 4 * index);
return (advance * 1000) / view.getUint16(tables.get("head") + 18);
}
it("draws the char code fallbacks of a generated standard font (issue 11915)", async function () {
const loadingTask = loadDocument(
buildGetDocumentParams("issue11915.pdf")
);
const pdfPage = await (await loadingTask.promise).getPage(1);
const { fnArray, argsArray } = await pdfPage.getOperatorList();
const fonts = await getFonts(pdfPage, { fnArray, argsArray });
const texts = new Map();
let font = null;
for (let i = 0, ii = fnArray.length; i < ii; i++) {
if (fnArray[i] === OPS.setFont) {
font = fonts.get(argsArray[i][0]);
} else if (fnArray[i] === OPS.showText && font.generatedFontName) {
expect(font.missingFile).toBeFalse();
expect(font.remeasure).toBeFalse();
const glyphs = argsArray[i][0].filter(g => g?.unicode);
expect(glyphs.every(g => g.isInFont))
.withContext(font.generatedFontName)
.toBeTrue();
texts.set(
font.generatedFontName,
glyphs.map(g => g.unicode).join("")
);
}
}
expect([...texts.values()]).toEqual(
jasmine.arrayContaining([
"Arial",
"Courier New",
"Times New Roman",
"Calibri",
"Arial Italic",
])
);
});
it("synthesizes the weight of a non-embedded black font", async function () {
const loadingTask = loadDocument({
data: buildFontPdf(
[
"<< /Type /Font /Subtype /TrueType /BaseFont /ArialBlack /Encoding /WinAnsiEncoding >>",
],
"BT /F1 24 Tf 20 100 Td (lHI) Tj ET"
),
});
const pdfPage = await (await loadingTask.promise).getPage(1);
const [font] = await getGeneratedFonts(
pdfPage,
await pdfPage.getOperatorList()
);
const { view, tables } = readFontTables(font.data);
expect(view.getUint16(tables.get("OS/2") + 4)).toEqual(900);
});
const buildWidthsPdf = () =>
buildFontPdf([
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica " +
"/FirstChar 64 /LastChar 65 /Widths [100 500] /Encoding << /Differences [64 /A] >> >>",
]);
it("generates a glyph for each width of a character", async function () {
const loadingTask = loadDocument({
data: buildWidthsPdf(),
});
const pdfPage = await (await loadingTask.promise).getPage(1);
const { fnArray, argsArray } = await pdfPage.getOperatorList();
const [glyph] = argsArray[fnArray.indexOf(OPS.showText)][0];
expect(glyph.unicode).toEqual("A");
expect(glyph.width).toEqual(500);
expect(glyph.isInFont).toBeTrue();
const [font] = await getGeneratedFonts(pdfPage, { fnArray, argsArray });
expect(
getGeneratedAdvance(font.data, glyph.fontChar.codePointAt(0))
).toBeCloseTo(glyph.width, 0);
});
it("generates the natural width of a character with several widths, after the system fonts", async function () {
const loadingTask = loadDocument({
data: buildWidthsPdf(),
useSystemFonts: true,
disableFontFace: false,
});
const pdfPage = await (await loadingTask.promise).getPage(1);
const [font] = await getGeneratedFonts(
pdfPage,
await pdfPage.getOperatorList()
);
expect(font.missingFile).toBeTrue();
expect(font.systemFontInfo.css).toContain(
`,"${font.generatedFontName}",sans-serif`
);
expect(getGeneratedAdvance(font.data, 0x41)).toBeCloseTo(667, 0);
});
it("generates a glyph for each width of the fallbacks of an Identity font", async function () {
const loadingTask = loadDocument({
data: buildFontPdf(
[
"<< /Type /Font /Subtype /Type0 /BaseFont /Arial /Encoding /Identity-H /DescendantFonts [6 0 R] >>",
"<< /Type /Font /Subtype /CIDFontType2 /BaseFont /Arial " +
"/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) " +
"/Supplement 0 >> /DW 1000 /W [200 [600]] >>",
],
"BT /F1 60 Tf 10 50 Td <00C800C1> Tj ET"
),
});
const pdfPage = await (await loadingTask.promise).getPage(1);
const { fnArray, argsArray } = await pdfPage.getOperatorList();
const [glyph200, glyph193] = argsArray[fnArray.indexOf(OPS.showText)][0];
expect([glyph200.width, glyph193.width]).toEqual([600, 1000]);
// The font's char code keeps U+00C1, the encoding fallback doesn't.
expect(glyph200.fontChar).toEqual("Á");
expect(glyph193.fontChar).not.toEqual(glyph200.fontChar);
expect(glyph193.isInFont).toBeTrue();
const [font] = await getGeneratedFonts(pdfPage, { fnArray, argsArray });
for (const glyph of [glyph200, glyph193]) {
expect(
getGeneratedAdvance(font.data, glyph.fontChar.codePointAt(0))
).toBeCloseTo(glyph.width, 0);
}
});
it("generates the fonts with the resources of their document", async function () {
if (isNodeJS) {
pending("Fake workers share the Hellbox state of earlier documents.");
}
worker = new PDFWorker({ name: "GeneratedFonts" });
const loadingTask1 = loadDocument(
buildGetDocumentParams("tracemonkey.pdf", {
worker,
useWorkerFetch: false,
standardFontDataUrl: null,
wasmUrl: null,
})
);
await loadingTask1.promise;
const loadingTask2 = loadDocument(
buildGetDocumentParams("issue11915.pdf", {
worker,
useWorkerFetch: false,
})
);
const pdfPage = await (await loadingTask2.promise).getPage(1);
const fonts = await getGeneratedFonts(
pdfPage,
await pdfPage.getOperatorList()
);
expect(fonts.length).toEqual(5);
});
it("generates the fonts despite the failures of other documents", async function () {
if (isNodeJS) {
pending("Fake workers share the Hellbox state of earlier documents.");
}
worker = new PDFWorker({ name: "GeneratedFontsFailures" });
const tasks = [
{ wasmUrl: "./nonexistent/" },
{ standardFontDataUrl: "./nonexistent/" },
{},
].map(urls =>
loadDocument(
buildGetDocumentParams("issue11915.pdf", {
worker,
useWorkerFetch: false,
...urls,
})
)
);
const pdfPages = await Promise.all(
tasks.map(async task => (await task.promise).getPage(1))
);
const opLists = await Promise.all(
pdfPages.map(pdfPage => pdfPage.getOperatorList())
);
const fonts = await getGeneratedFonts(pdfPages[2], opLists[2]);
expect(fonts.length).toEqual(5);
});
it("generates the fonts despite the pending fetches of a closed document", async function () {
if (isNodeJS) {
pending("Fake workers share the Hellbox state of earlier documents.");
}
class PendingFactory extends DefaultBinaryDataFactory {
async fetch({ kind, filename }) {
if (kind !== "standardFontDataUrl") {
return super.fetch({ kind, filename });
}
if (filename === "unicode.bin") {
return new Promise(() => {});
}
throw new Error(`Cannot fetch ${filename}.`);
}
}
worker = new PDFWorker({ name: "GeneratedFontsPending" });
const params = { worker, useWorkerFetch: false };
const closedTask = loadDocument(
buildGetDocumentParams("issue11915.pdf", {
...params,
BinaryDataFactory: PendingFactory,
})
);
const closedPage = await (await closedTask.promise).getPage(1);
await closedPage.getOperatorList();
await closedTask.destroy();
loadingTasks.delete(closedTask);
const loadingTask = loadDocument(
buildGetDocumentParams("issue11915.pdf", params)
);
const pdfPage = await (await loadingTask.promise).getPage(1);
const fonts = await getGeneratedFonts(
pdfPage,
await pdfPage.getOperatorList()
);
expect(fonts.length).toEqual(5);
});
it("generates the fonts with the resources of a custom factory", async function () {
class ResourceFactory extends DefaultBinaryDataFactory {
constructor() {
super({
standardFontDataUrl: STANDARD_FONT_DATA_URL,
wasmUrl: WASM_URL,
});
}
}
const loadingTask = loadDocument(
buildGetDocumentParams("issue11915.pdf", {
BinaryDataFactory: ResourceFactory,
standardFontDataUrl: null,
wasmUrl: null,
useWorkerFetch: false,
})
);
const pdfPage = await (await loadingTask.promise).getPage(1);
const fonts = await getGeneratedFonts(
pdfPage,
await pdfPage.getOperatorList()
);
expect(fonts.length).toEqual(5);
});
});
describe("Annotations", function () {
it("should extract the text under some annotations", async function () {
const loadingTask = getDocument(buildGetDocumentParams("bug1885505.pdf"));
+110 -16
View File
@@ -13,19 +13,87 @@
* limitations under the License.
*/
import { FontFaceObject } from "../../src/display/font_loader.js";
import { FontFaceObject, FontLoader } from "../../src/display/font_loader.js";
import { isNodeJS } from "../../src/shared/util.js";
describe("font_loader", function () {
let nativeFontFace;
beforeEach(function () {
nativeFontFace = globalThis.FontFace;
});
afterEach(function () {
globalThis.FontFace = nativeFontFace;
});
function createFont(properties) {
return new FontFaceObject({
data: new Uint8Array([0x00]),
disableFontFace: false,
fontExtraProperties: false,
loadedName: "g_d0_f1",
...properties,
});
}
it("loads generated fonts through CSS without the Font Loading API", async function () {
const loader = new FontLoader({ ownerDocument: {} });
spyOnProperty(loader, "isSyncFontLoadingSupported", "get").and.returnValue(
true
);
const insertRule = spyOn(loader, "insertRule");
for (const [loadedName, missingFile] of [
["g_d0_f1_generated", false],
["g_d0_f1", true],
]) {
const font = createFont({
generatedFontName: "g_d0_f1_generated",
loadedName,
missingFile,
});
await loader.bind(font);
await loader.bind(font);
expect(insertRule).toHaveBeenCalledOnceWith(
jasmine.stringContaining('font-family:"g_d0_f1_generated";')
);
insertRule.calls.reset();
}
});
it("falls back to paths only when a replacement font fails to load", async function () {
globalThis.FontFace = class {
constructor(family) {
this.family = family;
this.loaded = Promise.reject(new Error("Invalid font"));
}
};
for (const missingFile of [false, true]) {
const ownerDocument = { fonts: new Set() };
const loader = new FontLoader({ ownerDocument });
const font = createFont({
generatedFontName: "g_d0_f1_generated",
missingFile,
});
if (missingFile) {
await expectAsync(loader.bind(font)).toBeResolved();
} else {
await expectAsync(loader.bind(font)).toBeRejectedWithError(
"Invalid font"
);
}
expect(font.disableFontFace).toBe(!missingFile);
expect(ownerDocument.fonts.size).toEqual(0);
loader.clear();
}
});
describe("FontFaceObject", function () {
function createFontFaceObject(fontFamily) {
return new FontFaceObject({
return createFont({
cssFontInfo: { fontFamily, fontWeight: "400", italicAngle: "0" },
data: new Uint8Array([0x00]),
disableFontFace: false,
fontExtraProperties: false,
loadedName: "g_d0_f1",
mimetype: "font/opentype",
});
}
@@ -95,20 +163,46 @@ describe("font_loader", function () {
});
it("uses the same font family in both font loading paths", function () {
const NativeFontFace = globalThis.FontFace;
globalThis.FontFace = function MockFontFace(family) {
this.family = family;
};
try {
for (const fontFamily of [`"Foo Bar"`, "Foo-Bar", "serif"]) {
const font = createFontFaceObject(fontFamily);
for (const fontFamily of [`"Foo Bar"`, "Foo-Bar", "serif"]) {
const font = createFontFaceObject(fontFamily);
expect(font.createNativeFontFace().family).toEqual(
getFontFamily(font.createFontFaceRule())
);
expect(font.createNativeFontFace().family).toEqual(
getFontFamily(font.createFontFaceRule())
);
}
});
it("matches the generated font family and canvas style in both loading paths", function () {
globalThis.FontFace = class {
constructor(family, data, descriptors) {
Object.assign(this, { family, descriptors });
}
};
for (const italic of [false, true]) {
for (const [bold, black, weight] of [
[false, false, "normal"],
[true, false, "bold"],
[true, true, "900"],
]) {
const font = createFont({
generatedFontName: "g_d0_f1_generated",
italic,
bold,
black,
});
const face = font.createNativeFontFace();
const style = italic ? "italic" : "normal";
expect(face.family).toEqual("g_d0_f1_generated");
expect(face.descriptors).toEqual({ style, weight });
const rule = font.createFontFaceRule();
expect(rule).toContain('font-family:"g_d0_f1_generated";');
expect(rule).toContain(`font-style: ${style};`);
expect(rule).toContain(`font-weight: ${weight};`);
}
} finally {
globalThis.FontFace = NativeFontFace;
}
});
+8 -31
View File
@@ -18,14 +18,12 @@ import { getFontSubstitution } from "../../src/core/font_substitutions.js";
describe("getFontSubstitution", function () {
const idFactory = createIdFactory(0);
const localFontPath = "/tmp/";
it("should substitute an unknown font", () => {
const fontName = "Foo";
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -49,7 +47,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -73,7 +70,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -97,7 +93,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -121,7 +116,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -145,7 +139,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Helvetica",
"TrueType"
@@ -161,8 +154,7 @@ describe("getFontSubstitution", function () {
"local(A030),local(TeX Gyre Heros),local(FreeSans)," +
"local(DejaVu Sans),local(Albany),local(Bitstream Vera Sans)," +
"local(Arial Unicode MS),local(Microsoft Sans Serif)," +
"local(Apple Symbols),local(Cantarell)," +
"url(/tmp/LiberationSans-Regular.ttf)",
"local(Apple Symbols),local(Cantarell)",
style: {
style: "normal",
weight: "normal",
@@ -177,7 +169,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Helvetica-Oblique",
"TrueType"
@@ -196,7 +187,7 @@ describe("getFontSubstitution", function () {
"local(DejaVu Sans Italic),local(Albany Italic)," +
"local(Bitstream Vera Sans Italic),local(Arial Unicode MS Italic)," +
"local(Microsoft Sans Serif Italic),local(Apple Symbols Italic)," +
"local(Cantarell Italic),url(/tmp/LiberationSans-Italic.ttf)",
"local(Cantarell Italic)",
style: {
style: "italic",
weight: "normal",
@@ -211,7 +202,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Helvetica-Bold",
"TrueType"
@@ -229,7 +219,7 @@ describe("getFontSubstitution", function () {
"local(DejaVu Sans Bold),local(Albany Bold)," +
"local(Bitstream Vera Sans Bold),local(Arial Unicode MS Bold)," +
"local(Microsoft Sans Serif Bold),local(Apple Symbols Bold)," +
"local(Cantarell Bold),url(/tmp/LiberationSans-Bold.ttf)",
"local(Cantarell Bold)",
style: {
style: "normal",
weight: "bold",
@@ -244,7 +234,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Helvetica-BoldOblique",
"TrueType"
@@ -264,8 +253,7 @@ describe("getFontSubstitution", function () {
"local(Bitstream Vera Sans Bold Italic)," +
"local(Arial Unicode MS Bold Italic)," +
"local(Microsoft Sans Serif Bold Italic)," +
"local(Apple Symbols Bold Italic),local(Cantarell Bold Italic)," +
"url(/tmp/LiberationSans-BoldItalic.ttf)",
"local(Apple Symbols Bold Italic),local(Cantarell Bold Italic)",
style: {
style: "italic",
weight: "bold",
@@ -280,7 +268,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Times-Roman",
"TrueType"
@@ -311,7 +298,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Times-Italic",
"TrueType"
@@ -344,7 +330,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Times-Bold",
"TrueType"
@@ -377,7 +362,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
"Times-BoldItalic",
"TrueType"
@@ -410,7 +394,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -427,7 +410,7 @@ describe("getFontSubstitution", function () {
"local(FreeSans),local(DejaVu Sans),local(Albany)," +
"local(Bitstream Vera Sans),local(Arial Unicode MS)," +
"local(Microsoft Sans Serif),local(Apple Symbols)," +
"local(Cantarell),url(/tmp/LiberationSans-Regular.ttf)",
"local(Cantarell)",
style: {
style: "normal",
weight: "normal",
@@ -444,7 +427,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -463,7 +445,7 @@ describe("getFontSubstitution", function () {
"local(DejaVu Sans Bold),local(Albany Bold)," +
"local(Bitstream Vera Sans Bold),local(Arial Unicode MS Bold)," +
"local(Microsoft Sans Serif Bold),local(Apple Symbols Bold)," +
"local(Cantarell Bold),url(/tmp/LiberationSans-Bold.ttf)",
"local(Cantarell Bold)",
style: {
style: "normal",
weight: "bold",
@@ -480,7 +462,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -499,7 +480,7 @@ describe("getFontSubstitution", function () {
"local(DejaVu Sans Bold),local(Albany Bold)," +
"local(Bitstream Vera Sans Bold),local(Arial Unicode MS Bold)," +
"local(Microsoft Sans Serif Bold),local(Apple Symbols Bold)," +
"local(Cantarell Bold),url(/tmp/LiberationSans-Bold.ttf)",
"local(Cantarell Bold)",
style: {
style: "normal",
weight: "900",
@@ -516,7 +497,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"TrueType"
@@ -535,7 +515,7 @@ describe("getFontSubstitution", function () {
"local(DejaVu Sans Bold),local(Albany Bold)," +
"local(Bitstream Vera Sans Bold),local(Arial Unicode MS Bold)," +
"local(Microsoft Sans Serif Bold),local(Apple Symbols Bold)," +
"local(Cantarell Bold),url(/tmp/LiberationSans-Bold.ttf)",
"local(Cantarell Bold)",
style: {
style: "normal",
weight: "900",
@@ -552,7 +532,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"CIDFontType2"
@@ -583,7 +562,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"CIDFontType0"
@@ -614,7 +592,6 @@ describe("getFontSubstitution", function () {
const fontSubstitution = getFontSubstitution(
new Map(),
idFactory,
localFontPath,
fontName,
undefined,
"CIDFontType2"
+4 -2
View File
@@ -67,6 +67,7 @@ describe("obj_bin_transform", function () {
bbox: [1, 1, 1, 1],
fontMatrix: [1, 1, 1, 1, 1, 1],
fallbackName: "string",
generatedFontName: "string",
loadedName: "string",
data: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
uselessProp: "something",
@@ -120,9 +121,9 @@ describe("obj_bin_transform", function () {
describe("FontInfo", function () {
it("must roundtrip correctly for FontInfo", function () {
let sizeEstimate = 41; // fixed offset until the strings
let sizeEstimate = 61; // fixed offset until the strings
const { encoder } = InfoUtils;
sizeEstimate += 4 + 4 * (4 + encoder.encode("string").length);
sizeEstimate += 4 + 3 * (4 + encoder.encode("string").length);
sizeEstimate += 4 + 4; // cssFontInfo and systemFontInfo
sizeEstimate += 4 + fontInfo.data.length;
const buffer = compileFontInfo(fontInfo);
@@ -141,6 +142,7 @@ describe("obj_bin_transform", function () {
expect(deserialized.bbox).toEqual([1, 1, 1, 1]);
expect(deserialized.fontMatrix).toEqual([1, 1, 1, 1, 1, 1]);
expect(deserialized.fallbackName).toEqual("string");
expect(deserialized.generatedFontName).toEqual("string");
expect(deserialized.loadedName).toEqual("string");
expect(Array.from(deserialized.data)).toEqual([
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+2 -2
View File
@@ -29,8 +29,8 @@ const TEST_PDFS_PATH = isNodeJS ? "./test/pdfs/" : "../pdfs/";
const CMAP_URL = isNodeJS ? "./external/bcmaps/" : "../../external/bcmaps/";
const STANDARD_FONT_DATA_URL = isNodeJS
? "./external/standard_fonts/"
: "../../external/standard_fonts/";
? "./external/hellbox/"
: "../../external/hellbox/";
const WASM_URL = isNodeJS
? "./build/generic-legacy/web/wasm/"
+2
View File
@@ -36,6 +36,8 @@ describe("unicode", function () {
it("should re-map special Unicode values", function () {
// copyrightsans => copyright
expect(mapSpecialUnicodeValues(0xf8e9)).toEqual(0x00a9);
// braceex => curly bracket extension
expect(mapSpecialUnicodeValues(0xf8f4)).toEqual(0x23aa);
// Private Use Area characters
expect(mapSpecialUnicodeValues(0xffff)).toEqual(0);
});
+1 -1
View File
@@ -887,7 +887,7 @@ const defaultOptions = new Map([
value:
// eslint-disable-next-line no-nested-ternary
typeof PDFJSDev === "undefined"
? "../external/standard_fonts/"
? "../external/hellbox/"
: PDFJSDev.test("MOZCENTRAL")
? "resource://pdf.js/web/standard_fonts/"
: "../web/standard_fonts/",
+1 -1
View File
@@ -107,7 +107,7 @@ async function openDocument(source, name) {
typeof PDFJSDev === "undefined" ? "../external/iccs/" : "../web/iccs/",
standardFontDataUrl:
typeof PDFJSDev === "undefined"
? "../external/standard_fonts/"
? "../external/hellbox/"
: "../web/standard_fonts/",
wasmUrl: "../web/wasm/",
useWorkerFetch: true,