[reportlab-users] Paragraph height wrong when using xml font tags
    Robin Becker 
    robin at reportlab.com
       
    Fri Jun 26 06:22:27 EDT 2009
    
    
  
Hi Volker,
Volker Haas wrote:
> Hi all.
> 
> The height of a paragraph flowable is not calculated correctly when 
> using xml font tags to change the font size. This only happens if *all* 
> of the text  in the paragraph flowable is inside a font tag which 
> changes the size.
> 
I have attempted to commit a fix for this in the trunk. As I suspected the 
problem lies in the difference between the handling in the fast and slow 
paragraph paths. To fix this I needed to change the way autoLeading was behaving 
in the fast path; that involved getting rid of the approximation ascent=fontSize 
descent=0.2*fontSize at least as far as paragraph positioning is concerned.
However we still have this approximation in many places in the canvas drawing code.
For many fonts the assumption is patently false ie the standard Courier font 
ascent+descent <= fontSize. I guess our model which is derived from computer 
land rather than print world is just wrong.
In our model there's just leading and fontSize with default leading defined as 
fontSize*1.2; in this model the lines are leading apart ie leading = line spacing.
In the print world we have ascent + descent and leading so the interline total 
is ascent+descent+leading. Leading is usually small and constant whereas ascent 
and descent are proportional to the font size.
I made a big mistake when doing the work on auto line spacing (ie the 
autoLeading option) in not just reusing the original approximation ie instead of 
accumulating the more accurate ascent and descent values I should have just 
recorded the max fontSizes. There might have been some downsides to that, but 
less confusion.
.......
-- 
Robin Becker
    
    
More information about the reportlab-users
mailing list