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

a fix for FontDescriptor.m #4

Open
ldenoue opened this issue Oct 21, 2011 · 4 comments
Open

a fix for FontDescriptor.m #4

ldenoue opened this issue Oct 21, 2011 · 4 comments

Comments

@ldenoue
Copy link

ldenoue commented Oct 21, 2011

In FontDescriptor.m, - (id)initWithPDFDictionary:(CGPDFDictionaryRef)dict, CGPDFDictionaryGetName(dict, "Type", &type) sometimes returns a nil in type.

Testing as follows goes around the problem:
if (type == nil)
{
[self release]; return nil;
}

Laurent.

@KurtCode
Copy link
Owner

I guess that is possible (well, obviously it is if you observed it).

But the next line compares the type to "FontDescriptor" which is the expected type of dictionary. If the type comes out nil, shouldn't the comparison return a non-equal (non-zero) result, like 1 (since any string at all is greater than nothing)?

If this is so, then the object is released and nil returned.

const char *type = nil;
CGPDFDictionaryGetName(dict, "Type", &type);
if (strcmp(type, "FontDescriptor") != 0)
{
    [self release]; return nil;
}

@ldenoue
Copy link
Author

ldenoue commented Oct 21, 2011

Looks like strcmp doesn't like nil strings.
Laurent

Sent from my iPhone

On Oct 21, 2011, at 6:12 PM, KurtCode
[email protected]
wrote:

I guess that is possible (well, obviously it is if you observed it).

But the next line compares the type to "FontDescriptor" which is the expected type of dictionary. If the type comes out nil, shouldn't the comparison return a non-equal (non-zero) result, like 1 (since any string at all is greater than nothing)?

If this is so, then the object is released and nil returned.

const char *type = nil;
CGPDFDictionaryGetName(dict, "Type", &type);
if (strcmp(type, "FontDescriptor") != 0)
{
   [self release]; return nil;
}

Reply to this email directly or view it on GitHub:
#4 (comment)

@KurtCode
Copy link
Owner

That's interesting, I didn't know that. Thanks!

It appears strcmp behavior is undefined for nil arguments.

@ldenoue
Copy link
Author

ldenoue commented Mar 19, 2013

Hi!
I noticed I can't get text out of this pdf with pdfkitten.
The operator table callbacks are not called.
Do you have any idea why? By the way the sample code from FastPDFKit
doesn't get text either, but Mozilla js pdf and others are fine with it.

http://www.55fun.com/book.pdf

Laurent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants