r5752 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Thu Dec 10 13:02:03 CET 2009


Author: werner
Date: 2009-12-10 13:02:02 +0100 (Thu, 10 Dec 2009)
New Revision: 5752

Modified:
   trunk/eda/fped/postscript.c
Log:
Added a crude hack to increase the robustness of font scaling. (This can
be necessary if printing unusually large components.)

- postscript.c: in "maxfont", if we get a zero-sized font, dodge the division
  by zero



Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c	2009-12-10 06:57:56 UTC (rev 5751)
+++ trunk/eda/fped/postscript.c	2009-12-10 12:02:02 UTC (rev 5752)
@@ -891,16 +891,22 @@
 
 	/*
 	 * Stack: font string width height factor -> factor
+	 *
+	 * Hack: sometimes, scalefont can't produce a suitable font and just
+	 * gives us something zero-sized, which trips the division. We just
+	 * ignore this case for now. Since maxfont is used in pairs, the
+	 * second one may still succeed.
 	 */
 
 	fprintf(file,
+"/sdiv { dup 0 eq { pop 1 } if div } def\n"
 "/maxfont {\n"
 "    gsave 0 0 moveto\n"
 "    /f exch def /h exch def /w exch def\n"
 "    exch f scalefont setfont\n"
 "    false charpath flattenpath pathbbox\n"
 "    /ury exch def /urx exch def /lly exch def /llx exch def\n"
-"    w urx llx sub div h ury lly sub div 2 copy gt { exch } if pop\n"
+"    w urx llx sub sdiv h ury lly sub sdiv 2 copy gt { exch } if pop\n"
 "    f mul grestore } def\n");
 
 	/*




More information about the commitlog mailing list