Skip to content

Conversation

@edoardocavazza
Copy link
Contributor

It seems that bold and italic properties are set only for system fonts. With this PR, we are going to use values from font descriptor to add the properties to all translated fonts.

@edoardocavazza edoardocavazza changed the title Set bold and italic flag translated font Set bold and italic properties to translated font Oct 2, 2025
Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the use case for this change a bit more? Is it just for consistency with system fonts, or are these values going to be used somewhere in a future patch?

this.fontMatrix = properties.fontMatrix;
this.bbox = properties.bbox;
this.defaultEncoding = properties.defaultEncoding;
if (typeof properties.fontWeight === "number") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test to make sure that this behavior can't regress in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rebased the branch and added a regression test, if interested

@edoardocavazza
Copy link
Contributor Author

Hi @timvandermeij,

here’s a bit of context for this PR and the others we’ve been submitting recently.
Our team is working on a modified version of the text layer in pdf.js that uses semantic HTML tags instead of spans.
Besides improving screen reader support, this approach would also make it possible to create “Reflow” views of PDFs, similar to what Acrobat offers.
I’d also like to add that, if we eventually come up with an optimal solution, we’d be happy to propose our changes to the main project.

At this stage, we’re not yet suggesting any major changes to the pdf.js code — only those that we believe are general improvements for the project.

So for now, this PR only includes consistency-related changes, as you’ve already noticed.
In our prototype, this would mean being able to use a strong or em tag (or both) to better represent bold and italic text in the PDF.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants