Skip to content

Conversation

@ryzokuken
Copy link
Collaborator

Serialize FontPath commands into a binary format
and store it in an ArrayBuffer so that it can
eventually be stored in a SharedArrayBuffer.

This PR is along the same lines as #20197 and #20340

@ryzokuken ryzokuken requested a review from calixteman October 8, 2025 11:52
@ryzokuken ryzokuken self-assigned this Oct 8, 2025
@calixteman
Copy link
Contributor

For the glyph paths, we should use the same format as "described" here:

pdf.js/src/display/canvas.js

Lines 1491 to 1520 in d83cbb2

if (!(path instanceof Path2D)) {
// Using a SVG string is slightly slower than using the following loop.
const path2d = (data[0] = new Path2D());
for (let i = 0, ii = path.length; i < ii; ) {
switch (path[i++]) {
case DrawOPS.moveTo:
path2d.moveTo(path[i++], path[i++]);
break;
case DrawOPS.lineTo:
path2d.lineTo(path[i++], path[i++]);
break;
case DrawOPS.curveTo:
path2d.bezierCurveTo(
path[i++],
path[i++],
path[i++],
path[i++],
path[i++],
path[i++]
);
break;
case DrawOPS.closePath:
path2d.closePath();
break;
default:
warn(`Unrecognized drawing path operator: ${path[i - 1]}`);
break;
}
}
path = path2d;

Using a SVG string is slightly slower and using this binary data would help to make the serialization a bit simpler.

Serialize FontPath commands into a binary format
and store it in an ArrayBuffer so that it can
eventually be stored in a SharedArrayBuffer.
@ryzokuken
Copy link
Collaborator Author

Thanks for the comments, @calixteman @timvandermeij they should be addressed now PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants