Re: Question for C++ guru's..

From: Tomas Frydrych <tf_at_o-hand.com>
Date: Tue Dec 26 2006 - 19:17:13 CET

msevior@physics.unimelb.edu.au wrote:
> Hi everyone,
> After a little investigating I found that the reason printing
> on unix is not working right is because the virtual methods
> are called.
> GR_UnixPangoGraphics is defined with this inheritence..
>
> class ABI_EXPORT GR_UnixPangoGraphics : public GR_UnixGraphics
>
> and has these methods..
>
>
> virtual UT_uint32 getFontAscent(GR_Font *);
> virtual UT_uint32 getFontDescent(GR_Font *);
> virtual UT_uint32 getFontHeight(GR_Font *);
>
> XAP_UnixGnomePrintGraphics is defined this way
>
> class XAP_UnixGnomePrintGraphics : public GR_Graphics
>
> has the same virtual methods..
>
>
>
> virtual UT_uint32 getFontAscent(GR_Font *);
> virtual UT_uint32 getFontDescent(GR_Font *);
> virtual UT_uint32 getFontHeight(GR_Font *);
>
> Now the constructor of XAP_UnixGnomePrintGraphics also contonstructs
> GR_UnixPangoGraphics, then in fp_Run.cpp::_inheritProperties we calculate
> the height of the run with this call...
>
> _setHeight(getGraphics()->getFontHeight(pFont));
>
> Which resolves to
>
> GR_UnixPangoGraphics::getFontHeight(GR_Font *)
>
> and not to
>
> XAP_UnixGnomePrintGraphics::getFontHeight(GR_Font *)
>
> Which is why the line spacing when printing is wrong.
>
> Do any of our C++ guru's know what is going on and how to fix it?
>
> Cheers
>
> Martin
>
>

There are two Pango-based graphics classes, the base class
GR_UnixPangoGraphics, which operates on screen font map, and a derived
GR_UnixPangoPrintGraphics, which is for the printer. The latter owns an
instance of XAP_UnixGnomePrintGraphics, which provides it with the
appropriate printer font map and methods for non-textual operations
(such as drawing lines); the class itself provides the drawChars() and
renderChars() methods.

The getFontAscent() et al. methods are not overridden because the the
implementation of GR_UnixPangoPringGraphics::getFontAscent() would be
identical to that in the parent class, as it just queries the metrics of
the given Pango font -- if the values that are getting produced are not
correct, then I am pretty sure it is because the wrong font is being
querried. I think the most likely explanation is that when doing
quickPrint, the cached PangoFont for the screen is still being used --
it should not be too hard to fix this by tweaking the logic near the end
of GR_UnixPangoGraphics::setFont () to ensure that reloadFont() is
called if the cached PangoFont is for a different device than is
currently in use.

Tomas
Received on Tue Dec 26 19:18:28 2006

This archive was generated by hypermail 2.1.8 : Tue Dec 26 2006 - 19:18:29 CET