[Poppler-bugs] [Bug 19670] Colorizing text in pattern colorspace solved

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun May 17 04:51:59 PDT 2009


http://bugs.freedesktop.org/show_bug.cgi?id=19670





--- Comment #43 from thomasf <Thomas.Freitag at alfa.de>  2009-05-17 04:51:59 PST ---
Thanks, it helps, and I think I was able to solve it. It is a problem in 
Gfx::opSetFillColorSpace, in case that text colorspace change from a pattern
colorspace to a solid colorspace:
1. doPatternFill(gTrue) already restores the state in OutputDev.
2. In a stateless OutputDevice, after restoring the state, we need to restore
some text parameters.
Therefore the solution is:

void Gfx::opSetFillColorSpace(Object args[], int numArgs) {
  Object obj;
  GfxColorSpace *colorSpace;
  GfxColor color;

  state->setFillPattern(NULL);
  res->lookupColorSpace(args[0].getName(), &obj);
  if (obj.isNull()) {
    colorSpace = GfxColorSpace::parse(&args[0]);
  } else {
    colorSpace = GfxColorSpace::parse(&obj);
  }
  obj.free();
  if (colorSpace) {
    state->setFillColorSpace(colorSpace);
    out->updateFillColorSpace(state);
    colorSpace->getDefaultColor(&color);
    state->setFillColor(&color);
    out->updateFillColor(state);
        if (drawText) {
                if (colorSpace->getMode() == csPattern) {
                        colorSpaceText = NULL;
                        textHaveCSPattern = gTrue;
                        out->beginTextObject(state);
                } else if (textHaveCSPattern) {
                        out->endTextObject(state);
                        doPatternFill(gTrue);
                        //out->restoreState(state);
                        out->beginTextObject(state);
                        out->updateRender(state);
                        out->updateTextMat(state);
                        out->updateTextPos(state);
                        textHaveCSPattern = gFalse;
                }
        }
  } else {
    error(getPos(), "Bad color space (fill)");
  }
}

I tested it with the PDFs of comment 39, and it works well. Unfortunately I'm
not able to test it at home with SplashOutputDev again, I'll do that tomorrow,
but because the three new functions calls are not specified there (so they are
dummy in SplashOutputDev, the changed code should not run into new problems
there.  


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Poppler-bugs mailing list