diff --git a/src/core/document.js b/src/core/document.js index 9262a0cba..5b8fc6565 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -968,7 +968,12 @@ class PDFDocument { return pdfFonts[pdfFonts.length - 1]; }, set font(font) { - pdfFonts.push(font); + if (font && !font.missingFile) { + // If font file is missing we must use a + // font substitution or a fallback, so the + // font is not pushed in pdfFonts. + pdfFonts.push(font); + } }, clone() { return this; diff --git a/src/core/timesnewroman_factors.js b/src/core/timesnewroman_factors.js new file mode 100644 index 000000000..d2afeb47f --- /dev/null +++ b/src/core/timesnewroman_factors.js @@ -0,0 +1,265 @@ +/* Copyright 2021 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. + */ + +// Factors to rescale LiberationSans-Bold.ttf to have the same +// metrics as timesbd.ttf. +const TimesNewRomanBoldFactors = [ + 2.12968, 1, 1, 1, 1, 1.17096, 0.89903, 0.89903, 1.12466, 1.15348, 1.16838, 1, + 1, 1.28482, 0.97575, 0.89982, 1, 0.89982, 1, 0.89903, 0.89903, 0.89903, + 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 1, 1, 0.97575, + 0.97575, 0.97575, 0.81855, 0.95393, 1, 0.9236, 1, 1, 1, 1, 1, 1.07708, 1.4007, + 0.89903, 1.07708, 1.09193, 1.13306, 1, 1, 0.91581, 1, 1, 0.83382, 1.09193, 1, + 1.08272, 1.05949, 1.08272, 1.08272, 1.09193, 1, 1, 1, 0.99498, 0.89903, 1, + 0.89903, 0.91047, 0.79807, 0.91047, 0.79807, 1, 0.81855, 0.91047, 1, 1.19859, + 1, 1, 0.93685, 0.91047, 0.81855, 0.91047, 0.91047, 1.14053, 0.69974, 1, + 0.91047, 0.89903, 0.92844, 0.89903, 0.89903, 0.8877, 1.01255, 0.78709, + 1.01255, 0.89047, 1, 0.89903, 0.89903, 0.89903, 0.89903, 0.78709, 0.89903, 1, + 1.01392, 0.81003, 0.89903, 0.97575, 1.01392, 0.90539, 1, 1, 0.90029, 0.90029, + 1, 1, 0.97103, 0.89982, 1, 0.90029, 0.90374, 0.89903, 0.8993, 0.8993, 0.8993, + 0.81855, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.4007, 1.4007, 1.4007, 1.4007, + 1, 1, 1, 1, 1, 1, 1, 0.97575, 1, 1, 1, 1, 1, 1.08272, 0.91581, 0.91047, + 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.81219, 0.79807, + 0.79807, 0.79807, 0.79807, 0.79807, 1, 1, 1, 1, 0.81855, 0.91047, 0.81855, + 0.81855, 0.81855, 0.81855, 0.81855, 1, 0.81855, 0.91047, 0.91047, 0.91047, + 0.91047, 0.89903, 0.91047, 0.89903, 1, 0.89903, 1, 0.89903, 1, 0.89903, 1, + 0.79807, 1, 0.79807, 1, 0.79807, 1, 0.79807, 1, 1.02038, 1, 0.91047, 1, + 0.79807, 1, 0.79807, 1, 0.79807, 1, 0.79807, 1, 0.79807, 1, 0.81855, 1, + 0.81855, 1, 0.81855, 1, 1, 1.07708, 0.91047, 1.07708, 0.91047, 1.4007, 1, + 1.4007, 1, 1.4007, 1, 1.4007, 1, 1.4007, 1, 1.04854, 0.99298, 0.89903, + 1.19859, 1, 1, 1, 1.09193, 1, 1, 1, 1.09193, 1.21673, 1.09193, 0.82569, + 1.09193, 1, 1, 0.91047, 1, 1, 1, 0.91047, 1.02895, 1.06347, 0.91047, 1, + 0.81855, 1, 0.81855, 1, 0.81855, 1, 0.76513, 1, 1.14053, 1, 1, 1, 1.14053, + 0.83382, 0.69974, 0.83382, 0.69974, 0.83382, 0.69974, 0.83382, 0.69974, 1, 1, + 1.09193, 1.08767, 1.09193, 1, 1, 0.91047, 1, 0.91047, 1, 0.91047, 1, 0.91047, + 1, 0.91047, 1, 0.91047, 1.05949, 0.92844, 1.08272, 0.89903, 1.08272, 1.09193, + 0.8877, 1.09193, 0.8877, 1.09193, 0.8877, 1, 0.89903, 1, 0.89903, 1, 0.81219, + 1, 0.81855, 1, 1, 1.09193, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.71639, 1, 1, + 0.93646, 1.00377, 1.10206, 0.94316, 0.9326, 0.95571, 1.11599, 1, 0.9236, + 1.05849, 0.85122, 1, 1.09193, 1.07708, 1, 1.4007, 1.07708, 1.07467, 1.13306, + 1, 1.05235, 1, 1.07708, 0.91581, 1.0895, 1.09193, 1.08272, 1.01011, 1.08272, + 0.96379, 0.95798, 1.4007, 1.08272, 0.90786, 0.94697, 0.92966, 1.11599, + 0.89178, 0.90786, 0.8632, 0.84109, 0.85588, 0.90021, 0.89714, 0.92966, + 0.96567, 1.11599, 0.99562, 0.88323, 0.94174, 0.80334, 1.0011, 0.81855, + 0.71556, 0.86504, 0.81127, 0.79515, 1.03282, 0.89178, 0.87235, 0.80237, + 0.91316, 0.86532, 1.11599, 0.89178, 0.81855, 0.89178, 0.86532, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1.07708, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0.79807, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.93725, 1, 1, 1, 1, 1, 1, + 1.05949, 0.92844, 1.05949, 0.92844, 1.05949, 0.92844, 1.08272, 0.89903, 1, 1, + 0.89903, 1, 1, 0.90539, 1.19859, 1.19859, 1.19859, 1.19859, 1, 1, 1, 0.89903, + 0.89903, 1, 1, 1, 1.17312, 1.15291, 1, 1, 1, 1, 1, 0.87793, 0.89903, 0.89903, + 0.88571, 0.89903, 1, 1, 1, 1, 1, 1, 0.8993, 0.8993, 0.8993, 0.8993, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0.97575, 1, 1, 1, 0.99527, 1, 1, 1, 0.97657, 1, 1, + 0.99353, 0.97575, 1, 1, 1, 1.13359, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0.91047, 0.91047, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, +]; +const TimesNewRomanBoldMetrics = { lineHeight: 1.1499, lineGap: 0.04248 }; + +// Factors to rescale LiberationSans-BoldItalic.ttf to have the same +// metrics as timesbi.ttf. +const TimesNewRomanBoldItalicFactors = [ + 2.12968, 1, 1, 1, 1.16862, 1.17096, 0.89903, 0.89903, 0.93685, 1.07708, + 1.16838, 1, 1, 1.28482, 0.97575, 0.89982, 1, 0.89982, 1, 0.89903, 0.89903, + 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 1, 1, + 0.97575, 0.97575, 0.97575, 0.81855, 0.85328, 0.9236, 0.9236, 0.9236, 1, 1, + 1.09193, 0.92844, 1.07708, 1.4007, 0.89903, 0.9236, 1, 1.06741, 1, 0.92844, + 0.91581, 0.92844, 0.9236, 0.83382, 1, 1, 1, 0.94206, 1, 0.91581, 1, 1, 1, 1, + 0.97575, 0.89903, 1, 0.89903, 0.81855, 0.79807, 0.81855, 0.79807, 1, 0.81855, + 0.91047, 1, 1, 0.89903, 1, 0.87479, 0.91047, 0.81855, 0.81855, 0.81855, 1, + 0.69974, 0.83431, 0.91047, 0.79807, 0.8575, 0.89903, 0.79807, 0.77832, 0.8946, + 0.78709, 0.8946, 0.97575, 1.16862, 0.89903, 0.89903, 0.89903, 0.89903, + 0.78709, 0.89903, 1, 1.01392, 0.719, 0.89903, 1.03763, 1.01392, 0.90539, 1, 1, + 0.90029, 0.90029, 1, 1, 0.89903, 1, 1, 0.90029, 0.82086, 0.89903, 0.8993, + 0.8993, 0.8993, 0.81855, 0.9236, 0.9236, 0.9236, 0.9236, 0.9236, 0.9236, + 0.94385, 0.9236, 1, 1, 1, 1, 1.4007, 1.4007, 1.4007, 1.4007, 1, 1, 0.92844, + 0.92844, 0.92844, 0.92844, 0.92844, 0.97575, 0.92844, 1, 1, 1, 1, 0.91581, + 0.91581, 0.81855, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, + 0.81219, 0.79807, 0.79807, 0.79807, 0.79807, 0.79807, 1, 1, 1, 1, 0.81855, + 0.91047, 0.81855, 0.81855, 0.81855, 0.81855, 0.81855, 1, 0.81855, 0.91047, + 0.91047, 0.91047, 0.91047, 0.79807, 0.81855, 0.79807, 0.9236, 0.89903, 0.9236, + 0.89903, 0.9236, 0.89903, 0.9236, 0.79807, 0.9236, 0.79807, 0.9236, 0.79807, + 0.9236, 0.79807, 1, 1.01188, 1, 0.81855, 1, 0.79807, 1, 0.79807, 1, 0.79807, + 1, 0.79807, 1, 0.79807, 0.92844, 0.81855, 0.92844, 0.81855, 0.92844, 0.81855, + 1, 1, 1.07708, 0.91047, 1.07708, 0.91047, 1.4007, 1, 1.4007, 1, 1.4007, 1, + 1.4007, 1, 1.4007, 1, 1.05181, 0.99298, 0.89903, 1, 1, 1, 0.89903, 1, 1, 1, 1, + 1, 1.31566, 1, 0.78287, 1, 1, 1, 0.91047, 1, 1, 1, 0.91047, 1.01447, 1.08373, + 0.88489, 0.92844, 0.81855, 0.92844, 0.81855, 0.92844, 0.81855, 0.94385, + 0.76513, 0.9236, 1, 1, 1, 0.9236, 1, 0.83382, 0.69974, 0.83382, 0.69974, + 0.83382, 0.69974, 0.83382, 0.69974, 1, 1, 1, 1.10907, 1, 0.83431, 1, 0.91047, + 1, 0.91047, 1, 0.91047, 1, 0.91047, 1, 0.91047, 1, 0.91047, 0.94206, 0.8575, + 0.91581, 0.79807, 0.91581, 1, 0.77832, 1, 0.77832, 1, 0.77832, 1.19859, + 0.89903, 0.9236, 0.89903, 0.94385, 0.81219, 0.92844, 0.81855, 1, 1, 1, + 0.83431, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9236, 1, 0.90966, 0.98814, + 1.06914, 0.86582, 0.8063, 0.9268, 1, 0.9236, 0.9236, 0.99039, 0.91127, 1, 1, + 1.07708, 0.98117, 1.4007, 0.9236, 1, 1.06741, 1, 1.00297, 0.92844, 1.08367, + 0.91581, 1.0488, 1, 0.91581, 0.95962, 1, 0.96523, 0.98374, 1.4007, 0.91581, + 0.89213, 0.85714, 0.89848, 1, 0.82824, 0.89213, 0.82533, 0.74802, 0.8392, + 0.85714, 0.89672, 0.89848, 0.93082, 1, 0.93615, 0.79807, 0.95547, 0.79807, + 0.99891, 0.81855, 0.7668, 0.85081, 0.83761, 0.81236, 1.08602, 0.82824, + 0.83137, 0.80473, 0.86418, 0.86659, 1, 0.82824, 0.81855, 0.82824, 0.86659, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.08147, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0.79807, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89826, 1, 1, 1, 1, 1, + 1, 0.94206, 0.8575, 0.94206, 0.8575, 0.94206, 0.8575, 0.91581, 0.79807, 1, 1, + 0.89903, 1, 1, 0.90539, 1.19859, 1.19859, 1.19859, 1.19859, 1, 1, 1, 0.89903, + 0.89903, 1, 1, 1, 1.17312, 1.15291, 1, 1, 1.09135, 1, 1, 0.87793, 0.89903, + 0.89903, 0.87749, 0.89903, 1, 1, 1, 1, 1, 1, 0.8993, 0.8993, 0.8993, 0.8993, + 1.00098, 1, 1, 1, 1.00049, 1, 1, 1, 1, 1, 1, 1.03763, 1, 1, 1, 0.99527, 1, 1, + 1, 0.97657, 1, 1, 0.99353, 0.97575, 1, 1, 1, 0.98516, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.91047, 0.91047, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +]; +const TimesNewRomanBoldItalicMetrics = { lineHeight: 1.1499, lineGap: 0.04248 }; + +// Factors to rescale LiberationSans-Italic.ttf to have the same +// metrics as timesi.ttf. +const TimesNewRomanItalicFactors = [ + 2.12968, 1, 1, 1, 1.19859, 1.18294, 0.89903, 0.89903, 0.93685, 1.16618, + 1.1202, 1, 1, 1.28482, 1.15552, 0.89982, 1, 0.89982, 1, 0.89903, 0.89903, + 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, + 1.19859, 1, 1.15552, 1.15552, 1.15552, 0.89903, 0.9062, 0.91581, 0.91581, + 0.9236, 1, 0.91581, 1, 0.92844, 1, 1.19859, 0.8877, 1, 1, 1, 0.9236, 0.92844, + 0.91581, 0.92844, 0.84584, 0.74963, 0.91047, 1, 0.91581, 0.88257, 0.91581, + 0.83382, 0.91047, 1.4007, 1, 1.4007, 0.89906, 0.89903, 1, 0.89903, 0.89903, + 0.8877, 0.89903, 0.79807, 1, 0.89903, 0.89903, 1.25055, 1.25055, 0.8877, + 1.25055, 0.86694, 0.89903, 0.89903, 0.89903, 0.89903, 1.16862, 0.77832, 1, + 0.89903, 0.8877, 0.9236, 0.8877, 0.8877, 0.77832, 1.19737, 1.05827, 1.19737, + 0.92642, 1.16862, 0.89903, 0.89903, 0.89903, 0.89903, 1.05827, 0.89903, 1, + 1.03115, 0.74538, 0.89903, 1.15552, 1.03115, 0.90539, 1, 1, 0.90029, 0.90029, + 1, 1, 0.97364, 1, 1, 0.90029, 0.84893, 0.89903, 0.8993, 0.8993, 0.8993, + 0.81855, 0.91581, 0.91581, 0.91581, 0.91581, 0.91581, 0.91581, 0.88916, + 0.9236, 0.91581, 0.91581, 0.91581, 0.91581, 1.19859, 1.19859, 1.19859, + 1.19859, 1, 0.9236, 0.92844, 0.92844, 0.92844, 0.92844, 0.92844, 1.15552, + 0.92844, 1, 1, 1, 1, 0.83382, 0.91581, 0.81855, 0.89903, 0.89903, 0.89903, + 0.89903, 0.89903, 0.89903, 0.75014, 0.8877, 0.79807, 0.79807, 0.79807, + 0.79807, 1, 1, 1, 1, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, + 0.89903, 1, 0.81855, 0.89903, 0.89903, 0.89903, 0.89903, 0.8877, 0.89903, + 0.8877, 0.91581, 0.89903, 0.91581, 0.89903, 0.91581, 0.89903, 0.9236, 0.8877, + 0.9236, 0.8877, 0.9236, 0.8877, 0.9236, 0.8877, 1, 0.97344, 1, 0.89903, + 0.91581, 0.79807, 0.91581, 0.79807, 0.91581, 0.79807, 0.91581, 0.79807, + 0.91581, 0.79807, 0.92844, 0.89903, 0.92844, 0.89903, 0.92844, 0.89903, 1, 1, + 1, 0.89903, 1, 0.89903, 1.19859, 1, 1.19859, 1, 1.19859, 1, 1.19859, 1.25055, + 1.19859, 1, 1.02264, 1.12761, 0.8877, 1.25055, 1, 1, 0.8877, 1, 1.25055, 1, 1, + 1, 1.2934, 1, 0.80708, 1, 1.25055, 0.9236, 0.89903, 1, 1, 0.9236, 0.89903, + 0.93884, 0.96286, 0.86655, 0.92844, 0.89903, 0.92844, 0.89903, 0.92844, + 0.89903, 0.94385, 0.70667, 0.84584, 1.16862, 1, 1, 0.84584, 1.16862, 0.74963, + 0.77832, 0.74963, 0.77832, 0.74963, 0.77832, 0.74963, 0.77832, 1, 1, 0.91047, + 1.02759, 0.91047, 1.00176, 1, 0.89903, 1, 0.89903, 1, 0.89903, 1, 0.89903, 1, + 0.89903, 1, 0.89903, 0.88257, 0.9236, 0.83382, 0.8877, 0.83382, 0.91047, + 0.77832, 0.91047, 0.77832, 0.91047, 0.77832, 1.25055, 0.89903, 0.91581, + 0.89903, 0.88916, 0.75014, 0.92844, 0.81855, 1, 1, 0.91047, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0.91581, 1.19859, 0.8613, 0.93595, 1.03392, 0.90959, + 0.76298, 0.93699, 1.25055, 0.91581, 0.91581, 0.99743, 0.91194, 0.91581, + 0.91047, 1, 0.92844, 1.19859, 1, 0.90556, 1, 0.9236, 0.98569, 0.92844, + 0.99663, 0.91581, 0.99104, 0.91047, 0.83382, 0.90957, 0.91581, 0.84656, + 1.00963, 1.19859, 0.83382, 0.92038, 0.89667, 0.89358, 1.25055, 0.83481, + 0.92038, 0.87179, 0.78809, 0.83656, 0.89667, 0.87355, 0.89358, 0.90549, + 1.25055, 0.95996, 0.87996, 1.05169, 0.8877, 0.95847, 0.89903, 0.74781, + 0.83802, 0.83434, 0.81781, 0.95692, 0.83481, 0.84805, 0.8059, 0.85369, + 0.90658, 1.25055, 0.83481, 0.89903, 0.83481, 0.89592, 0.91581, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1.00956, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0.79807, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.88428, 1, 1, 1, 1, 1, 1, + 0.88257, 0.9236, 0.88257, 0.9236, 0.88257, 0.9236, 0.83382, 0.8877, 1, 1, + 0.89903, 0.88916, 1, 0.90539, 1.4989, 1.4989, 1.4989, 1.4989, 1.67009, + 1.67009, 1.67009, 0.89903, 0.89903, 1, 0.88916, 1, 1.16667, 1.17655, 1, 1, + 1.14551, 1, 1, 0.86345, 0.89903, 0.89903, 0.90491, 0.89903, 1, 1, 1, 0.97998, + 1, 1, 0.8993, 0.8993, 0.8993, 0.8993, 1.00049, 1, 1.00245, 1, 1, 1, 1, 1, 1, + 1, 1, 1.15552, 1, 1, 1, 1.00476, 1, 1, 1, 1.15552, 1, 1, 0.99353, 1.15552, 1, + 1, 1, 0.98516, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +]; +const TimesNewRomanItalicMetrics = { lineHeight: 1.1499, lineGap: 0.04248 }; + +// Factors to rescale LiberationSans-Regular.ttf to have the same +// metrics as times.ttf. +const TimesNewRomanRegularFactors = [ + 2.12968, 1, 1, 1, 1.19859, 1.14993, 0.89903, 0.89903, 0.93685, 1.16618, + 0.94373, 1, 1, 1.28482, 0.96572, 0.89982, 1, 0.89982, 1, 0.89903, 0.89903, + 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 0.89903, 1, 1, + 0.96572, 0.96572, 0.96572, 0.79807, 0.90717, 1.08272, 1, 0.9236, 1, 0.91581, + 0.91047, 0.92844, 1, 1.19859, 0.77832, 1.08272, 1.09833, 1.06741, 1, 0.92844, + 0.83382, 0.92844, 0.9236, 0.83382, 1, 1, 1.08272, 1, 1.08272, 1.08272, 1, + 1.19859, 1, 1.19859, 1, 0.89903, 1, 0.79807, 0.89903, 0.8877, 0.89903, + 0.79807, 1.19859, 0.89903, 0.89903, 1.25055, 1.25055, 1, 1.25055, 0.93376, + 0.89903, 0.89903, 0.89903, 0.89903, 1, 0.77832, 1, 0.89903, 1, 1, 1, 1, + 0.8877, 1.43713, 0.77068, 1.43713, 0.92642, 1, 0.89903, 0.89903, 0.89903, + 0.89903, 0.77068, 0.89903, 1, 1.03115, 0.74538, 0.89903, 0.96572, 1.03115, + 0.90539, 1, 1, 0.90029, 0.90029, 1, 1, 0.84364, 0.89982, 1, 0.90029, 0.84893, + 0.89903, 0.8993, 0.8993, 0.8993, 0.72662, 1.08272, 1.08272, 1.08272, 1.08272, + 1.08272, 1.08272, 0.88916, 0.9236, 0.91581, 0.91581, 0.91581, 0.91581, + 1.19859, 1.19859, 1.19859, 1.19859, 1, 1, 0.92844, 0.92844, 0.92844, 0.92844, + 0.92844, 0.96572, 0.92844, 1, 1, 1, 1, 1.08272, 0.83382, 0.81855, 0.79807, + 0.79807, 0.79807, 0.79807, 0.79807, 0.79807, 0.75014, 0.8877, 0.79807, + 0.79807, 0.79807, 0.79807, 1, 1, 1, 1, 0.89903, 0.89903, 0.89903, 0.89903, + 0.89903, 0.89903, 0.89903, 1, 0.81855, 0.89903, 0.89903, 0.89903, 0.89903, 1, + 0.89903, 1, 1.08272, 0.79807, 1.08272, 0.79807, 1.08272, 0.79807, 0.9236, + 0.8877, 0.9236, 0.8877, 0.9236, 0.8877, 0.9236, 0.8877, 1, 1.05163, 1, + 0.89903, 0.91581, 0.79807, 0.91581, 0.79807, 0.91581, 0.79807, 0.91581, + 0.79807, 0.91581, 0.79807, 0.92844, 0.89903, 0.92844, 0.89903, 0.92844, + 0.89903, 1, 1, 1, 0.89903, 1, 0.89903, 1.19859, 1, 1.19859, 1, 1.19859, 1, + 1.19859, 1.25055, 1.19859, 1, 0.96412, 1.24422, 0.77832, 1.25055, 1, 1, 1, + 1.09833, 1.25055, 1, 1, 1.09833, 1.39363, 1.09833, 1.02924, 1.09833, 1.25055, + 1, 0.89903, 1, 1, 1, 0.89903, 1, 0.97029, 0.88938, 0.92844, 0.89903, 0.92844, + 0.89903, 0.92844, 0.89903, 0.88916, 0.76513, 0.9236, 1, 1, 1, 0.9236, 1, + 0.83382, 0.77832, 0.83382, 0.77832, 0.83382, 0.77832, 0.83382, 0.77832, 1, 1, + 1, 1.13932, 1, 1, 1, 0.89903, 1, 0.89903, 1, 0.89903, 1, 0.89903, 1, 0.89903, + 1, 0.89903, 1, 1, 1.08272, 1, 1.08272, 1, 0.8877, 1, 0.8877, 1, 0.8877, + 1.25055, 0.89903, 1.08272, 0.79807, 0.88916, 0.75014, 0.92844, 0.81855, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.08193, 1, 0.88481, 0.96445, 1.07125, + 0.93253, 0.95377, 0.98767, 1.21099, 1.08272, 1, 1.04965, 0.91594, 0.91581, 1, + 1, 0.92844, 1.19859, 1.08272, 1.08553, 1.06741, 1, 0.98948, 0.92844, 1, + 0.83382, 0.94155, 1, 1.08272, 0.91616, 1.08272, 0.88311, 1.02743, 1.19859, + 1.08272, 0.90625, 0.94195, 0.9403, 1.21099, 0.90536, 0.90625, 0.88455, + 0.88379, 0.84649, 0.94195, 0.93909, 0.9403, 0.86128, 1.21099, 1.00781, + 0.96973, 1, 0.9043, 0.99564, 0.89903, 0.73178, 0.87725, 0.82168, 0.87342, + 1.01731, 0.90536, 0.89006, 0.84558, 0.87808, 0.84303, 1.21099, 0.90536, + 0.89903, 0.90536, 0.84303, 0.91581, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.79807, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0.95804, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.08272, 1, 1, 1, 0.89903, + 1, 1, 0.90539, 1.4989, 1.4989, 1.4989, 1.4989, 1.33284, 1.33284, 1.33284, + 0.89903, 0.89903, 1, 1, 1, 1.16667, 1.17655, 1, 1, 1.14551, 1, 1, 0.86345, + 0.89903, 0.89903, 0.88571, 0.89903, 1, 1, 1, 0.97998, 1, 1, 0.8993, 0.8993, + 0.8993, 0.8993, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.96572, 1, 1, 1, 1.00476, 1, + 1, 1, 0.96653, 1, 1, 0.99353, 0.96572, 1, 1, 1, 1.13359, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.1123, 1.1123, 1, 1, 1, 0.90029, + 0.90029, 0.90029, 0.90029, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +]; +const TimesNewRomanRegularMetrics = { lineHeight: 1.1499, lineGap: 0.04248 }; + +export { + TimesNewRomanBoldFactors, + TimesNewRomanBoldItalicFactors, + TimesNewRomanBoldItalicMetrics, + TimesNewRomanBoldMetrics, + TimesNewRomanItalicFactors, + TimesNewRomanItalicMetrics, + TimesNewRomanRegularFactors, + TimesNewRomanRegularMetrics, +}; diff --git a/src/core/xfa_fonts.js b/src/core/xfa_fonts.js index 881a61baf..995f8cea5 100644 --- a/src/core/xfa_fonts.js +++ b/src/core/xfa_fonts.js @@ -64,17 +64,30 @@ import { SegoeuiRegularFactors, SegoeuiRegularMetrics, } from "./segoeui_factors.js"; +import { + TimesNewRomanBoldFactors, + TimesNewRomanBoldItalicFactors, + TimesNewRomanBoldItalicMetrics, + TimesNewRomanBoldMetrics, + TimesNewRomanItalicFactors, + TimesNewRomanItalicMetrics, + TimesNewRomanRegularFactors, + TimesNewRomanRegularMetrics, +} from "./timesnewroman_factors.js"; import { getLookupTableFactory } from "./core_utils.js"; import { normalizeFontName } from "./fonts_utils.js"; const getXFAFontMap = getLookupTableFactory(function (t) { - t["MyriadPro-Regular"] = t["PdfJS-Fallback-Regular"] = { - name: "LiberationSans-Regular", - factors: MyriadProRegularFactors, - baseWidths: LiberationSansRegularWidths, - baseMapping: LiberationSansRegularMapping, - metrics: MyriadProRegularMetrics, - }; + t["MyriadPro-Regular"] = + t.MyriadPro = + t["PdfJS-Fallback-Regular"] = + { + name: "LiberationSans-Regular", + factors: MyriadProRegularFactors, + baseWidths: LiberationSansRegularWidths, + baseMapping: LiberationSansRegularMapping, + metrics: MyriadProRegularMetrics, + }; t["MyriadPro-Bold"] = t["PdfJS-Fallback-Bold"] = { name: "LiberationSans-Bold", factors: MyriadProBoldFactors, @@ -125,7 +138,7 @@ const getXFAFontMap = getLookupTableFactory(function (t) { baseWidths: LiberationSansBoldItalicWidths, baseMapping: LiberationSansBoldItalicMapping, }; - t["Calibri-Regular"] = { + t["Calibri-Regular"] = t.Calibri = { name: "LiberationSans-Regular", factors: CalibriRegularFactors, baseWidths: LiberationSansRegularWidths, @@ -153,7 +166,7 @@ const getXFAFontMap = getLookupTableFactory(function (t) { baseMapping: LiberationSansBoldItalicMapping, metrics: CalibriBoldItalicMetrics, }; - t["Segoeui-Regular"] = { + t["Segoeui-Regular"] = t.Segoeui = { name: "LiberationSans-Regular", factors: SegoeuiRegularFactors, baseWidths: LiberationSansRegularWidths, @@ -181,6 +194,34 @@ const getXFAFontMap = getLookupTableFactory(function (t) { baseMapping: LiberationSansBoldItalicMapping, metrics: SegoeuiBoldItalicMetrics, }; + t["TimesNewRoman-Regular"] = t["TimesNewRomanPSMT-Regular"] = { + name: "LiberationSans-Regular", + factors: TimesNewRomanRegularFactors, + baseWidths: LiberationSansRegularWidths, + baseMapping: LiberationSansRegularMapping, + metrics: TimesNewRomanRegularMetrics, + }; + t["TimesNewRoman-Bold"] = t["TimesNewRomanPSMT-Bold"] = { + name: "LiberationSans-Bold", + factors: TimesNewRomanBoldFactors, + baseWidths: LiberationSansBoldWidths, + baseMapping: LiberationSansBoldMapping, + metrics: TimesNewRomanBoldMetrics, + }; + t["TimesNewRoman-Italic"] = t["TimesNewRomanPSMT-Italic"] = { + name: "LiberationSans-Italic", + factors: TimesNewRomanItalicFactors, + baseWidths: LiberationSansItalicWidths, + baseMapping: LiberationSansItalicMapping, + metrics: TimesNewRomanItalicMetrics, + }; + t["TimesNewRoman-BoldItalic"] = t["TimesNewRomanPSMT-BoldItalic"] = { + name: "LiberationSans-BoldItalic", + factors: TimesNewRomanBoldItalicFactors, + baseWidths: LiberationSansBoldItalicWidths, + baseMapping: LiberationSansBoldItalicMapping, + metrics: TimesNewRomanBoldItalicMetrics, + }; t["Helvetica-Regular"] = t.Helvetica = { name: "LiberationSans-Regular", factors: HelveticaRegularFactors,