[poppler] [PATCH] proper implementation of drawImageMask and enable type3 fonts

Jeff Muizelaar jrmuizel at nit.ca
Wed Mar 9 17:12:27 PST 2005


This patch replaces the older type3 font/imageMask patch. This time we
do imageMask drawing properly.

-Jeff


2005-03-09  Jeff Muizelaar  <jrmuizel at nit.ca>

	* poppler/CairoFontEngine.cc (CairoFontEngine::getFont):
	Don't print "Type 3 font!" message.

	* poppler/CairoOutputDev.cc (CairoOutputDev::drawImageMask):
	Enable image mask drawing and do it properly, albeit slowly.

	* poppler/CairoOutputDev.h
	(CairoOutputDev::interpretType3Chars): Return true so that 
	Gfx.cc turns type3 characters into calls to drawImageMask

Index: poppler/CairoFontEngine.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoFontEngine.cc,v
retrieving revision 1.1.1.1
diff -u -b -r1.1.1.1 CairoFontEngine.cc
--- poppler/CairoFontEngine.cc	3 Mar 2005 19:46:01 -0000	1.1.1.1
+++ poppler/CairoFontEngine.cc	10 Mar 2005 01:05:17 -0000
@@ -332,7 +332,6 @@
   
   fontType = gfxFont->getType();
   if (fontType == fontType3) {
-    printf ("Type 3 font!\n");
     /* Need to figure this out later */
     //    return NULL;
   }
Index: poppler/CairoOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.3
diff -u -b -r1.3 CairoOutputDev.cc
--- poppler/CairoOutputDev.cc	5 Mar 2005 04:57:49 -0000	1.3
+++ poppler/CairoOutputDev.cc	10 Mar 2005 01:05:17 -0000
@@ -467,12 +467,7 @@
   double *ctm;
   cairo_matrix_t *mat;
 
-  /* TODO: I'm not sure how to implement this, and its currently crashing.
-     Disabling for now */
-
-  return;
-  
-  buffer = (char *)malloc (width * height);
+  buffer = (char *)malloc (width * height * 4);
 
   if (buffer == NULL) {
     error(-1, "Unable to allocate memory for image.");
@@ -485,16 +480,21 @@
   imgStr->reset();
 
   for (y = 0; y < height; y++) {
-    dest = buffer + y * width;
+    dest = buffer + y * width * 4;
     for (x = 0; x < width; x++) {
       imgStr->getPixel(&pix);
+      
+      *dest++ = soutRound(255 * fill_color.b);
+      *dest++ = soutRound(255 * fill_color.g);
+      *dest++ = soutRound(255 * fill_color.r);
+ 
       if (invert)
 	pix ^= 1;
       
       if (pix)
-	*dest++ = 255;
-      else
 	*dest++ = 0;
+      else
+	*dest++ = 255;
     }
   }
 
@@ -514,14 +514,9 @@
   cairo_concat_matrix (cairo, mat);
   cairo_matrix_destroy (mat);
 
-  /* TODO: Should we use A1 here? I assume that is bit-packed */
   image = cairo_surface_create_for_image (
-              buffer, CAIRO_FORMAT_A8, width, height, width);
+              buffer, CAIRO_FORMAT_ARGB32, width, height, width * 4);
   cairo_surface_set_filter (image, CAIRO_FILTER_BEST);
-
-  /* TODO: Is this the right way to do image masks? */
-  cairo_set_rgb_color (cairo,
-		       fill_color.r, fill_color.g, fill_color.b);
   cairo_show_surface (cairo, image, width, height);
 
   cairo_restore (cairo);
Index: poppler/CairoOutputDev.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.h,v
retrieving revision 1.2
diff -u -b -r1.2 CairoOutputDev.h
--- poppler/CairoOutputDev.h	5 Mar 2005 04:57:49 -0000	1.2
+++ poppler/CairoOutputDev.h	10 Mar 2005 01:05:17 -0000
@@ -52,7 +52,7 @@
 
   // Does this device use beginType3Char/endType3Char?  Otherwise,
   // text in Type 3 fonts will be drawn with drawChar/drawString.
-  virtual GBool interpretType3Chars() { return gFalse; }
+  virtual GBool interpretType3Chars() { return gTrue; }
 
   //----- initialization and control
 


More information about the poppler mailing list