CVS: ----------------------------------------------------------------------
CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: af/gr/win/gr_Win32Graphics.cpp af/gr/win/gr_Win32Graphics.h
CVS: af/gr/xp/gr_Graphics.h af/xap/cocoa/xap_CocoaFont.h
CVS: af/xap/cocoa/xap_CocoaFont.mm af/xap/unix/xap_UnixFont.cpp
CVS: af/xap/unix/xap_UnixFont.h af/xap/unix/xap_UnixPSFont.cpp
CVS: af/xap/unix/xap_UnixPSFont.h
CVS: ----------------------------------------------------------------------
Extend the Graphics class with a new pure abstract method (glyphBox)
needed for Maths support.
This method returns some more detailed metrics of the requested glyph. The
method is as follows:
//
// UT_Rect of glyph in Logical units.
// rec.left = bearing Left (distance from origin to start)
// rec.width = width of the glyph
// rec.top = distance from the origin to the top of the glyph
// rec.height = total height of the glyph
//
virtual bool glyphBox(UT_UCS4Char g, UT_Rect & rec) const = 0;
The implementation in unix is
bool XAP_UnixFontHandle::glyphBox(UT_UCS4Char g, UT_Rect & rec) const
{
XftFaceLocker
locker(m_font->getLayoutXftFont(GR_CharWidthsCache::CACHE_FONT_SIZE));
FT_Face pFace = locker.getFace();
UT_UCS4Char cChar = g;
if(m_font->isSymbol()) cChar = static_cast<UT_UCS4Char>(adobeToUnicode(g));
FT_UInt glyph_index = FT_Get_Char_Index(pFace, cChar);
FT_Error error =
FT_Load_Glyph(pFace, glyph_index,
FT_LOAD_LINEAR_DESIGN |
FT_LOAD_IGNORE_TRANSFORM |
FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE);
if (error) {
return false;
}
rec.left = pFace->glyph->metrics.horiBearingX;
rec.width = pFace->glyph->metrics.width;
rec.top = pFace->glyph->metrics.horiBearingY;
rec.height = pFace->glyph->metrics.height;
xxx_UT_DEBUGMSG((" left %d width %d top %d height %d
\n",rec.left,rec.width,rec.top,rec.height));
return true;
}
I've committed implementations for Win32 and Cocoa in attempt to keep the
build from breaking as follows:
bool GR_Win32Font::glyphBox(UT_UCS4Char g, UT_Rect & rec)
{
// FIXME: Write the code for this!
UT_ASSERT(0);
return false;
}
bool XAP_CocoaFont::glyphBox(UT_UCS4Char g, UT_Rect & rec)
{
// FIXME: Write the code for this!
UT_ASSERT(0);
return false;
}
Please feel free to implement and fix for other platforms or graphics
systems.
Cheers
Martin
Received on Wed Jan 26 13:48:25 2005
This archive was generated by hypermail 2.1.8 : Wed Jan 26 2005 - 13:48:28 CET