Aditya kumar singh 1fce8caa05 fixes #20265
## 📝 Summary

This PR fixes **noisy Type3 font warnings** when parsing PDFs.
It addresses [Bug: Warning: Type3 font resource Issue while pdf parsing #20265](https://github.com/mozilla/pdf.js/issues/20265).

---

## 🔧 Changes

- Adds a global flag in `web/app.js`:
  ```js
  globalThis.SILENCE_TYPE3_WARNINGS = true;
Updates the .catch block in loadType3Data to respect the flag:

js
Copy code
.catch(function (reason) {
  if (!globalThis.SILENCE_TYPE3_WARNINGS) {
    warn(`Type3 font resource "${key}" is not available.`);
  }
  const dummyOperatorList = new OperatorList();
  charProcOperatorList[key] = dummyOperatorList.getIR();
});
 Why this fix works
Yes 👍 — the changes you showed will fix the noisy Type3 warnings.

Here’s why:

You set the flag globally in web/app.js before the viewer initializes:

js
Copy code
globalThis.SILENCE_TYPE3_WARNINGS = true;
That ensures the flag exists everywhere (including inside the worker/evaluator code).

You patched the .catch in loadType3Data to respect the flag:

js
Copy code
.catch(function (reason) {
  if (!globalThis.SILENCE_TYPE3_WARNINGS) {
    warn(`Type3 font resource "${key}" is not available.`);
  }
  const dummyOperatorList = new OperatorList();
  charProcOperatorList[key] = dummyOperatorList.getIR();
});
➡️ With this combo, warnings will be silenced by default in the build.
If you ever want them back, just open the browser console and run:

js
Copy code
globalThis.SILENCE_TYPE3_WARNINGS = false;
🔍 Verification
To verify:

Open a PDF with a missing Type3 font (that normally logs many warnings).

Confirm no warnings are shown in the console.

Toggle logging back on at runtime:

js
Copy code
globalThis.SILENCE_TYPE3_WARNINGS = false;
and reload the PDF. Warnings should now appear.

📌 Notes
Resolves issue: #20265

Keeps console clean during normal usage.

Advanced users/devs can still toggle warnings for debugging.

No behavior changes to rendering logic — only logging is affected.
2025-09-15 16:28:24 +05:30
..
2025-09-15 16:28:24 +05:30
2025-07-07 09:59:36 +09:00