[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lout 3.24: Bug in FontRead(): Fails if empty line after EndCharMetrics

From: Michael Piotrowski
Subject: Lout 3.24: Bug in FontRead(): Fails if empty line after EndCharMetrics
Date: 01 Jun 2001 17:55:22 +0200
User-agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.1 (Bryce Canyon)


while migrating to Lout 3.24 I noticed that Lout wouldn't any longer
read the AFM files generated by ttf2afm (which worked fine with Lout
3.17); instead it would terminate with "fatal error: EndFontMetrics

I found that the cause of this problem was the empty line after
EndCharMetrics in the AFM files.  Lout's FontRead() function uses
sscanf() to extract the keyword from the current line of the AFM file
[z37.c, line 766]:

   sscanf( (char *) buff, "%s", command);

However, if sscanf() fails, e.g., on an empty line, command is not
changed, and still contains its previous value.  In my case this was
"StartCharMetrics", which caused the rest of the file, up to and
including the final "EndFontMetrics", to be read by ReadCharMetrics(),
eventually resulting in the fatal error cited above.

My suggestion would be to replace the line above with something like
this (enclosing the following switch block):

   if (sscanf( (char *) buff, "%s", command) != EOF)
       switch( command[0] )

Or are AFM files not allowed to contain empty lines?  Even then, Lout
should probably issue a different error ;-)

Michael Piotrowski, M.A.                                  <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]