Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ import {
lookupMatrix,
lookupNormalRect,
} from "./core_utils.js";
import { FontInfo, PatternInfo } from "../shared/obj-bin-transform.js";
import {
FontInfo,
FontPathInfo,
PatternInfo,
} from "../shared/obj-bin-transform.js";
import {
getEncoding,
MacRomanEncoding,
Expand Down Expand Up @@ -4663,11 +4667,8 @@ class PartialEvaluator {
if (font.renderer.hasBuiltPath(fontChar)) {
return;
}
handler.send("commonobj", [
glyphName,
"FontPath",
font.renderer.getPathJs(fontChar),
]);
const buffer = FontPathInfo.write(font.renderer.getPathJs(fontChar));
handler.send("commonobj", [glyphName, "FontPath", buffer], [buffer]);
} catch (reason) {
if (evaluatorOptions.ignoreErrors) {
warn(`buildFontPaths - ignoring ${glyphName} glyph: "${reason}".`);
Expand Down
8 changes: 7 additions & 1 deletion src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ import {
StatTimer,
} from "./display_utils.js";
import { FontFaceObject, FontLoader } from "./font_loader.js";
import { FontInfo, PatternInfo } from "../shared/obj-bin-transform.js";
import {
FontInfo,
FontPathInfo,
PatternInfo,
} from "../shared/obj-bin-transform.js";
import {
getDataProp,
getFactoryUrlProp,
Expand Down Expand Up @@ -2821,6 +2825,8 @@ class WorkerTransport {
}
break;
case "FontPath":
this.commonObjs.resolve(id, new FontPathInfo(exportedData));
break;
case "Image":
this.commonObjs.resolve(id, exportedData);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/display/font_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class FontFaceObject {
} catch (ex) {
warn(`getPathGenerator - ignoring character: "${ex}".`);
}
const path = makePathFromDrawOPS(cmds);
const path = makePathFromDrawOPS(cmds.path);

if (!this.fontExtraProperties) {
// Remove the raw path-string, since we don't need it anymore.
Expand Down
40 changes: 38 additions & 2 deletions src/shared/obj-bin-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { assert, MeshFigureType } from "./util.js";
import { assert, FeatureTest, MeshFigureType } from "./util.js";

class CssFontInfo {
#buffer;
Expand Down Expand Up @@ -881,4 +881,40 @@ class PatternInfo {
throw new Error(`Unsupported pattern kind: ${kind}`);
}
}
export { CssFontInfo, FontInfo, PatternInfo, SystemFontInfo };

class FontPathInfo {
static write(path) {
let data;
let buffer;
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
FeatureTest.isFloat16ArraySupported
) {
buffer = new ArrayBuffer(path.length * 2);
data = new Float16Array(buffer);
} else {
buffer = new ArrayBuffer(path.length * 4);
data = new Float32Array(buffer);
}
data.set(path);
return buffer;
}

#buffer;

constructor(buffer) {
this.#buffer = buffer;
}

get path() {
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
FeatureTest.isFloat16ArraySupported
) {
return new Float16Array(this.#buffer);
}
return new Float32Array(this.#buffer);
}
}

export { CssFontInfo, FontInfo, FontPathInfo, PatternInfo, SystemFontInfo };
Loading