[prev in list] [next in list] [prev in thread] [next in thread] 

List:       abiword-dev
Subject:    Re: GR_UnixPangoGraphics::_scaleCharacterMetrics unit confusion
From:       Martin Sevior <msevior () gmail ! com>
Date:       2009-01-31 1:25:55
Message-ID: 6d78b3860901301725j23eb3ddax906953df92e6394f () mail ! gmail ! com
[Download RAW message or body]


On Sat, Jan 31, 2009 at 5:59 AM, John Wehle <john@feith.com> wrote:
>> Another possibility for your problem is that m_iDeviceResolution is
>> not set correctly.
>
> It looks reasonable.
>
>> In all my builds I always see a device resolution of 96.
>
> The existing debug statements said:
>
> DEBUG: GR_UnixPangoGraphics::graphicsAllocator
> DEBUG: Initializing UnixPangoGraphics 8954000
> DEBUG: cursor set to 1  gdk 68
> DEBUG: @@@@@@@@@@@@@ retrieved DPI 96 @@@@@@@@@@@@@@@@@
>
> And the statement I added to tdu said:
>
> Zoom 114  DeviceRes 96 Res 1440
>

OK this is all fine

<snip>

>>>  1) I believe RI.m_pGlyphs->glyphs[i].geometry.width is PangoGlyphUnit,
>>>     not layout units.
>>
>> It starts out that way but it must end up in device units, ie the
>> actual pixel position on the screen.
>
> Okay I'm even more confused.  What I see in the code is:
>
>  pango_shape fills out m_pGlyphs based on the chosen font
>
>  _scaleCharacterMetrics is intended to fill m_pScaledGlyphs
>  based on m_pGlyphs and the current zoom
>
>  m_pScaledGlyphs is passed to pango_xft_render to draw the
>  actual glyphs
>
> My pango documentation indicates that pango_shape fills in
> glyphs with geometry information based on PANGO_SCALE (1024)
> of a device unit.  The documentation also indicates that
> pango_xft_render expects the geometry of the glyphs to be
> based on PANGO_SCALE (1024) of a device unit (i.e. the same
> units as pango_shape).
>
>  1) _tduX is looks like it works in layout units which appears
>     to be 1440.  How can it take something in pango units when
>     it expects layout units?
>

This absolutely correct. _tduX converts a layout unit to a device unit.

>  2) What am I missing in the pango documentation regarding the
>     units used by the glyph parameter to pango_xft_render?
>
> I do see that the x and y offsets passed to pango_xft_render for
> where to start are in pixels, however that's separate from the
> glyph information.
>
>> The _tduX() method does what you want but in addition takes into
>> account rounding unit adjustments when doing a horizontal scroll, (in
>> case the width of the page is bigger that your frame).
>
> I understand this when dealing with the x offset of the glyph.  I don't
> understand how anything regarding the scroll affects the glyph width.
> Can you give me an example?
>

Not easily, but this a red-herring in any case. The effect of _tduX is
make sure all the text lines up to within the nearest
pixel. You describe a situation where something is fundamentally broken.

Could you tell me which version of abiword, and gtk you are using? All
this works perfectly on current linux distros.

I wonder if perhaps you're regularly hitting an irregular code
pathway? To tell, look at the method:

 GR_UnixPangoGraphics::renderChars(GR_RenderInfo & ri)

Change:

	xxx_UT_DEBUGMSG(("Pango renderChars: xoff %d yoff %d\n",
					 RI.m_xoff, RI.m_yoff));
	to

	UT_DEBUGMSG(("Pango renderChars: xoff %d yoff %d\n",
					 RI.m_xoff, RI.m_yoff));
	
If you're hitting the preferred code pathway, you should see that
debug message on every character draw.

If you're hitting the other pathway, you'll see the debugmsg:

		UT_DEBUGMSG(("Drawing glyph subset from %d to %d (offsets %d, %d)\n",
					 iGlyphsStart, iGlyphsEnd,
					 iOffsetStart, iOffsetEnd));

Which do you see?


Thanks!

Martin




> -- John
> -------------------------------------------------------------------------
> |   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
> |    John Wehle    |     Fax: 1-215-540-5495  |                         |
> -------------------------------------------------------------------------
>
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic