Avoid to have the text layer mismatching the rendered text with mismatching locales (bug 1869001)

The system locale (used in OffscreenCanvas) can be different from the one guessed by Fluent,
consequently, in order to avoid any mismatch, we just use an attached canvas element.
The original issue can easily be reproduced locally in adding a lang="ja" in viewer.html
(or with an other language for Japanese users).
This commit is contained in:
Calixte Denizet 2024-01-04 15:53:36 +01:00
parent 7873ad98bb
commit f84f48b5d0
7 changed files with 42 additions and 46 deletions

View file

@ -63,6 +63,7 @@ import {
NodeStandardFontDataFactory,
} from "display-node_utils";
import { CanvasGraphics } from "./canvas.js";
import { cleanupTextLayer } from "./text_layer.js";
import { GlobalWorkerOptions } from "./worker_options.js";
import { MessageHandler } from "../shared/message_handler.js";
import { Metadata } from "./metadata.js";
@ -2481,6 +2482,7 @@ class WorkerTransport {
this.fontLoader.clear();
this.#methodPromises.clear();
this.filterFactory.destroy();
cleanupTextLayer();
this._networkStream?.cancelAllRequests(
new AbortException("Worker was terminated.")
@ -3065,6 +3067,7 @@ class WorkerTransport {
}
this.#methodPromises.clear();
this.filterFactory.destroy(/* keepHCM = */ true);
cleanupTextLayer();
}
get loadingParams() {