Commit Graph

277 Commits

Author SHA1 Message Date
Jonas Jenwald
7ddb0bc718 Attempt to combine text runs positioned with setTextMatrix 2016-05-18 17:21:58 +02:00
Jonas Jenwald
e281ef15db Adjust incorrect first obj number of "free" xref entry in XRef_readXRefTable (issue 7229)
Fixes 7229.
2016-04-21 16:36:32 +02:00
Jonas Jenwald
079b563e2d Ensure that the params parameter of the PredictorStream is a dictionary (issue 7200)
Fixes 7200.
2016-04-15 16:30:18 +02:00
Yury Delendik
d76db416f4 Adds more SMask tests. 2016-04-11 08:02:06 -05:00
Yury Delendik
ff3ce973b8 Merge pull request #7106 from Snuffleupagus/issue-7101
Keep track of the character to glyph mapping in font_renderer.js, to prevent errors when different characters point to the same glyph (issue 7101)
2016-04-01 08:09:21 -05:00
Jonas Jenwald
05cf709f8e Parse Type1 font files to determine the various Length{n} properties, instead of trusting the PDF file (issue 5686, issue 3928)
Fixes 5686.
Fixes 3928.
2016-03-31 11:08:12 +02:00
Jonas Jenwald
17aaa125df Keep track of the character to glyph mapping in font_renderer.js, to prevent errors when different characters point to the same glyph (issue 7101)
Fixes 7101.
2016-03-30 11:33:04 +02:00
Jonas Jenwald
ac772017b6 Add unit-tests for destionations in /Names (NameTree) dictionaries where all entries are indirect objects
Re: issue 6204 and PR 6208.
2016-03-29 17:55:05 +02:00
Jonas Jenwald
13d7a5070e Prevent failures in the Annotation code if the Rect array contains indirect objects (issue 7115)
Note that in the PDF files provided by the reporter, this issue was limited to `Rect` arrays in AcroForm entries (which we currently don't support).
However, since a bad PDF generator could create this problem in *any* kind of annotation, the reduced test-case included here uses a simple LinkAnnotation instead.

Fixes 7115.
2016-03-26 20:55:16 +01:00
Jonas Jenwald
dfe9015a43 Convert uniXXXX glyph names to proper ones when building the charCodeToGlyphId map for TrueType fonts (bug 1132849, issue 6893, issue 6894)
This patch adds a `getUnicodeForGlyph` helper function, which is used to recover Unicode values for non-standard glyph names.

Some PDF generators, e.g. Scribus PDF, use improper `uniXXXX` glyph names which breaks the glyph mapping. We can avoid this by converting them to "standard" glyph names instead.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1132849.
Fixes 6893.
Fixes 6894.
2016-03-09 19:37:15 +01:00
Preetham Mysore
be1e12dbcb Fix for descent calculation while reading font hhea headers 2016-03-03 08:51:41 -05:00
Jonas Jenwald
8402c79171 Merge pull request #7050 from brendandahl/issue4402
For CIDFontType2 use CID as glyph ID when missing CID to GID map.
2016-03-02 10:11:42 +01:00
Brendan Dahl
a6acf74b54 Merge pull request #7023 from brendandahl/issue6721
Only draw glyphs on canvas if they are in the font or the font file is missing.
2016-03-01 18:03:37 -08:00
Brendan Dahl
6e1d131384 For CIDFontType2 use CID as glyph ID when missing CID to GID map. 2016-03-01 17:05:33 -08:00
Brendan Dahl
ff87f3fb86 Only draw glyphs on canvas if they are in the font or the font file is missing. 2016-03-01 13:24:58 -08:00
Jonas Jenwald
505f15f221 Avoid accidentally getting the entire font file in readNameTable (issue 7020)
In the PDF file in question, some of the 'name' table entries have `record.length === 0`. This becomes problematic in the non-unicode case, since `font.getBytes(0)` will fetch the *entire* stream.
Given that OTS rejects 'name' entries larger than `2^16`, this thus explain the sanitizer errors.

Fixes 7020.
2016-03-01 21:59:49 +01:00
Tim van der Meij
ad31e52a26 Group popup creation code and apply it to more annotation types 2016-02-25 00:35:45 +01:00
Tim van der Meij
10902fd882 Implement unit and reference testing for FileAttachment annotations 2016-02-23 22:49:53 +01:00
Jonas Jenwald
07e1ad40a2 Replace getAll with getKeys in PartialEvaluator_hasBlendModes to speed up loading of badly generated PDF files (issue 6961)
Some bad PDF generators, in particular "Scribus PDF", duplicates resources *a lot* at various levels of the PDF files. This can lead to `PartialEvaluator_hasBlendModes` taking an unreasonable amount of time to complete.
The reason is that the current code is using `Dict_getAll`, which recursively dereferences *all* indirect objects, which can be really slow. This patch instead uses `Dict_getKeys`, and then manually looks up only the necessary indirect objects.

I've added the PDF file as a `load` test. The most important thing here is probably to ensure that the file remains available in the repo, and the comment should help reduced the chance of regressions. (Note that locally, the `load` test times out without this patch, but we cannot really assume that that always happens.)

Fixes 6961.
2016-02-10 17:21:38 +01:00
Tim van der Meij
58329f7f92 Merge pull request #6803 from Snuffleupagus/page-labels
[api-minor] Add support for PageLabels in the API
2016-01-20 22:05:48 +01:00
Yury Delendik
0aa373cdf3 Merge pull request #6891 from Snuffleupagus/issue-6889
Map missing glyphs to the `notdef` glyph for TrueType (3, 1) fonts regardless if the 'post' table is defined or not (issue 6889)
2016-01-20 13:14:47 -06:00
Jonas Jenwald
85cf90643f [api-minor] Add support for PageLabels in the API 2016-01-19 22:49:04 +01:00
Tim van der Meij
1eea0db897 Merge pull request #6822 from Snuffleupagus/urls-in-outline
[api-minor] Add support for URLs in the document outline
2016-01-19 22:21:40 +01:00
Jonas Jenwald
0030a82dc3 [api-minor] Add support for URLs in the document outline
Re: issue 5089.
(Note that since there are other outline features that we currently don't support, e.g. bold/italic text and custom colours, I thus think we can keep the referenced issue open.)
2016-01-19 21:36:27 +01:00
Tim van der Meij
ec066101d8 Merge pull request #6848 from Snuffleupagus/recover-missing-glyf-table
[TrueType] Recover from a missing "glyf" table by replacing it with dummy data, utilizing the existing code in `sanitizeGlyphLocations`
2016-01-18 20:28:52 +01:00
Jonas Jenwald
4855d4cc9f Map missing glyphs to the notdef glyph for TrueType (3, 1) fonts regardless if the 'post' table is defined or not (issue 6889) 2016-01-17 22:58:00 +01:00
Jonas Jenwald
b4020047bc Replace the linked test-case for issue 1155 with a reduced one
As part of the link cleanup in issue 6854, obtaining this file through the Internet Archive didn't work.
However, given that the file was added in order to test an issue with `CropBox/MediaBox`, a reduced test-case should do just fine instead.

Please refer to issue 1155, and PR 1212.
2016-01-16 16:00:37 +01:00
Jonas Jenwald
d52495a9c8 [TrueType] Recover from a missing "glyf" table by replacing it with dummy data, utilizing the existing code in sanitizeGlyphLocations
It seems to be fairly common for OCR software to include incomplete TrueType fonts, notable missing the "glyf" table, in PDF files. Since we currently reject such fonts, the result is that text-selection/copying is broken.

This patch contains a suggested approach to try and use these kind of broken fonts, by using existing code in `sanitizeGlyphLocations` to replace a missing "glyf" table with dummy data.

Fixes 4684.
Fixes 6007.
Fixes 6829.
2016-01-15 21:44:59 +01:00
Brendan Dahl
3057b69e45 Merge pull request #6839 from Snuffleupagus/issue-6782
Check that CIDFontType0 fonts does not actually contain OpenType font files (issue 6782)
2016-01-11 08:56:48 -08:00
Tim van der Meij
30b8f41003 Merge pull request #6820 from Snuffleupagus/showText-shadingPattern
Apply Patterns, if necessary, when rendering text
2016-01-08 14:02:56 +01:00
Daan Sprenkels
90ec2c9294 shading-pattern: Decreased Shadings.SMALL_NUMBER
and added a test case for #6298
2016-01-06 15:26:40 +01:00
Jonas Jenwald
896e390285 Check that CIDFontType0 fonts does not actually contain OpenType font files (issue 6782)
*This patch follows a similar idea as PR 5756.*

The patch is based on the nice debugging done by Brendan in the referenced issue 6782.
A better way to handle this, and similar issues, would probably be to completely ignore what the PDF file claims about font type/subtype, and just check the actual data. But until that kind of rewrite happens, this patch should help.

Fixes 6782.
2016-01-06 02:19:02 +01:00
Brendan Dahl
eb7c36beb6 Add validation for callsubr and callgsubr for type 2 charstrings. 2016-01-05 09:54:25 -08:00
Tim van der Meij
6ef7120a04 Implement support for Highlight annotations 2016-01-01 15:31:46 +01:00
Tim van der Meij
34918a6666 Implement support for Squiggly annotations 2015-12-30 19:37:04 +01:00
Jonas Jenwald
1d1f175826 Apply Patterns, if necessary, when rendering text
Currently we're not applying Patterns for text, but only for graphics.

This patch is unfortunately not a complete solution, but rather a step on the way, since there are still some PDF files where the Patterns look more like a solid colour, rather than the intended gradient.
I've been unable to fix these issues completely, and I've not managed to determine if the remaining issues are caused either by the pattern code, the canvas code, or perhaps both.

However, given that even this simple patch improves the current situation quite a bit, I figured that it couldn't hurt to submit it as-is.

 - Fixes 5804.
 - Fixes 6130.
 - Improves 3988 a lot, since the text is now visible. However, it looks like the text is *one* solid colour, instead of the correct gradient.
 - Improves 5432, since the text is no longer gray. (This file also suffers from the same problem as the previous one.)
2015-12-29 20:02:40 +01:00
Tim van der Meij
c5f4b9750e Implement support for StrikeOut annotations 2015-12-29 15:09:28 +01:00
Jonas Jenwald
b32cdf5836 Merge pull request #6813 from timvandermeij/underline-annotation
Implement support for Underline annotations
2015-12-28 23:48:31 +01:00
Jonas Jenwald
2f2ea6160b Ensure that the baseTransform is applied when rendering annotations
Fixes 3350.
Fixes 5946.
Fixes 6334.
Fixes 6722.
Probably fixes 3826 (since the PDF files are no longer available, I cannot confirm it).
2015-12-28 16:02:38 +01:00
Tim van der Meij
cd28dd34fe Implement support for Underline annotations 2015-12-28 00:33:41 +01:00
Tim van der Meij
7d43971f54 Implement support for Popup annotations
Most code for Popup annotations is already present for Text annotations.
This patch extracts the popup creation logic from the Text annotation
code so it can be reused for Popup annotations.

Not only does this add support for Popup annotations, the Text
annotation code is also considerably easier. If a `Popup` entry is
available for a Text annotation, it will not be more than an image. The
popup will be handled by the Popup annotation. However, it is also
possible for Text annotations to not have a separate Popup annotation,
in which case the Text annotation handles the popup creation itself.
2015-12-25 13:17:21 +01:00
Tim van der Meij
f93a220736 Merge pull request #6684 from dsprenkels/issue-6296-radial-shading-size
shading-pattern: While drawing patterns, use transform to baseTransform first
2015-12-14 20:39:08 +01:00
Jonas Jenwald
ee0d522187 Use adjustWidths for TrueType fonts if we handle them as OpenType (issue 5027, issue 5084, issue 6556, bug 1204903)
In `Font_checkAndRepair` we can decide that a font isn't TrueType, and instead parse it as CFF. In that case it's quite possible that the `fontMatrix` will be changed, and without calling `adjustWidths` we're failing to update the glyph widths correctly.

Fixes 5027.
Fixes 5084.
Fixes 6556.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1204903.
2015-12-08 00:49:22 +01:00
Jonas Jenwald
084bb8682f Merge pull request #6723 from yurydelendik/smask-transfer
Adds transfer function support for SMask.
2015-12-05 22:41:56 +01:00
Jonas Jenwald
4810b7b8fc Fix the charCodeOf method in IdentityToUnicodeMap in order to prevent text selection from breaking
After PR 6590, `font.spaceWidth` is now called in more cases than before (in `PartialEvaluator_getTextContent`), which exposed an underlying issue with `IdentityToUnicodeMap_charCodeOf` throwing an error.
This breaks text-selection in some PDF files found in the wild, hence this patch replaces the `error` with an actual function instead (modelled after `IdentityCMap_charCodeOf`).
2015-12-05 13:15:55 +01:00
Yury Delendik
15c9969abe Adds transfer function support for SMask. 2015-12-04 12:52:45 -06:00
Brendan Dahl
87762afec4 Remove glyph id's outside the range of valid glyphs.
OTS does not like invalid glyph ids in a camp table.
2015-12-03 11:53:06 -08:00
Daan Sprenkels
a9081653fc shading-pattern: While drawing patterns, transform to the baseTransform first 2015-12-02 21:49:38 +01:00
Jonas Jenwald
6dfe53b976 [api-minor] Add a parameter to PDFPageProxy_getTextContent that enables replacing of all whitespace with standard spaces in the textLayer (issue 6612)
This patch goes a bit further than issue 6612 requires, and replaces all kinds of whitespace with standard spaces.

When testing this locally, it actually seemed to slightly improve two existing test-cases (`tracemonkey-text` and `taro-text`).

Fixes 6612.
2015-11-25 17:28:40 +01:00
Jonas Jenwald
055573fc83 Replace the unavailable linked test-case for issue 1055 with a reduced test-case
Re: issue 1055 and PR 1095.
2015-11-18 13:48:44 +01:00