Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fonts): make name/object null #8

Merged
merged 2 commits into from
Jul 13, 2018
Merged

feat(fonts): make name/object null #8

merged 2 commits into from
Jul 13, 2018

Conversation

itsachen
Copy link
Contributor

@itsachen itsachen commented Jul 13, 2018

What

  • Improve handling of undefined font names/invalid object IDs

Why

In preparation for PDF font validation, we should improve how we handle PDFs with undefined font names and invalid objects. These are corner cases but setting them as null is better for now than using empty strings or invalid objects.

src/pdffonts.cc Outdated
fontObj->Set(Nan::New("object").ToLocalChecked(), objectObj);
// Logic taken from pdffonts.cc
// See: https://cgit.freedesktop.org/poppler/poppler/tree/utils/pdffonts.cc?id=eb1291f86260124071e12226294631ce685eaad6#n207
if (fontRef.gen >= 100000) {

Choose a reason for hiding this comment

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

What does fontRef.gen represent?

Nit: While the link helps, I think it'd be clearer with a comment that describes what this block is doing instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its the PDF object generation number. I'll include this link for context: http://www.printmyfolders.com/understanding-pdf

src/pdffonts.cc Outdated
if (fontRef.gen >= 100000) {
fontObj->Set(Nan::New("object").ToLocalChecked(), Nan::Null());
} else {
v8::Local<v8::Object> objectObj = Nan::New<v8::Object>();

Choose a reason for hiding this comment

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

What does this object represent? Would it be clearer if we gave it a less specific name than just 'object'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It represents metadata associated with the PDF object that is the font. object seems to be used commonly, the original utility references the metadata using the term as well.

Choose a reason for hiding this comment

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

Could metadataObj be an alternative then? I'm coming into this late and have zero context so I trust your judgement.

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 think object might be more clearly understood than reference or metadata, even though thats how I've come to understand it. It kind of represents the PDF object, in a way, though it does require context to understand.

@marklee22 marklee22 requested a review from a team July 13, 2018 16:44
@itsachen itsachen merged commit 1912e6f into master Jul 13, 2018
@itsachen itsachen deleted the make-null branch July 13, 2018 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants