Re: Everything on a single page

Valery Ushakov <[email protected]>
Newsgroups gmane.comp.type-setting.lout
Message-ID <[email protected]>
On Tue, Jun 11, 2013 at 19:50:34 +0200, Kamil Rytarowski wrote:

> internal error: assert failed in MinSize: fwd(x, dim) < 0!

Hmm, interesting.  The first error that valgrind tells me about is
that lout is confused by egonek in "Wste,p" (in the chapter title)
when table of contents is produced on the thrid run:

  Conditional jump or move depends on uninitialised value(s)
     at 0x4F7B6C: FontWordSize (z37.c:1683)
     by 0x47B096: MinSize (z12.c:1093)
     [...]
   Uninitialised value was created by a heap allocation
     at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
     by 0x4F2FD8: FontRead (z37.c:729)
     by 0x4F5876: FontChange (z37.c:1347)
     [...]

and many more.  Depending on the garbage you've got in the
uninitialised memory you either get that error or a crash.

A quick kludge to change z37.c:729 from malloc to calloc (that zeroes
the memory):

--- z37.c~  2010-09-10 00:55:04.000000000 +0400
+++ 37.c   2013-06-12 01:11:42.317596802 +0400
@@ -726,7 +726,7 @@
   /* initialise font metrics table for the new font */
   ifdebug(DMA, D,
       DebugRegisterUsage(MEM_FONTS, 1, MAX_CHARS * sizeof(struct metrics)));
-  fnt = (struct metrics *) malloc(MAX_CHARS * sizeof(struct metrics));
+  fnt = (struct metrics *) calloc(MAX_CHARS, sizeof(struct metrics));
   if( fnt == (struct metrics *) NULL )
     Error(37, 25, "run out of memory while reading font file %s",
       FATAL, &fpos(err), FileName(fnum));

papers over the internal error, but produces incorrectly formatted
document.


This is where it gets even more interesting.

To begin with, it looks like extra metric files (Ti-Rm+ &c) mostly
contain subset of Latin2 used for Czech.  "eogonek" is found only in
two files, 

Ti-It+:5:C -1 ; WX 444 ; N eogonek ; B 25 -10 424 460 ;
Ti-Rm+:5:C -1 ; WX 444 ; N eogonek ; B 25 -10 424 460 ;

But consider attached minimized document that has 

@Chapter
  @Title { @Show { Wst{@Char eogonek}p } test }

When "Wste,p test" is printed in the chapter title itself, it's
printed correctly and the bounding box around "Wste,p" (drawn by
@Show) is correct.

When "Wste,p test" is printed in the TOC, "test" runs into "Wste,p"
and the bounding box is incorrect.  This is where valgrind complained
about uninitialised value, and where now zero bounding box for eogonek
is picked up.  Of course the font itself is recoded correctly, so
eogonek in "Wste,p" is printed, but since Lout thinks it's zero-width,
it positions "test" based on incorrect size of "Wste,p".

But both of them are in the same TimesCE Bold!  And valgrind doesn't
complain on the first two runs (when chapter title is printed, but TOC
is not).  So I'm puzzled.  Unfortunately I don't have time right now
to debug it further.  If anyone can pick this up, minimized test case
is attached and valgrind, -dddft, and -dddcm are your friends :).

-uwe
eogonek.lt (text/plain, 834 B)
# -*- coding: latin-2;-*-

@SysInclude { langdefs }
@SysInclude { bsf }
@SysInclude { dsf }
@SysInclude { bookf }
@SysInclude { latin2 }

@SysDatabase @FontDef { fontdefs }

def @Show right x {
  { 0 0 moveto xsize 0 lineto xsize ysize lineto 0 ysize lineto
    closepath 0.75 setgray fill
    1 0 0 setrgbcolor
    xmark 0 moveto xmark ysize lineto stroke
    0 ymark moveto xsize ymark lineto stroke
  } @Graphic x
}

@Use { @BasicSetup
    @InitialFont { TimesCE Base 12p }
    @InitialLanguage { Polish }
}

@Use { @DocumentSetup
    @MakeContents { Yes }
    @PageHeaders { None }
}

@Use { @BookSetup
    @TitlePageFont { TimesCE Base }
}

@SysDatabase @RefStyle { refstyle }

@Book
  @Title { Tytu{@Char lslash} pracy }
//
@Chapter
  @Title { @Show { Wst{@Char eogonek}p } test }
{
@LP
Nie pieprz, Pietrze, pieprzem wieprza.
}
eogonek.ps.gz (application/x-gunzip, 4.6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.