Blame SOURCES/paps-fix-tab-width.patch

78523c
@@ -, +, @@ 
78523c
---
78523c
 src/libpaps.c | 40 +++++++++++++++++++++++++++++-----------
78523c
 1 file changed, 29 insertions(+), 11 deletions(-)
78523c
--- a/src/libpaps.c	
78523c
+++ a/src/libpaps.c	
78523c
@@ -251,7 +251,6 @@ gchar *paps_layout_line_to_postscript_strdup(paps_t *paps_,
78523c
 {
78523c
   paps_private_t *paps = (paps_private_t*)paps_;
78523c
   GString *layout_str = g_string_new("");
78523c
-  gchar *ret_str;
78523c
 
78523c
   add_line_to_postscript(paps,
78523c
 			 layout_str,
78523c
@@ -259,10 +258,7 @@ gchar *paps_layout_line_to_postscript_strdup(paps_t *paps_,
78523c
 			 pos_y,
78523c
 			 layout_line);
78523c
 
78523c
-  ret_str = layout_str->str;
78523c
-  g_string_free(layout_str, FALSE);
78523c
-
78523c
-  return ret_str;
78523c
+  return g_string_free(layout_str, FALSE);
78523c
 }
78523c
 
78523c
 static void
78523c
@@ -408,9 +404,26 @@ static void draw_contour(paps_private_t *paps,
78523c
 {
78523c
   GSList *runs_list;
78523c
   double scale = 72.0 / PANGO_SCALE  / PAPS_DPI; 
78523c
+  PangoGlyphUnit avg_width = 1;
78523c
 
78523c
   g_string_append(layout_str, "(");
78523c
-  
78523c
+
78523c
+  if (paps->cpi > 0.0L)
78523c
+    {
78523c
+      /* calculate approximate width per a character */
78523c
+      for (runs_list = pango_line->runs; runs_list != NULL; runs_list = g_slist_next(runs_list))
78523c
+	{
78523c
+	  PangoLayoutRun *run = runs_list->data;
78523c
+	  PangoGlyphString *glyphs = run->glyphs;
78523c
+	  int i;
78523c
+
78523c
+	  for (i = 0; i < glyphs->num_glyphs; i++)
78523c
+	    {
78523c
+	      if (glyphs->glyphs[i].glyph != PANGO_GLYPH_EMPTY)
78523c
+		avg_width = MAX (avg_width, glyphs->glyphs[i].geometry.width);
78523c
+	    }
78523c
+	}
78523c
+    }
78523c
   /* Loop over the runs and output font info */
78523c
   runs_list = pango_line->runs;
78523c
   double x_pos = line_start_pos_x;
78523c
@@ -433,11 +446,16 @@ static void draw_contour(paps_private_t *paps,
78523c
           glyph_pos_x = x_pos + 1.0*geometry.x_offset * scale;
78523c
           glyph_pos_y = line_start_pos_y - 1.0*geometry.y_offset * scale;
78523c
 
78523c
-	  if (paps->cpi > 0.0L) {
78523c
-		  x_pos += (1 / paps->cpi * 72.0);
78523c
-	  } else {
78523c
-		  x_pos += geometry.width * scale * paps->scale_x;
78523c
-	  }
78523c
+	  if (paps->cpi > 0.0L)
78523c
+	    {
78523c
+	      double n = ((double)geometry.width) / avg_width;
78523c
+
78523c
+	      x_pos += n * (1 / paps->cpi * 72.0);
78523c
+	    }
78523c
+	  else
78523c
+	    {
78523c
+	      x_pos += geometry.width * scale * paps->scale_x;
78523c
+	    }
78523c
 
78523c
           if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY)
78523c
             continue;
78523c
--