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

From: <msevior_at_physics.unimelb.edu.au>
Date: Wed Dec 27 2006 - 05:46:10 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.
>

Hi Tomas,
Thanks for this explanantion.

> 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.
>

It's not a problem with quickPrint. quickPrint works perfectly. The
problem is when rebuilding a full layout the old non-quickPrint way. It
appears to be related to the fact that the X11 screen returns a resolution
of 96 dpi whereas the gnomeprint context has 72 dpi hardcoded. I put in
some code to work around this for non-quickPrints, which is if the view is
in Normal Mode.

Like this:

UT_uint32 GR_UnixPangoPrintGraphics::getFontHeight(GR_Font * fnt)
{
        return
static_cast<UT_uint32>(static_cast<double>(GR_UnixPangoGraphics::getFontHeight(fnt))*m_dResRatio);
}

I would welcome a better solution.

Cheers

Martin

> Tomas
>
Received on Wed Dec 27 05:46:35 2006

This archive was generated by hypermail 2.1.8 : Wed Dec 27 2006 - 05:46:36 CET