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

Wrong rendering of pattern #11473

Closed
MichaelEischer opened this issue Jan 4, 2020 · 1 comment
Closed

Wrong rendering of pattern #11473

MichaelEischer opened this issue Jan 4, 2020 · 1 comment

Comments

@MichaelEischer
Copy link

pattern.pdf

Configuration:

  • Firefox Nightly 73.0a1 (2020-01-04)
  • macOS Mojave 10.14.6
  • PDF.js version: 2.4.254
  • Is a browser extension: built-in

Steps to reproduce the problem:

  1. Open the PDF, zoom in to 200% for a more detailed view

What is the expected behavior?
pattern-acrobat

What went wrong?
pattern-pdfjs

The crosshatch pattern is rendered by pdf.js using the wrong pattern style. The other pattern style just seem to have a broken redering.

TeX source of PDF:

\documentclass[a4paper,11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}
crosshatch pattern:
\begin{tikzpicture}
\draw[draw=black, fill=black!10, pattern=crosshatch, pattern color=black] (0,0) rectangle (1,1);
\end{tikzpicture}
\\

north east lines pattern:
\begin{tikzpicture}
\draw[draw=black, fill=black!10, pattern=north east lines, pattern color=black] (0,0) rectangle (1,1);
\end{tikzpicture}
\\

north west lines pattern:
\begin{tikzpicture}
\draw[draw=black, fill=black!10, pattern=north west lines, pattern color=black] (0,0) rectangle (1,1);
\end{tikzpicture}
\\

grid pattern:
\begin{tikzpicture}
\draw[draw=black, fill=black!10, pattern=grid, pattern color=black] (0,0) rectangle (1,1);
\end{tikzpicture}
\end{document}
brendandahl added a commit to brendandahl/pdf.js that referenced this issue May 11, 2021
Previously, we set the base transformation and pattern matrix
directly to the main rendering ctx of the page, however doing this
caused the current transform to be lost. This would cause issues
with things like shear missing so the pattern was misaligned or when
stroke was used the scale of the line width or dash would be wrong.
Instead we should leave the current transform and use setTransfrom
on the pattern so it is applied correctly. For axial and radial shadings I had
to create a temporary canvas to draw the shading so I could in turn
use setTransform.

Fixes: mozilla#13325, mozilla#6769, mozilla#7847, mozilla#11018, mozilla#11597, mozilla#11473

The following already in the corpus are improved:
issue8078-page1
issue1877-page1
brendandahl added a commit to brendandahl/pdf.js that referenced this issue Jun 30, 2021
Previously, when we filled image masks we didn't copy over the current transformation,
this caused patterns to be misaligned when painted. Now we create a temporary
canvas with the mask and have the transform copied over and offset it relative to
where the mask would be painted. We also weren't properly offsetting tiling patterns.
This isn't usually noticeable since patters repeat, but in the case of mozilla#13561 the pattern
is only drawn once and has to be in the correct position to line up with the mask image.

These fixes broke mozilla#11473, but highlighted that we were drawing that correctly by
accident and not correctly handling negative bounding boxes on tiling patterns.

Fixes mozilla#6297,  mozilla#13561, mozilla#13441, mozilla#13111

Partially fixes mozilla#1344 (still blurry but boxes are in correct position now)
brendandahl added a commit to brendandahl/pdf.js that referenced this issue Jul 6, 2021
Previously, when we filled image masks we didn't copy over the current transformation,
this caused patterns to be misaligned when painted. Now we create a temporary
canvas with the mask and have the transform copied over and offset it relative to
where the mask would be painted. We also weren't properly offsetting tiling patterns.
This isn't usually noticeable since patters repeat, but in the case of mozilla#13561 the pattern
is only drawn once and has to be in the correct position to line up with the mask image.

These fixes broke mozilla#11473, but highlighted that we were drawing that correctly by
accident and not correctly handling negative bounding boxes on tiling patterns.

Fixes mozilla#6297,  mozilla#13561, mozilla#13441, mozilla#13111

Partially fixes mozilla#1344 (still blurry but boxes are in correct position now)
brendandahl added a commit to brendandahl/pdf.js that referenced this issue Jul 7, 2021
Previously, when we filled image masks we didn't copy over the current transformation,
this caused patterns to be misaligned when painted. Now we create a temporary
canvas with the mask and have the transform copied over and offset it relative to
where the mask would be painted. We also weren't properly offsetting tiling patterns.
This isn't usually noticeable since patters repeat, but in the case of mozilla#13561 the pattern
is only drawn once and has to be in the correct position to line up with the mask image.

These fixes broke mozilla#11473, but highlighted that we were drawing that correctly by
accident and not correctly handling negative bounding boxes on tiling patterns.

Fixes mozilla#6297,  mozilla#13561, mozilla#13441

Partially fixes mozilla#1344 (still blurry but boxes are in correct position now)
@SamyCookie
Copy link

Since #11473, there is some tiny glitches on lines, should we reopen this ticket until rendering is perfectly effected ?

bh213 pushed a commit to bh213/pdf.js that referenced this issue Jun 3, 2022
Previously, when we filled image masks we didn't copy over the current transformation,
this caused patterns to be misaligned when painted. Now we create a temporary
canvas with the mask and have the transform copied over and offset it relative to
where the mask would be painted. We also weren't properly offsetting tiling patterns.
This isn't usually noticeable since patters repeat, but in the case of mozilla#13561 the pattern
is only drawn once and has to be in the correct position to line up with the mask image.

These fixes broke mozilla#11473, but highlighted that we were drawing that correctly by
accident and not correctly handling negative bounding boxes on tiling patterns.

Fixes mozilla#6297,  mozilla#13561, mozilla#13441

Partially fixes mozilla#1344 (still blurry but boxes are in correct position now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants