DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.42k stars 633 forks source link

Test compoundMap[glyphIndex] before declaring as non-null #1735

Open REU8ER opened 2 months ago

REU8ER commented 2 months ago

Testing whether "compoundMap[glyphIndex]" is null before declaring it as non-null, this is causing an error when saving the document, preventing it from being generated.

from: bytes.setUint16(offset + 2, compoundMap[glyphIndex]!); offset += (flags & arg1And2AreWords != 0) ? 8 : 6;

to: final value = compoundMap[glyphIndex]; if (value != null) { bytes.setUint16(offset + 2, value); offset += (flags & arg1And2AreWords != 0) ? 8 : 6; }

Detalhe do problema:

1686

With this we can check whether it will be null or not, causing the document to be generated, even ignoring the character that could not be processed. By doing this, the character that generates the error is replaced by a blank space, from "≥" to " ", I know that would not be the best alternative, but with this the document is generated normally and does not return as null.

This is in the "ttf_writer.dart" file in the "font" folder.

I don't have much knowledge about GitHub or how to open a Push Request, but I would like to help and I hope I was able to do so.