Yury Delendik
a67198895f
Resets canvas 2d context to the default state.
2017-05-23 15:10:30 -05:00
chris.greening
cfc2f36f5c
Adds additional parameter so background color of canvas can be set
2017-05-17 17:06:44 +01:00
Jonas Jenwald
95bbc8101c
Replace unnecessary bind(this)
and var self = this
statements with arrow functions in src/core/evaluator.js
...
Note that by using `let` instead of `var` in `PartialEvaluator.setGState` and `TranslatedFont.loadType3Data`, we can get rid of further `bind` usages since `let` is block-scoped.
Also, the fact that `bind` wasn't used in the `Font` case inside of `setGState` is actually a bug which has been present ever since PR 5205, where a closure was replaced by a standard loop.[1]
---
[1] I'm not aware of any bugs caused by this, but that is probably more a happy accident than anything else, since e.g. just removing the `bind` from the `SMask` case without using block-scoped variables causes test failures.
2017-05-01 20:29:44 +02:00
Jonas Jenwald
07b5574006
Enable the object-shorthand
ESLint rule in src/display
...
Please see http://eslint.org/docs/rules/object-shorthand .
For the most part, these changes are of the search-and-replace kind, and the previously enabled `no-undef` rule should complement the tests in helping ensure that no stupid errors crept into to the patch.
2017-04-25 16:17:18 +02:00
Jonas Jenwald
52e3de3c0a
Convert the files in the /src/display
folder to ES6 modules
...
Also disables ES2015 transpilation in development mode.
2017-04-16 12:19:10 +02:00
Yury Delendik
30bee9fe0c
Moves Uint32ArrayView and hasCanvasTypedArrays into compatibility.js.
2017-04-14 10:04:52 -05:00
Brendan Dahl
4969b2ad97
Normalize blend mode names.
2017-04-10 16:18:08 -07:00
Mukul Mishra
41d092d04b
Fixes behaviour of DOMCanvasFactory to return {canvas, context}.
2017-02-07 03:47:13 +05:30
Yury Delendik
d842c9c6b0
Merge pull request #8002 from mukulmishra18/refactor-canvas
...
[api-minor] Fix #7798 : Refactor scratch canvas usage.
2017-02-06 07:45:41 -06:00
Mukul Mishra
32817633c9
Fix #7798 : Refactor scratch canvas usage.
...
Fixes extra canvas create calls.
Fixes unnecessary call of `new DOMCanvasFactory`.
Fixes undefined error of DOMCanvasFactory.
Fixes failures in some of the tests.
Fixes expected behaviour.
Remove unused vars.
2017-02-05 20:19:47 +05:30
Tim van der Meij
95732279b6
Remove usage of mozFillRule
...
The non-standard `mozFillRule` has been removed in Firefox 51 [1, 2].
Instead, a parameter of the standard methods should be used. Note that
this is supported in all major browsers for a long time now, so there
should be no need keeping this Firefox-specific code around.
[1] https://developer.mozilla.org/en-US/Firefox/Releases/51
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=826619
2017-01-29 23:24:44 +01:00
Jonas Jenwald
4626fc8342
Enable the spaced-comment
ESLint rule
...
Please see http://eslint.org/docs/rules/spaced-comment .
Note that the exceptions added for `line` comments are intended to still allow use of the old preprocessor without linting errors.
Also, I took the opportunity to improve the grammar slightly (w.r.t. capitalization and punctuation) for comments touched in the patch.
2017-01-19 16:41:59 +01:00
Jonas Jenwald
c850968fa7
Remove globals
that are now unnecessary thanks to the use of various ESLint environments (e.g. Node, ShellJS, Jasmine)
2016-12-16 21:09:55 +01:00
Jonas Jenwald
66d2637b3f
Fix errors reported by the yoda
ESLint rule
...
http://eslint.org/docs/rules/yoda
2016-12-12 20:35:52 +01:00
Jonas Jenwald
3820946301
Fix (most) errors reported by the no-multi-spaces
ESLint rule
...
http://eslint.org/docs/rules/no-multi-spaces
2016-12-12 20:35:51 +01:00
Jonas Jenwald
d3043167de
Correctly detect more cases of non-embedded Arial Black fonts (issue 7835)
...
This patch adds support for non-embedded Arial Black fonts, that use a `Arial-Black...` format for the font names.
Also, this patch changes `canvas.js` such that we always render Arial Black fonts with the maximum weight, which actually improves a number of existing test-cases. This should thus explain the test "failures", which are clear improvements compared with e.g. Adobe Reader.
Fixes 7835.
2016-11-22 13:56:21 +01:00
Tim van der Meij
5194e68134
Lint: correct code style violations
...
Manual observations and working with other linting tools found these.
2016-11-01 15:04:21 +01:00
Jonas Jenwald
8eaa2cbce3
Remove the deprecated mozDash
/mozDashOffset
canvas 2D context methods
...
According to [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility ) the standard versions of these methods have been supported since Firefox 27, which was released over two and a half years ago. (See the dates in https://wiki.mozilla.org/RapidRelease/Calendar#Past_branch_dates )
Furthermore the non-standard properties are now in the process of being removed, please see https://groups.google.com/forum/#!topic/mozilla.dev.platform/UIudMABegcY .
Hence I don't think that we need to keep the old `moz` prefixed ones as fallback any more.
2016-09-15 10:05:40 +02:00
Jonas Jenwald
5379749d4b
Try to prevent CanvasGraphics_getSinglePixelWidth
from intermittently returning incorrect values in Firefox (issue 7188)
...
Fixes 7188.
2016-08-22 20:00:24 +02:00
klemens
6f03f62327
trivial spelling fixes
2016-07-17 14:33:41 +02:00
Yury Delendik
63f62a0e53
Finishing SMask at the end of operators list.
2016-04-11 08:02:06 -05:00
Yury Delendik
1485c1d1da
Suspending/resuming SMask operation during setGState/restore.
2016-04-11 08:02:06 -05:00
Yury Delendik
1d12aed5ca
Move all PDFJS.xxx settings into display/global.
2016-04-07 13:46:07 -05:00
Yury Delendik
bda5e6235e
Removes global PDFJS usage from the src/core/.
2016-03-23 19:24:37 -05:00
Yury Delendik
c6d2b7f9d9
Merge pull request #6906 from KamiHQ/fix-printing
...
avoid apply transform twice for composite context
2016-03-11 08:26:59 -06: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
Xiliang Chen
069f4b9bdf
avoid apply transform twice for composite context
2016-01-21 14:25:39 +13: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
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
df81b832bb
Remove unused variables
2015-12-16 23:52:16 +01:00
Yury Delendik
6b60c8f4db
Adds UMD headers to core, display and shared files.
2015-12-15 13:24:39 -06: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
Brendan Dahl
91b27aae46
Merge pull request #6651 from yurydelendik/fix-chars-scaling
...
Fix chars scaling for standard fonts. (redo of #4908 )
2015-12-10 14:18:48 -05:00
Yury Delendik
15c9969abe
Adds transfer function support for SMask.
2015-12-04 12:52:45 -06:00
Yury Delendik
d4843ebf6d
Fixes canvas state after smask group ends.
2015-12-03 14:34:12 -06:00
Daan Sprenkels
a9081653fc
shading-pattern: While drawing patterns, transform to the baseTransform first
2015-12-02 21:49:38 +01:00
Yury Delendik
c9cb6a3025
Replaces UnsupportedManager with callback.
2015-11-30 14:42:47 -06:00
Yury Delendik
194994a289
Merge pull request #6551 from yurydelendik/subaa
...
[api-minor] Enables subpixel anti-aliasing for most of the content.
2015-11-17 19:45:32 -06:00
Yury Delendik
8200f099a3
Fix chars scaling for standard fonts.
2015-11-17 13:21:27 -06:00
Yury Delendik
1d8800370a
Allow subpixel anti-aliasing for most of the content.
2015-11-16 10:50:02 -06:00
Manas
a2ba1b8189
Uses editorconfig to maintain consistent coding styles
...
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Yury Delendik
fa46b73c47
Better spacing in text layer.
2015-11-02 08:54:15 -06:00
Jonas Jenwald
487ba9065a
Fail gracefully, and with a notification, if paintXObject is encountered in canvas.js
...
We should never actually try to execute `paintXObject` in canvas.js, but in some cases where we fail to parse the PDF file correctly it can happen. Currently this will potentially cause an entire page to fail to render, which seems suboptimal.
With this patch, we will instead continue rendering with a warning that things might not work correctly.
2015-10-21 21:30:59 +02:00
Tim van der Meij
dd9d0b8770
Merge pull request #5480 from CodingFabian/issue-5458
...
Remove TryCatch in canvas for EvenOdd winding rule.
2015-10-04 15:31:34 +02:00
Jonas Jenwald
9eab463b6d
Ensure that the baseTransform
is always defined for TilingPatterns
...
Fixes http://www2.emersonprocess.com/siteadmincenter/PM%20Micro%20Motion%20Documents/High-Pressure-Measurement-WP-001287.pdf#page=3 .
2015-09-27 22:49:34 +02:00
Fabian Lange
2564827503
Fix text spacing with vertical fonts ( #6387 )
...
According to the PDF spec 5.3.2, a positive value means in horizontal,
that the next glyph is further to the left (so narrower), and in
vertical that it is further down (so wider).
This change fixes the way PDF.js has interpreted the value.
2015-09-15 09:28:45 +02:00
Fabian Lange
063ca95f5f
Remove TryCatch in canvas fill
...
As verified by @Rob--W, the evenodd fill rule works correctly in all supported browsers. This now allows optimization by JS engines.
This fixes #5458
2015-09-05 11:10:51 +02:00
Jonas Jenwald
cfd5a64df5
Ensure that the clipping path is reset when the state is restored (issue 6413)
...
According to the specification, see `NOTE 2` in http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.3882161 , it appears that we should ensure that the clipping path is reset when the restore (`Q`) operator is encountered.
Fixes 6413.
2015-09-03 17:35:32 +02:00
Jonas Jenwald
75624c8d82
Clear the |getSinglePixelWidth| cache when rendering Type3 fonts (issue 6117)
...
Fixes 6117.
2015-06-17 14:30:32 +02:00
Jonas Jenwald
a64536901a
Increase the font weight used for non-embedded ArialBlack fonts
...
Currently non-embedded ArialBlack fonts are not rendered bold enough, compared to e.g. Adobe Reader.
The issue is that we set the font weight to `bolder`, but since that is actually relative to the font weight of the parent, the result is that there's no practical difference from just using `bold`.
This patch attempts to address that, by explicitly setting the font weight to the maximum value instead (see https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight ).
*Note:* I expect one test "failure" in `issue5801`, which in this case is an improvement, since that PDF file uses ArialBlack.
2015-06-06 21:29:41 +02:00
Rob Wu
6eb9e6a6a4
Fix flaw in mozCurrentTransform polyfill
...
Set transformation matrix in (polyfilled) mozPrintCallback when a scale
is applied. Removed _scaleX and _scaleY in favor of _transformMatrix to
emphasize that the caller MUST ensure that the state of the matrix is
correct before `addContextCurrentTransform` is called.
2015-03-11 20:55:26 +01:00
Collin Anderson
54e984c763
cleaned whitespace
2015-02-17 11:07:37 -05:00
Jonas Jenwald
fc1e2483b4
Enforce minimum line widths
2014-12-20 18:05:55 +01:00
Yury Delendik
a018e933ea
Merge pull request #5446 from CodingFabian/minorImprovementsInCanvasjs
...
minor improvements and code cleanup for canvas.js
2014-12-18 15:05:52 -06:00
Fabian Lange
5405b1c8e4
minor improvements and code cleanup for canvas.js
2014-12-18 21:59:40 +01:00
Yury Delendik
35474628e3
Merge pull request #5449 from CodingFabian/preferParamsOverArguments
...
Use 3 param method for converting r,g,b into css string.
2014-12-08 15:23:12 -06:00
Fabian Lange
ceffeab1de
Use 3 param method for converting r,g,b into css string.
...
This avoids creation of temporary arrays to pass them into the util
method. Also using "arguments" is more expensive then passing in 3
parameters.
2014-12-05 19:25:02 +01:00
Yury Delendik
a3df129e32
Merge pull request #5524 from fkaelberer/increaseSMaskChunkSizeTo1M
...
Increases chunk size in SMask composition to 1M pixels
2014-12-05 08:42:06 -08:00
fkaelberer
7d698a46a9
increase chunk size in SMask composition to 1M pixels
2014-12-03 10:25:53 +01:00
Fabian Lange
b049119d14
removed rounding of values in composeSMaskLuminosity
...
maskData comes out of maskCtx.getImageData, so is 0..255 clamped, and
the used multiplications will not create fractions needing rounding,
neither would addition.
2014-12-02 22:25:54 +01:00
Yury Delendik
1bf72f3fe8
Merge pull request #5409 from thejdeep/master
...
Black text not visible #5291
2014-10-25 09:21:08 -05:00
thejdeep
39a29cfe03
Fixed text not visible
2014-10-25 07:18:31 +05:30
Jonas Jenwald
4ac4d49158
Avoid rendering invisible Type3 fonts (issue 5421)
2014-10-18 22:29:21 +02:00
Yury Delendik
be998261cc
Fixes Type3 negative font direction
2014-08-18 17:57:52 -05:00
Jonas Jenwald
c1f1f2f0e1
Add strict equalities in src/display/canvas.js
2014-08-01 12:39:56 +02:00
Yury Delendik
7026543663
Merge pull request #5059 from timvandermeij/unused-code
...
Removing unused code and enforcing additional JSHint options
2014-07-29 15:04:43 -05:00
Jonas Jenwald
2485f11829
Fix loading of PDF files with invalid or missing Type3 characters (issue 5039)
2014-07-24 15:03:22 +02:00
Tim van der Meij
34728ee49b
Removing unused code
2014-07-18 22:34:50 +02:00
pramodhkp
8407d28c9e
Combine re element into constructPath
2014-06-25 00:27:42 +05:30
Nicholas Nethercote
7ef7f95374
Zero the height and width of the Cached canvases before deleting.
...
This reduces peak RSS by about 300 MiB on my Mac when scrolling slowly through
the first 30 pages of a scanned black and white document.
2014-06-16 22:58:11 -07:00
Yury Delendik
1ac8ca66f7
Fixes optional backdrop regression
2014-06-10 15:47:25 -05:00
p01
e0bf7e2151
Optimized genericComposeSMask
...
Declaring the composition and backgdrop functions outside of genericComposeSMask
is more efficient.
2014-06-10 12:37:39 +02:00
p01
412febe4a4
canvas.js minor optimizations
2014-06-10 12:37:39 +02:00
p01
35e418c603
Optimized CanvasGraphics_executeOperatorList 66% faster
2014-06-10 12:37:38 +02:00
Jonas Jenwald
7e6cdc74af
Merge pull request #4832 from yurydelendik/showtext
...
Refactors showText: split type3, remove showSpacedText
2014-05-29 12:58:09 +02:00
Yury Delendik
542c9c4c7a
Moves ColorSpace logic into evaluator
2014-05-23 14:11:47 -05:00
Yury Delendik
d53dc2e7d6
Refactors showText: split type3, remove showSpacedText
2014-05-23 13:36:54 -05:00
Jonas Jenwald
fe27a76004
Merge pull request #4815 from yurydelendik/loadFont
...
Refactors loadFont for translateFont be async
2014-05-20 21:30:42 +02:00
p01
455c6b2d35
Removed several 'in' operators in canvas.js
...
This gives up to 6x speed improvement on these methods
2014-05-20 12:39:59 +02:00
p01
cf5ff3d327
Fewer lookups in CanvasGraphics_constructPath
2014-05-20 12:39:58 +02:00
Yury Delendik
e5a0d89da9
Refactors loadFont for translateFont be async; fixes type3 dup data
2014-05-19 16:27:54 -05:00
Jonas Jenwald
b907e15a90
Build paths for glyph accents when drawing text as curves
2014-05-14 00:04:44 +02:00
Yury Delendik
fd4fc89213
Merge pull request #4763 from yurydelendik/canvas-rAF
...
Uses rAF to interrupt the operator list execution
2014-05-09 07:25:52 -05:00
Yury Delendik
c5eb058b09
Uses rAF to interrupt the operator list execution
2014-05-09 07:00:47 -05:00
Yury Delendik
a26d28a393
Merge pull request #4683 from yurydelendik/grouppath
...
Groups path commands into single operation
2014-05-08 22:16:58 -05:00
p01
83cd530f45
Cleaner putBinaryImageData
2014-05-05 14:22:44 +02:00
Yury Delendik
63d5aae3f6
Groups path commands into single command
2014-04-30 09:09:04 -05:00
Rob Wu
2e97c0d085
Remove some unused variables from src/
...
Only obviously useless, local variables have been removed.
2014-04-15 17:10:23 +02:00
Yury Delendik
a00f854848
Refactors buildImage to use Promise; don't draw bad images
2014-04-14 15:22:35 -05:00
Tim van der Meij
4e055169ed
Fixes lint warning W004 in src/display/{api, canvas, pattern_helper}.js
2014-04-11 00:41:17 +02:00
Brendan Dahl
5bd8a83c9b
Build the text layer geometry on the worker.
2014-04-09 16:44:07 -07:00
Yury Delendik
f57c6935d7
Implements WebGL support
2014-04-03 08:36:22 -05:00
Yury Delendik
944219ad8a
Balance smask process chunking
2014-04-03 08:34:21 -05:00
Yury Delendik
5262e6f84f
Set max size for the group
2014-04-03 08:34:20 -05:00
Yury Delendik
dc0e60d103
Merge pull request #4535 from Snuffleupagus/issue-4484
...
Avoid drawing text when the font size is zero (issue 4484)
2014-04-02 07:23:43 -05:00
Jonas Jenwald
08eb9a960a
Avoid drawing text when the font size is zero (issue 4484)
2014-03-30 13:36:21 +02:00
Jonas Jenwald
7e7b728b5d
Assign non-zero width/height to all rectangles (issue 4260)
2014-03-26 22:29:04 +01:00
p01
4e6ebf2de0
Optimized putBinaryImageData for GRAYSCALE_1BPP
...
The following changes make putBinaryImageData 2.2x faster.
* Use a Uint32Array to draw whole pixels instead component by component
* Unroll the inner most loop
* Added lazy PDFJS.hasCanvasTypedArrays, PDFJS.isLittleEndian and compatibility
Uint32ArrayView for browsers using the old CanvasPixelArray
2014-03-26 14:05:59 +01:00
Christian Krebs
fc9edfcf76
Introduce paintSolidColorImageMask command to handle 1x1 solid image masks
...
See https://github.com/mozilla/pdf.js/issues/4436 for details
2014-03-19 13:27:59 +01:00
Jonas Jenwald
bc986a3029
Fix coding style in src/display/canvas.js
2014-03-14 13:11:11 +01:00