Index: gnome-print-pango.c
===================================================================
RCS file: /cvs/gnome/libgnomeprint/libgnomeprint/gnome-print-pango.c,v
retrieving revision 1.7
diff -u -p -r1.7 gnome-print-pango.c
--- gnome-print-pango.c	10 Mar 2005 15:50:25 -0000	1.7
+++ gnome-print-pango.c	12 Mar 2005 22:27:31 -0000
@@ -299,7 +299,7 @@ gnome_print_pango_glyph_string (GnomePri
 			int y = gi->geometry.y_offset;
 			
 			gnome_glyphlist_moveto (glyph_list,
-						(gdouble) x / PANGO_SCALE, (gdouble) y / PANGO_SCALE);
+						(gdouble) x / PANGO_SCALE, - (gdouble) y / PANGO_SCALE);
 			gnome_glyphlist_glyph (glyph_list, gi->glyph);
 		}
 			
Index: gnome-print-pdf.c
===================================================================
RCS file: /cvs/gnome/libgnomeprint/libgnomeprint/gnome-print-pdf.c,v
retrieving revision 1.41
diff -u -p -r1.41 gnome-print-pdf.c
--- gnome-print-pdf.c	4 Jan 2005 19:28:39 -0000	1.41
+++ gnome-print-pdf.c	12 Mar 2005 22:27:31 -0000
@@ -179,7 +179,7 @@ static gint gnome_print_pdf_print_bpath 
 static gchar *gnome_print_pdf_get_date (void);
 
 static gint  gnome_print_pdf_graphic_mode_set (GnomePrintPdf *pdf, PdfGraphicMode mode);
-static gint  gnome_print_pdf_page_fprintf (GnomePrintPdf *pdf, const char *format, ...);
+static gint  gnome_print_pdf_page_fprintf (GnomePrintPdf *pdf, const char *format, ...) G_GNUC_PRINTF (2, 3);
 static gint  gnome_print_pdf_page_print_double (GnomePrintPdf *pdf, const gchar *format, gdouble x);
 
 static GnomePrintContextClass *parent_class;
