? attachment.cgi?id=5496 ? mkinstalldirs ? transform2.patch ? glib/poppler-features.h ? poppler/GlobalParams.cc-merge Index: poppler/CairoOutputDev.cc =================================================================== RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v retrieving revision 1.35 diff -u -r1.35 CairoOutputDev.cc --- poppler/CairoOutputDev.cc 27 Apr 2006 17:26:37 -0000 1.35 +++ poppler/CairoOutputDev.cc 27 May 2006 22:50:30 -0000 @@ -123,10 +123,85 @@ updateStrokeOpacity(state); needFontUpdate = gTrue; } +static void print_ctm(char *name, double *ctm) { + /*printf("%s: %f %f, %f %f, %f %f\n", + name, + ctm[0], + ctm[1], + ctm[2], + ctm[3], + ctm[4], + ctm[5]);*/ +} +static void print_matrix(char *name, cairo_matrix_t matrix) { +/* printf("%s: %f %f, %f %f, %f %f\n", + name, + matrix.xx, + matrix.yx, + matrix.xy, + matrix.yy, + matrix.x0, + matrix.y0);*/ +} + +void CairoOutputDev::setDefaultCTM(double *ctm) { + cairo_matrix_t matrix; + matrix.xx = ctm[0]; + matrix.yx = ctm[1]; + matrix.xy = ctm[2]; + matrix.yy = ctm[3]; + matrix.x0 = ctm[4]; + matrix.y0 = ctm[5]; + print_matrix("default", matrix); + cairo_set_matrix (cairo, &matrix); + + OutputDev::setDefaultCTM(ctm); +} +static int done; void CairoOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) { + cairo_matrix_t matrix; + matrix.xx = m11; + matrix.yx = m12; + matrix.xy = m21; + matrix.yy = m22; + matrix.x0 = m31; + matrix.y0 = m32; + print_matrix("transform", matrix); + if (done) { + double *ctm = state->getCTM(); + cairo_matrix_t cmatrix; + cairo_get_matrix(cairo, &cmatrix); + print_matrix("old", cmatrix); + print_ctm("ctm", ctm); +// exit(1); + } + + + if (m11 == 0 && m12 == 1 && m21 == -1 && m22 == 0) {// && m31 == -404.59999 && m32 == 47.70001) { + double *ctm = state->getCTM(); + cairo_matrix_t cmatrix; + cairo_get_matrix(cairo, &cmatrix); + print_matrix("current", cmatrix); + cairo_transform (cairo, &matrix); + cairo_get_matrix(cairo, &cmatrix); + print_matrix("new", cmatrix); + print_ctm("ctm", ctm); + done = 1; + } else + if (done) { + cairo_transform (cairo, &matrix); + double *ctm = state->getCTM(); + cairo_matrix_t cmatrix; + cairo_get_matrix(cairo, &cmatrix); + print_matrix("current", cmatrix); + print_ctm("ctm", ctm); +// exit(1); + } + else + cairo_transform (cairo, &matrix); updateLineDash(state); updateLineJoin(state); updateLineCap(state); @@ -137,20 +212,9 @@ double *dashPattern; int dashLength; double dashStart; - double *transformedDash; - double transformedStart; - int i; state->getLineDash(&dashPattern, &dashLength, &dashStart); - - transformedDash = new double[dashLength]; - - for (i = 0; i < dashLength; ++i) { - transformedDash[i] = state->transformWidth(dashPattern[i]); - } - transformedStart = state->transformWidth(dashStart); - cairo_set_dash (cairo, transformedDash, dashLength, transformedStart); - delete [] transformedDash; + cairo_set_dash (cairo, dashPattern, dashLength, dashStart); } void CairoOutputDev::updateFlatness(GfxState *state) { @@ -191,10 +255,11 @@ void CairoOutputDev::updateLineWidth(GfxState *state) { LOG(printf ("line width: %f\n", state->getTransformedLineWidth())); + //printf ("line width: %f\n", state->getLineWidth()); if (state->getTransformedLineWidth() == 0.0) { cairo_set_line_width (cairo, 72.0/300.0); } else { - cairo_set_line_width (cairo, state->getTransformedLineWidth()); + cairo_set_line_width (cairo, state->getLineWidth()); } } @@ -271,13 +336,16 @@ font_face = currentFont->getFontFace(); cairo_set_font_face (cairo, font_face); - - matrix.xx = m11; - matrix.xy = -m21; - matrix.yx = m12; - matrix.yy = -m22; - matrix.x0 = 0; - matrix.y0 = 0; + + double fontSize = state->getFontSize(); + double *m = state->getTextMat(); + matrix.xx = m[0] * fontSize; + matrix.yx = m[1] * fontSize; + matrix.xy = -m[2] * fontSize; + matrix.yy = -m[3] * fontSize; + matrix.x0 = m[4]; + matrix.y0 = m[5]; + print_matrix("font", matrix); cairo_set_font_matrix (cairo, &matrix); } @@ -285,29 +353,59 @@ GfxSubpath *subpath; double x1, y1, x2, y2, x3, y3; int i, j; - + double *ctm = state->getCTM(); + cairo_matrix_t matrix; + matrix.xx = ctm[0]; + matrix.yx = ctm[1]; + matrix.xy = ctm[2]; + matrix.yy = ctm[3]; + matrix.x0 = ctm[4]; + matrix.y0 = ctm[5]; + //cairo_save (cairo); + //cairo_transform (cairo, &matrix); for (i = 0; i < path->getNumSubpaths(); ++i) { subpath = path->getSubpath(i); if (subpath->getNumPoints() > 0) { state->transform(subpath->getX(0), subpath->getY(0), &x1, &y1); - cairo_move_to (cairo, x1, y1); - LOG (printf ("move_to %f, %f\n", x1, y1)); - j = 1; + //cairo_move_to (cairo, x1, y1); + //*/ + if (done) { + double *ctm = state->getCTM(); + cairo_matrix_t cmatrix; + cairo_get_matrix(cairo, &cmatrix); + print_matrix("current", cmatrix); + print_ctm("ctm", ctm); + done = !done; +// exit(1); + } + + cairo_move_to (cairo, subpath->getX(0), subpath->getY(0)); + //printf ("move_to %f, %f\n", subpath->getX(0), subpath->getY(0)); + //printf ("old_move_to %f, %f\n", x1, y1); + j = 1; while (j < subpath->getNumPoints()) { if (subpath->getCurve(j)) { - state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1); +/* state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1); state->transform(subpath->getX(j+1), subpath->getY(j+1), &x2, &y2); state->transform(subpath->getX(j+2), subpath->getY(j+2), &x3, &y3); cairo_curve_to (cairo, x1, y1, x2, y2, - x3, y3); + x3, y3);*/ + cairo_curve_to( cairo, + subpath->getX(j), subpath->getY(j), + subpath->getX(j+1), subpath->getY(j+1), + subpath->getX(j+2), subpath->getY(j+2)); + LOG (printf ("curve_to %f, %f %f, %f %f, %f\n", x1, y1, x2, y2, x3, y3)); + //printf ("curve_to %f, %f %f, %f %f, %f\n", x1, y1, x2, y2, x3, y3); j += 3; } else { state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1); - cairo_line_to (cairo, x1, y1); - LOG(printf ("line_to %f, %f\n", x1, y1)); + //cairo_line_to (cairo, x1, y1); + //printf ("old_line_to %f, %f\n", x1, y1); + //printf("line_to %f, %f\n", subpath->getX(j), subpath->getY(j)); + cairo_line_to (cairo, subpath->getX(j), subpath->getY(j)); ++j; } } @@ -317,6 +415,7 @@ } } } + //cairo_restore (cairo); } void CairoOutputDev::stroke(GfxState *state) { @@ -376,8 +475,10 @@ glyphs[glyphCount].index = currentFont->getGlyph (code, u, uLen); state->transform(x - originX, y - originY, &tx, &ty); - glyphs[glyphCount].x = tx; - glyphs[glyphCount].y = ty; +// glyphs[glyphCount].x = tx; +// glyphs[glyphCount].y = ty; + glyphs[glyphCount].x = x - originX; + glyphs[glyphCount].y = y - originY; glyphCount++; } @@ -430,7 +531,9 @@ textClipPath = cairo_copy_path (cairo); cairo_new_path (cairo); } - + + //if (cairo_status (cairo)) + //printf("CAIRO ERROR: %s\n", cairo_status_to_string(cairo_status(cairo))); gfree (glyphs); glyphs = NULL; } @@ -438,10 +541,26 @@ GBool CairoOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen) { + + cairo_save (cairo); + double *ctm; + cairo_matrix_t matrix; + int invert_bit; + int row_stride; + + ctm = state->getCTM(); + matrix.xx = ctm[0]; + matrix.yx = ctm[1]; + matrix.xy = ctm[2]; + matrix.yy = ctm[3]; + matrix.x0 = ctm[4]; + matrix.y0 = ctm[5]; + cairo_set_matrix(cairo, &matrix); return gFalse; } void CairoOutputDev::endType3Char(GfxState *state) { + cairo_restore (cairo); } void CairoOutputDev::type3D0(GfxState *state, double wx, double wy) { @@ -477,7 +596,7 @@ cairo_matrix_t matrix; int invert_bit; int row_stride; - +#if 0 ctm = state->getCTM(); LOG (printf ("drawImageMask %dx%d, matrix: %f, %f, %f, %f, %f, %f\n", width, height, ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); @@ -487,17 +606,26 @@ matrix.yy = -ctm[3] / height; matrix.x0 = ctm[2] + ctm[4]; matrix.y0 = ctm[3] + ctm[5]; +#endif + matrix.xx = width; + matrix.yx = 0.0; + matrix.xy = 0.0; + matrix.yy = -height; + matrix.x0 = 0.0; + matrix.y0 = height; + /* work around a cairo bug when scaling 1x1 surfaces */ + if (width == 1 && height == 1) { cairo_save (cairo); - cairo_set_matrix (cairo, &matrix); - cairo_rectangle (cairo, 0., 0., 1., 1.); + cairo_rectangle (cairo, 0., 0., width, height); cairo_fill (cairo); cairo_restore (cairo); return; } + row_stride = (width + 3) & ~3; buffer = (unsigned char *) malloc (height * row_stride); if (buffer == NULL) { @@ -535,7 +663,7 @@ return; } - cairo_matrix_invert (&matrix); + cairo_pattern_set_matrix (pattern, &matrix); /* we should actually be using CAIRO_FILTER_NEAREST here. However, @@ -656,9 +784,27 @@ maskMatrix.x0 = ctm[2] + ctm[4]; maskMatrix.y0 = ctm[3] + ctm[5]; - cairo_matrix_invert (&matrix); + matrix.xx = width; + matrix.yx = 0.0; + matrix.xy = 0.0; + matrix.yy = -height; + matrix.x0 = 0.0; + matrix.y0 = height; + + maskMatrix.xx = maskWidth; + maskMatrix.yx = 0.0; + maskMatrix.xy = 0.0; + maskMatrix.yy = -maskHeight; + maskMatrix.x0 = 0.0; + maskMatrix.y0 = maskHeight; + + +/* cairo_matrix_invert (&matrix); cairo_matrix_invert (&maskMatrix); + cairo_matrix_init_scale (&matrix, width, -height); + cairo_matrix_init_scale (&maskMatrix, maskWidth, -maskHeight); +*/ cairo_pattern_set_matrix (pattern, &matrix); cairo_pattern_set_matrix (maskPattern, &maskMatrix); @@ -771,9 +917,28 @@ maskMatrix.x0 = ctm[2] + ctm[4]; maskMatrix.y0 = ctm[3] + ctm[5]; + matrix.xx = width; + matrix.yx = 0.0; + matrix.xy = 0.0; + matrix.yy = -height; + matrix.x0 = 0.0; + matrix.y0 = height; + + maskMatrix.xx = maskWidth; + maskMatrix.yx = 0.0; + maskMatrix.xy = 0.0; + maskMatrix.yy = -maskHeight; + maskMatrix.x0 = 0.0; + maskMatrix.y0 = maskHeight; + +/* + cairo_matrix_invert (&matrix); cairo_matrix_invert (&maskMatrix); + cairo_matrix_init_scale (&matrix, width, -height); + cairo_matrix_init_scale (&maskMatrix, maskWidth, -maskHeight); +*/ cairo_pattern_set_matrix (pattern, &matrix); cairo_pattern_set_matrix (maskPattern, &maskMatrix); @@ -868,14 +1033,22 @@ ctm = state->getCTM(); LOG (printf ("drawImageMask %dx%d, matrix: %f, %f, %f, %f, %f, %f\n", width, height, ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); - matrix.xx = ctm[0] / width; + /*matrix.xx = ctm[0] / width; matrix.xy = -ctm[2] / height; matrix.yx = ctm[1] / width; matrix.yy = -ctm[3] / height; matrix.x0 = ctm[2] + ctm[4]; matrix.y0 = ctm[3] + ctm[5]; +*/ + matrix.xx = width; + matrix.yx = 0.0; + matrix.xy = 0.0; + matrix.yy = -height; + matrix.x0 = 0.0; + matrix.y0 = height; - cairo_matrix_invert (&matrix); +// cairo_matrix_init_scale (&matrix, width, -height); + //cairo_matrix_invert (&matrix); cairo_pattern_set_matrix (pattern, &matrix); cairo_pattern_set_filter (pattern, CAIRO_FILTER_BILINEAR); Index: poppler/CairoOutputDev.h =================================================================== RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.h,v retrieving revision 1.14 diff -u -r1.14 CairoOutputDev.h --- poppler/CairoOutputDev.h 12 Apr 2006 06:52:07 -0000 1.14 +++ poppler/CairoOutputDev.h 27 May 2006 22:50:30 -0000 @@ -71,6 +71,7 @@ //----- update graphics state virtual void updateAll(GfxState *state); + virtual void setDefaultCTM(double *ctm); virtual void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32); virtual void updateLineDash(GfxState *state); Index: test/gtk-cairo-test.cc =================================================================== RCS file: /cvs/poppler/poppler/test/gtk-cairo-test.cc,v retrieving revision 1.9 diff -u -r1.9 gtk-cairo-test.cc --- test/gtk-cairo-test.cc 12 Apr 2006 02:07:07 -0000 1.9 +++ test/gtk-cairo-test.cc 27 May 2006 22:50:53 -0000 @@ -109,6 +109,8 @@ v = g_new0 (View, 1); v->document = poppler_document_new_from_file (filename, NULL, NULL); + if (!v->document) + printf("document bad\n"); if (v->document == NULL) return NULL; Index: utils/pdffonts.cc =================================================================== RCS file: /cvs/poppler/poppler/utils/pdffonts.cc,v retrieving revision 1.3 diff -u -r1.3 pdffonts.cc --- utils/pdffonts.cc 23 Jan 2006 15:40:54 -0000 1.3 +++ utils/pdffonts.cc 27 May 2006 22:50:55 -0000 @@ -272,7 +272,10 @@ } subset = i > 0 && i < name->getLength() && name->getChar(i) == '+'; } - + if (font->getName()) + printf("new name: %s\n", font->getName()->getCString()); + else + printf("new name: MISSSING NAME\n"); // print the font info printf("%-36s %-12s %-3s %-3s %-3s", name ? name->getCString() : "[none]", @@ -281,10 +284,28 @@ subset ? "yes" : "no", hasToUnicode ? "yes" : "no"); if (fontRef.gen >= 100000) { - printf(" [none]\n"); + printf(" [none]"); } else { - printf(" %6d %2d\n", fontRef.num, fontRef.gen); + printf(" %6d %2d", fontRef.num, fontRef.gen); + } + if (!emb) { + DisplayFontParam *dfp = globalParams->getDisplayFont(font); + if (!dfp) { + printf(" no font found\n"); + } else { + GooString *fileName; + switch(dfp->kind) { + case displayFontT1: + fileName = dfp->t1.fileName; + break; + case displayFontTT: + fileName = dfp->tt.fileName; + } + printf(" file: %s", fileName->getCString()); + } } + printf("\n"); + // add this font to the list if (fontsLen == fontsSize) {