Ejemplo n.º 1
0
void wxGetTextExtent(WXDisplay* display, const wxFont& font,
                     double scale, const wxString& str,
                     int* width, int* height, int* ascent, int* descent)
{
    WXFontStructPtr pFontStruct = font.GetFontStruct(scale, display);

    int direction, ascent2, descent2;
    XCharStruct overall;
    int slen = str.length();

    XTextExtents((XFontStruct*) pFontStruct,
                 const_cast<char*>((const char *)str.mb_str()), slen,
                 &direction, &ascent2, &descent2, &overall);

    if ( width )
        *width = (overall.width);
    if ( height )
        *height = (ascent2 + descent2);
    if ( descent )
        *descent = descent2;
    if ( ascent )
        *ascent = ascent2;
}