|
13 | 13 | * limitations under the License. |
14 | 14 | */ |
15 | 15 |
|
| 16 | +import { FeatureTest } from "pdfjs-lib"; |
| 17 | + |
16 | 18 | const CharacterType = { |
17 | 19 | SPACE: 0, |
18 | 20 | ALPHA_LETTER: 1, |
@@ -114,8 +116,13 @@ function getCharacterType(charCode) { |
114 | 116 |
|
115 | 117 | let NormalizeWithNFKC; |
116 | 118 | function getNormalizeWithNFKC() { |
117 | | - /* eslint-disable no-irregular-whitespace */ |
118 | | - NormalizeWithNFKC ||= ` ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`; |
| 119 | + if ( |
| 120 | + (typeof PDFJSDev === "undefined" && FeatureTest.platform.isFirefox) || |
| 121 | + (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) |
| 122 | + ) { |
| 123 | + /* eslint-disable no-irregular-whitespace */ |
| 124 | + NormalizeWithNFKC ||= `\xA0¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩`; |
| 125 | + } |
119 | 126 |
|
120 | 127 | if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { |
121 | 128 | const ranges = []; |
@@ -145,7 +152,24 @@ function getNormalizeWithNFKC() { |
145 | 152 | } |
146 | 153 | } |
147 | 154 | } |
148 | | - if (ranges.join("") !== NormalizeWithNFKC) { |
| 155 | + |
| 156 | + const rangesStr = ranges.join(""); |
| 157 | + if (!NormalizeWithNFKC) { |
| 158 | + NormalizeWithNFKC = rangesStr; |
| 159 | + } else if (rangesStr !== NormalizeWithNFKC) { |
| 160 | + for (let i = 1; i < rangesStr.length; i++) { |
| 161 | + if (rangesStr[i] !== NormalizeWithNFKC[i]) { |
| 162 | + console.log( |
| 163 | + `Difference at index ${i}: ` + |
| 164 | + `U+${rangesStr.charCodeAt(i).toString(16).toUpperCase().padStart(4, "0")}` + |
| 165 | + `!== U+${NormalizeWithNFKC.charCodeAt(i) |
| 166 | + .toString(16) |
| 167 | + .toUpperCase() |
| 168 | + .padStart(4, "0")}` |
| 169 | + ); |
| 170 | + break; |
| 171 | + } |
| 172 | + } |
149 | 173 | throw new Error( |
150 | 174 | "getNormalizeWithNFKC - update the `NormalizeWithNFKC` string." |
151 | 175 | ); |
|
0 commit comments