![]() |
-----BEGIN PGP SIGNED MESSAGE----- /usr/src/hylafax-v4.0pl1/util/TextFmt.h.patch /usr/src/hylafax-v4.0pl1/util/TextFmt.c++.patch Above patches solves ``textfmt'' bugs on any platform/any OS and if applied by hand, applicable also to older versions of hylafax. Now no more problems with international character sets and textfmt! Hi Sam, have inserted ``(unsigned const char)'' in TextFmt.h and have added a few lines to hylafax-v4.0pl1/util/TextFmt.c++ to make it function better in an international environment and with bad data in the upper character-codes of the metrics-files in the distribution. Find commented patches attached. Feel free to remove the comments, they are just there to tell you and others why I did what I did. The above patches have been thoroughly tested by me. They work well. They fix a programming error where values in an array are selected using *negative* indices, causing random memory addresses to be refereced. This is the cause of much pain in the international Hylafax community. Help is on it's way! Especially, TextFmt.h.patch solves the worst problem, but TextFmt.c++.patch may also be neccessary + that it solves minor errors in the processing of font width data from font metrics files by ignoring data in the files for character values above 127, because the supplied font metrics files cannot reliably be used for values above 127 -- iso 8859-1, instead it uses the same default Sam uses when no font metrics files are found, but only for values above 127, values up to 127 are read as before. == Leif Erlingsson http://www.lege.com +46 8 604-0995 FAX +46 8 605-2551 pgp -kvc leif@lege.com DB 47 2F B1 F8 6B E5 92 7A 97 5C C8 7E 62 CA 7C Stockholm, Sweden, Tellus, Milky Way, Gods Universe. -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: latin1 iQCVAgUBMwKvYQ0882B94nEhAQFNWgP/fatmsYj5uzsbwMUEVOMajCe3LM1TX3IM IHUg0CNAGqw2CbZNbwarrcpLmZvhes2cOICM9GVDwhQFraoq24NsyU8KsTNflPJS VD2xX258ToTuFmkfHi3i5tE4mE3xNaCT9dIxxiqtdmJrp7Ovfj52KqFy17+IBgaa Jsk1eZwJ2Xw= =qS2T -----END PGP SIGNATURE----- Please contact <leif@lege.com> for Public Key, if you don't have it. ID: 1024/7DE27121 1996/08/17 Leif Erlingsson <leif@lege.com> *** TextFmt.h.orig Wed Nov 27 00:20:54 1996 --- TextFmt.h Thu Feb 13 02:41:46 1997 *************** *** 65,71 **** fxBool readMetrics(TextCoord pointsize, fxBool useISO8859, fxStr& emsg); }; ! inline TextCoord TextFont::charwidth(const char c) const { return widths[c]; } inline const char* TextFont::getFamily(void) const { return family; } class FontDict; --- 65,82 ---- fxBool readMetrics(TextCoord pointsize, fxBool useISO8859, fxStr& emsg); }; ! /* ! * The *real* BAAD bug with iso8859-1 was here in TextFont::charwidth, ! * now kludged by Leif Erlingsson <leif@lege.com> using a type-cast. ! * The real bug, though, is in the prototypes.... Always always always ! * use ``unsigned char'' or ``unsigned const char'' etc. Always ! * unsigned, if there is even a remote possibility your program is ever ! * going to be used outside U S A or otherwise used with eight-bit ! * characters. As it is below, ``c'' is negative half the time outside ! * the US, meaning that values from memory preceeding widths[0] was ! * being looked up before ``(unsigned const char) '' was inserted ... ;-) ! */ ! inline TextCoord TextFont::charwidth(const char c) const { return widths[(unsigned const char) c]; } inline const char* TextFont::getFamily(void) const { return family; } class FontDict; *** TextFmt.c++.orig Wed Nov 27 00:20:44 1996 --- TextFmt.c++ Thu Feb 13 02:28:40 1997 *************** *** 1210,1216 **** fputc(c, fd); } else fprintf(fd, "\\%03o", c); ! hm += widths[c]; } while (--len); fprintf(fd, ")%s ", (const char*) showproc); } --- 1210,1216 ---- fputc(c, fd); } else fprintf(fd, "\\%03o", c); ! hm += widths[(unsigned) c]; // Leif Erlingsson <leif@lege.com> } while (--len); fprintf(fd, ")%s ", (const char*) showproc); } *************** *** 1228,1234 **** { TextCoord w = 0; while (*cp) ! w += widths[*cp++]; return w; } --- 1228,1234 ---- { TextCoord w = 0; while (*cp) ! w += widths[(unsigned) (*cp++ & 0xff)]; // Leif Erlingsson <leif@lege.com> return w; } *************** *** 1295,1300 **** --- 1295,1307 ---- "%s: No glyph metric table located; using fixed widths", (const char*) file); fclose(fp); + /* + * Next line added by Leif Erlingsson <leif@lege.com> because + * otherwise, if the metrics-file has no glyph metric table + * and useISO8859 == False, the FixedMetrics will be all 0's! + * (I don't know if this does or does not cause any problem.) + */ + loadFixedMetrics(625*ps/1000L); // NB: use fixed width metrics return (FALSE); } lineno++; *************** *** 1311,1316 **** --- 1318,1333 ---- } if (ix == -1) // end of unencoded glyphs break; + /* + * Next if-clause added by Leif Erlingsson <leif@lege.com> because + * experience has shown most glyph metric table's to be useless + * for obtaining character widths of iso8859-1 characters > 127. + * The Adobe Helvetica-Oblique metrics-file created Tue Apr 1 + * 12:54:09 PST 1986 caused bad spacing for eight-bit iso-8859-1 + * characters, for example. + */ + if (ix > 127) + w = 625; // distrust metrics-file for char > 127 if (ix < NCHARS) widths[ix] = w*ps/1000L; }