Ok. I've done a bit more research on this. As far as I can see there appear to
be two problems.
1, When the zoom is changed GR_Graphics doesn't reload the device font.
Thus, in a piece of code like this...
GR_Painter painter(gc);
gc->setZoomPercentage(100);
gc->setFont("Times New Roman"... "12pt");
gc->setZoomPercentage(200);
printf("%d\n", measureUnremappedChar('A');
painter.drawChars("A");
measureUnremappedChar() will be returning the width in pixels for a zoom
of 200%, but drawChars() will only be drawing at 100%. Thus, the width
measurement will seem twice as large as it should be.
2, The values returned from the freetype library in
XAP_UnixFontHandle::measureUnremappedCharForCache() for
pFace->glyph->linearHoriAdvance don't seemed quite accurate.
For example, for Arial at 15pt and 100% zoom the width of an "A" is 11
pixels, but linearHoriAdvance returns 10.004... points. [0]
Similarly, an "A" in Comic Times MS is 12 pixels wide but
linearHoriAdvance returns 10.97...pt. Adding 1 and rounding to the
nearest interger "fixes" the problem for 100% zoom. However, the values
when the zoom is 200% seem correct.
[0] The device resolution appears to be fixed at 72dpi so in this case
pixels=points.
1, is responsible for the majority of the error observed in the image I posted.
It can be fixed adding the following two lines to
GR_Graphics::setZoomPercentage():
void GR_UnixGraphics::setZoomPercentage(UT_uint32 iZoom)
{
GR_Graphics::setZoomPercentage (iZoom); // chain up
// Reset the device font for the new zoom.
if (m_pFont) // <-- This
m_pXftFontD = m_pFont->getDeviceXftFont(getZoomPercentage()); // <-- This
}
Is this an appropriate fix?
I'm not at all sure about what can be done about 2.
Best wishes,
R.
Received on Wed Aug 17 07:58:11 2005
This archive was generated by hypermail 2.1.8 : Wed Aug 17 2005 - 07:58:13 CEST