@@ -685,6 +685,9 @@ gnome_print_pdf_glyphlist (GnomePrintCon
 		GnomePosString *ps;
 		GnomeFont *font;
 		gint i, current_page = -1;
+		gboolean set_rise = FALSE;
+		enum { OUTSIDE, INSIDE_TJ, INSIDE_GLYPHS } state = OUTSIDE;
+		double current_x, current_y;
 
 		ps = pgl->strings + s;
 		font = gnome_rfont_get_font (ps->rfont);
@@ -704,107 +707,108 @@ gnome_print_pdf_glyphlist (GnomePrintCon
 		art_affine_scale (scale, font->size, font->size);
 		art_affine_multiply (Tm, scale, ctm);
 		
-		gnome_print_pdf_page_print_double (pdf, "%g", Tm [0]);
+		gnome_print_pdf_page_print_double (pdf, "%.4f", Tm [0]);
 		gnome_print_pdf_page_fprintf (pdf, " ");
-		gnome_print_pdf_page_print_double (pdf, "%g", Tm [1]);
+		gnome_print_pdf_page_print_double (pdf, "%.4f", Tm [1]);
 		gnome_print_pdf_page_fprintf (pdf, " ");
-		gnome_print_pdf_page_print_double (pdf, "%g", Tm [2]);
+		gnome_print_pdf_page_print_double (pdf, "%.4f", Tm [2]);
 		gnome_print_pdf_page_fprintf (pdf, " ");
-		gnome_print_pdf_page_print_double (pdf, "%g", Tm [3]);
+		gnome_print_pdf_page_print_double (pdf, "%.4f", Tm [3]);
 		gnome_print_pdf_page_fprintf (pdf, " ");
-		gnome_print_pdf_page_print_double (pdf, "%g", dx + pgl->glyphs[ps->start].x);
+		gnome_print_pdf_page_print_double (pdf, "%.1f", dx + pgl->glyphs[ps->start].x);
 		gnome_print_pdf_page_fprintf (pdf, " ");
-		gnome_print_pdf_page_print_double (pdf, "%g", dy + pgl->glyphs[ps->start].y);
+		gnome_print_pdf_page_print_double (pdf, "%.1f", dy + pgl->glyphs[ps->start].y);
 		gnome_print_pdf_page_fprintf (pdf, " Tm" EOL);
 
+		current_x = pgl->glyphs[ps->start].x;
+		current_y = pgl->glyphs[ps->start].y;
+
 		/* Build string */
-		if (!NEEDED_SUBSETTING(font)) {
-			ret = gnome_print_pdf_page_fprintf (pdf, "(");
-			for (i = ps->start; i < ps->start + ps->length; i++) {
-				gint glyph;
-				glyph = pgl->glyphs[i].glyph;
-				glyph = gnome_print_pdf_assign_code_to_glyph (pdf, glyph);
-				ret = gnome_print_pdf_page_fprintf (pdf, "\\%o", glyph);
-				g_return_val_if_fail (ret >= 0, ret);
-			}
-		} else {
-			for (i = ps->start; i < ps->start + ps->length; i++) {
 
+		for (i = ps->start; i < ps->start + ps->length; i++) {
+			gint glyph; /* Glyph to output */
+			
+			if (NEEDED_SUBSETTING (font)) {
 				/* Glyph position in parent font */
-
-				gint master_glyph;
-
-				/* Glyph in subfont */
-
-				gint glyph;
-
+				gint master_glyph = (gint)(pgl->glyphs[i].glyph); 
+			
 				/* Pages of 256 glyphs, including starting */
 				/* null glyph				   */ 
-
-				gint page;
-				
-				master_glyph = (gint)(pgl->glyphs[i].glyph);
-				page  = master_glyph / 255;
-
-				/* Initially */
-
-				if (i==ps->start) {
-					current_page = page;
-					gnome_print_pdf_set_font_real (pdf, font, TRUE, page);
-					ret = gnome_print_pdf_page_fprintf (pdf, "(");
-
-				/* There's a ttf subfont to be set*/
-
-				} else if (current_page != page) {
-					current_page = page;
-					(void)gnome_print_pdf_page_fprintf (pdf, ") Tj" EOL);
-					gnome_print_pdf_set_font_real (pdf, font, TRUE, page);
-					ret = gnome_print_pdf_page_fprintf (pdf, "(");
-				}
-
-				gnome_font_face_pso_mark_glyph (pdf->selected_font->pso, master_glyph);
+				gint page = master_glyph / 255;
 
 				/* For each sub ttf font the first glyph is  */
 				/* null and 255th one is a valid glyph, also */
 				/* 1 needed to be added to each subglyph     */
 				/* for taking into account first null glyph  */
 				/* added to every subfont	             */	
-
 				glyph = master_glyph ? master_glyph % 255 + 1 : master_glyph;
 
-				ret = gnome_print_pdf_page_fprintf (pdf, "\\%o", glyph);
-				g_return_val_if_fail (ret >= 0, ret);
-			}
-		}	
+				if (page != current_page) {
+					if (state > OUTSIDE) {
+						(void)gnome_print_pdf_page_fprintf (pdf, "%s] TJ" EOL,
+										    state >= INSIDE_GLYPHS ? ")" : "");
+						state = OUTSIDE;
+					}
+					
+					gnome_print_pdf_set_font_real (pdf, font, TRUE, page);
+					
+					current_page = page;
+				}
+
+				gnome_font_face_pso_mark_glyph (pdf->selected_font->pso, master_glyph);
 
-		ret = gnome_print_pdf_page_fprintf (pdf, ") Tj" EOL);
+			} else {
+				glyph = pgl->glyphs[i].glyph;
+				glyph = gnome_print_pdf_assign_code_to_glyph (pdf, glyph);
+			}
 
-/* FIXME: We are not honoring xy movements of a glyphlist right now. But rather
- * just assuming that the glyphlist isn't any different than then character
- * spacing that the font metrics provide. */
-#if 0	
-		g_return_val_if_fail (ret >= 0, ret);
-		/* Build array */
-		ret = gnome_print_pdf_page_fprintf (pdf, "[");
-		g_return_val_if_fail (ret >= 0, ret);
-		for (i = ps->start + 1; i < ps->start + ps->length; i++) {
-			ret = gnome_print_pdf_page_print_double (pdf, "%g",
-				     pgl->glyphs[i].x - pgl->glyphs[i-1].x);
-			g_return_val_if_fail (ret >= 0, ret);
-			ret = gnome_print_pdf_page_fprintf (pdf, " ");
-			g_return_val_if_fail (ret >= 0, ret);
-			ret = gnome_print_pdf_page_print_double (pdf, "%g",
-				     pgl->glyphs[i].y - pgl->glyphs[i-1].y);
-			g_return_val_if_fail (ret >= 0, ret);
-			ret = gnome_print_pdf_page_fprintf (pdf, " ");
-			g_return_val_if_fail (ret >= 0, ret);
+			/* Compute the error between the position specified by PDF's default
+			 * text positioning and the position specified in the glyph list.
+			 * if that error is greater than a threshold, reposition the glyph
+			 * horizontally using a distance in the TJ array or vertically
+			 * by setting the rise with Ts
+			 */
+			if (i > ps->start) {
+				double x_error = (pgl->glyphs[i].x - current_x) / font->size;
+				double y_error = (pgl->glyphs[i].y - current_y) / font->size;
+				
+				if (fabs (y_error) >= 0.001) {
+					gnome_print_pdf_page_fprintf (pdf, "%s%s%.4f Ts ",
+								      state >= INSIDE_GLYPHS ? ")" : "",
+								      state >= INSIDE_TJ ? "] TJ " : "",
+								      (pgl->glyphs[i].y - pgl->glyphs[ps->start].y) / font->size);
+					state = OUTSIDE;
+					current_y = pgl->glyphs[i].y;
+					set_rise = TRUE;
+				}
+				
+				if (fabs (x_error) >= 0.001) {
+					gnome_print_pdf_page_fprintf (pdf, "%s%s%.1f ",
+								      state <= OUTSIDE ? "[" : "",
+								      state >= INSIDE_TJ ? ") " : "",
+								      - x_error * 1000);
+					current_x += x_error * font->size;
+					state = INSIDE_TJ;
+				}
+			}
+			
+			gnome_print_pdf_page_fprintf (pdf, "%s%s\\%o",
+						      state <= OUTSIDE ? "[" : "",
+						      state <= INSIDE_TJ ? "(" : "",
+						      glyph);
+			state = INSIDE_GLYPHS;
+			
+			if (i + 1 < ps->start + ps->length) {
+				ArtPoint point;
+				gnome_font_get_glyph_stdadvance (font, pgl->glyphs[i].glyph, &point);
+				current_x += point.x;
+			}
 		}
-		ret = gnome_print_pdf_page_fprintf (pdf, "0 0] ");
-		g_return_val_if_fail (ret >= 0, ret);
-		/* xyshow */
-		ret = gnome_print_pdf_page_fprintf (pdf, "xyshow" EOL);
-		g_return_val_if_fail (ret >= 0, ret);
-#endif
+
+		if (state > OUTSIDE)
+			gnome_print_pdf_page_fprintf (pdf, "%s] TJ%s" EOL,
+						      state >= INSIDE_GLYPHS ? ")" : "",
+						      set_rise ? " 0 Ts" : "");
 	}
 
 	gnome_pgl_destroy (pgl);
