Re: gEDA-user: gschem text line spacing in postscript

2010-02-25 Thread Duncan Drennan
 This one adds a 12% leading to the text spacing for print, causing it to
 pretty well match my on-screen leading. YMMV depending on what fonts
 your system chooses.

This patch works beautifully. I tried it out with the font scaling set
to 1.0 and 1.3 and the result was consistent line spacing between the
on screen and postscript versions. This was with Win32 builds.

Thanks!
Duncan


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: gschem text line spacing in postscript

2010-02-24 Thread Peter TB Brett
On Tue, 23 Feb 2010 22:36:48 +, Peter Clifton pc...@cam.ac.uk wrote:

 BUT.. this should also be using the gEDA font size - points conversion.
 The 13 vs 13.89 discrepency is already incorporated in the 1.3 factor
 shipped by default.
 

If I remember correctly, printed line spacing was another reason in favour
of the font sizing option we chose in the end.

Peter

-- 
Peter Brett pe...@peter-b.co.uk
Remote Sensing Research Group
Surrey Space Centre


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


gEDA-user: gschem text line spacing in postscript

2010-02-23 Thread Duncan Drennan
Hi,

I noticed a small issue with the line spacing in the postscript output
of gschem. It appears to be that the text line spacing is not
consistent with the font scaling when output to postscript. Here is a
screenshot to show the difference between the gschem scaling and the
output postscript scaling, see
http://www.engineersimplicity.com/gEDA/text_line_spacing.png

I'm running a custom compiled version with the cairo/pango font
scaling set to 1.0 and suspect that the spacing issue is linked to
this. Is there another factor which influences line spacing?

Thanks,
Duncan

-- 
Turn ideas into products - http://www.engineersimplicity.com
The Art of Engineering - http://blog.engineersimplicity.com


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: gschem text line spacing in postscript

2010-02-23 Thread Peter Clifton
On Tue, 2010-02-23 at 22:07 +0200, Duncan Drennan wrote:
 Hi,
 
 I noticed a small issue with the line spacing in the postscript output
 of gschem. It appears to be that the text line spacing is not
 consistent with the font scaling when output to postscript. Here is a
 screenshot to show the difference between the gschem scaling and the
 output postscript scaling, see
 http://www.engineersimplicity.com/gEDA/text_line_spacing.png
 
 I'm running a custom compiled version with the cairo/pango font
 scaling set to 1.0 and suspect that the spacing issue is linked to
 this. Is there another factor which influences line spacing?
 
 Thanks,
 Duncan

Hmm... this will all be fixed when I get my backside into gear and
finish up the cairo printing support... until then, I'm not sure..

It might be something we can fix in the existing printing code, but it
could also just be a failing of the new cairo text rendering to match up
with the old printing code. I attempted to match on-screen rendering
before / after cairo, but never cross-checked how the printing output
used to match up.

Best regards,


-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: gschem text line spacing in postscript

2010-02-23 Thread Peter Clifton
On Tue, 2010-02-23 at 22:01 +, Peter Clifton wrote:
 Hmm... this will all be fixed when I get my backside into gear and
 finish up the cairo printing support... until then, I'm not sure..
 
 It might be something we can fix in the existing printing code, but it
 could also just be a failing of the new cairo text rendering to match up
 with the old printing code. I attempted to match on-screen rendering
 before / after cairo, but never cross-checked how the printing output
 used to match up.

Yep.. the printed output uses a completely different way of calculating
the line height. (Cairo + pango just do it for us in the renderer).

There is some magic going on which is specific only to printing:

libgeda/include/libgeda/defines.h:#define LINE_SPACING2.0

libgeda/src/o_text_basic.c

static int o_text_height(const char *string, int size) 

which returns:
  26*size/2*(1+LINE_SPACING*(line_count-1))

The printing code offsets by (char_height*LINE_SPACING)

Where char_height is o_text_height(a, o_current-text-size);
IE, 13 * o_current-text-size

A better conversion to mils is probably 1000 (mils/inch) / 72 (pt/inch)
= 13.89 mils/pt.

BUT.. this should also be using the gEDA font size - points conversion.
The 13 vs 13.89 discrepency is already incorporated in the 1.3 factor
shipped by default.

The short answer.. might be to change the 26*size/2 * ... to be 13.89 *
(float)size * (float)(line_count - 1)

And get rid of LINE_SPACING all together.


-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: gschem text line spacing in postscript

2010-02-23 Thread Peter Clifton
The attached patch should make things a little closer between on-screen
and print-out.

Apparently this isn't the whole story though, on my box at least, Pango
seems to be using a little inter-line spacing. The calculations with
this patch assume that a 12 point font has 12/72 inches between each
baseline.

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
diff --git a/libgeda/include/libgeda/defines.h b/libgeda/include/libgeda/defines.h
index d1f0422..cf7432a 100644
--- a/libgeda/include/libgeda/defines.h
+++ b/libgeda/include/libgeda/defines.h
@@ -121,9 +121,6 @@
 /* Warning: it MUST be a string. */
 #define TAB_CHAR_MODEL b
 
-/* multi text line spacing (multipled times character height) */
-#define LINE_SPACING2.0
-
 /* The conn modes for type */
 #define CONN_NULL   0
 #define CONN_ENDPOINT		1
diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index cd6bac8..e7f79b8 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -610,35 +610,6 @@ void o_text_print_text_string(FILE *fp, char *string, int unicode_count,
 }
 
 
-/*! \brief calculates the height of a text string
- *  \par Function Description
- *  This function calculates the height of a \a string depending
- *  on it's text \a size. The number of lines and the spacing
- *  between the lines are taken into account.
- * 
- *  \param [in] string  the text string
- *  \param [in] sizethe text size of the character
- *  \return the total height of the text string
- */
-static int o_text_height(const char *string, int size) 
-{
-  int line_count = 0;
-
-  if (string == NULL) {
-return 0;
-  }
-
-  /* Get the number of lines in the string */
-  line_count = o_text_num_lines(string);
-  
-  /* 26 is the height of a single char (in mils) */
-  /* which represents a character which is 2 pts high */
-  /* So size has to be divided in half */
-  /* and it's added the LINE_SPACING*character_height of each line */
-  return(26*size/2*(1+LINE_SPACING*(line_count-1)));
-}
-
-
 /*! \brief print a text object into a postscript file
  *  \par Function Description
  *  This function writes the postscript representation of the text object
@@ -766,8 +737,9 @@ void o_text_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
 break;
   }
 
-  char_height = o_text_height(a, o_current-text-size);
-  fprintf(fp,%s %f [,centering_control,(float)(char_height*LINE_SPACING));
+  font_size = o_text_get_font_size_in_points (toplevel, o_current)
+/ 72.0 * 1000.0;
+  fprintf(fp,%s %f [,centering_control, font_size);
 
   /* split the line at each newline and print them */
   p = output_string;   /* Current point */
@@ -790,8 +762,6 @@ void o_text_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
   /* Collect pertinent info about the text location */
   x = o_current-text-x;
   y = o_current-text-y;
-  font_size = o_text_get_font_size_in_points (toplevel, o_current)
-/ 72.0 * 1000.0;
   fprintf(fp,] %d %d %d %f text\n,angle,x,y,font_size);
 
   


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: gschem text line spacing in postscript

2010-02-23 Thread Peter Clifton
On Tue, 2010-02-23 at 23:02 +, Peter Clifton wrote:
 The attached patch should make things a little closer between on-screen
 and print-out.
 
 Apparently this isn't the whole story though, on my box at least, Pango
 seems to be using a little inter-line spacing. The calculations with
 this patch assume that a 12 point font has 12/72 inches between each
 baseline.

This one adds a 12% leading to the text spacing for print, causing it to
pretty well match my on-screen leading. YMMV depending on what fonts
your system chooses.

Best regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
diff --git a/libgeda/include/libgeda/defines.h b/libgeda/include/libgeda/defines.h
index d1f0422..cf7432a 100644
--- a/libgeda/include/libgeda/defines.h
+++ b/libgeda/include/libgeda/defines.h
@@ -121,9 +121,6 @@
 /* Warning: it MUST be a string. */
 #define TAB_CHAR_MODEL b
 
-/* multi text line spacing (multipled times character height) */
-#define LINE_SPACING2.0
-
 /* The conn modes for type */
 #define CONN_NULL   0
 #define CONN_ENDPOINT		1
diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index cd6bac8..6830674 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -89,6 +89,14 @@
  */
 #define GEDA_FONT_FACTOR 1.3
 
+/*! \brief Scale factor font height and line-spacing (for print only)
+ *
+ *  \par Description
+ *  Specifies the scale factor between the nominal font size and the inter-
+ *  line spacing used to render it when printing.
+ */
+#define PRINT_LINE_SPACING 1.12
+
 /*! Default setting for text draw function. */
 void (*text_draw_func)() = NULL;
 
@@ -610,35 +618,6 @@ void o_text_print_text_string(FILE *fp, char *string, int unicode_count,
 }
 
 
-/*! \brief calculates the height of a text string
- *  \par Function Description
- *  This function calculates the height of a \a string depending
- *  on it's text \a size. The number of lines and the spacing
- *  between the lines are taken into account.
- * 
- *  \param [in] string  the text string
- *  \param [in] sizethe text size of the character
- *  \return the total height of the text string
- */
-static int o_text_height(const char *string, int size) 
-{
-  int line_count = 0;
-
-  if (string == NULL) {
-return 0;
-  }
-
-  /* Get the number of lines in the string */
-  line_count = o_text_num_lines(string);
-  
-  /* 26 is the height of a single char (in mils) */
-  /* which represents a character which is 2 pts high */
-  /* So size has to be divided in half */
-  /* and it's added the LINE_SPACING*character_height of each line */
-  return(26*size/2*(1+LINE_SPACING*(line_count-1)));
-}
-
-
 /*! \brief print a text object into a postscript file
  *  \par Function Description
  *  This function writes the postscript representation of the text object
@@ -661,7 +640,7 @@ void o_text_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
   char *output_string = NULL;
   char *name = NULL;
   char *value = NULL;
-  int x, y, angle, len, char_height;
+  int x, y, angle, len;
   float font_size;
 
 
@@ -766,8 +745,9 @@ void o_text_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
 break;
   }
 
-  char_height = o_text_height(a, o_current-text-size);
-  fprintf(fp,%s %f [,centering_control,(float)(char_height*LINE_SPACING));
+  font_size = o_text_get_font_size_in_points (toplevel, o_current)
+/ 72.0 * 1000.0;
+  fprintf(fp,%s %f [,centering_control, font_size * PRINT_LINE_SPACING);
 
   /* split the line at each newline and print them */
   p = output_string;   /* Current point */
@@ -790,8 +770,6 @@ void o_text_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
   /* Collect pertinent info about the text location */
   x = o_current-text-x;
   y = o_current-text-y;
-  font_size = o_text_get_font_size_in_points (toplevel, o_current)
-/ 72.0 * 1000.0;
   fprintf(fp,] %d %d %d %f text\n,angle,x,y,font_size);
 
   


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: gschem text line spacing in postscript

2010-02-23 Thread Duncan Drennan
 This one adds a 12% leading to the text spacing for print, causing it to
 pretty well match my on-screen leading. YMMV depending on what fonts
 your system chooses.

Thanks Peter, I'll try it out and give you some feedback.

Regards,
Duncan


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user