+
+#if wxMOTIF_NEW_FONT_HANDLING
+
+WXFontSet wxFont::GetFontSet(double scale, WXDisplay* display) const
+{
+ wxXFont* f = GetInternalFont(scale, display);
+
+ if( !f ) return (WXFontSet) 0;
+
+ Arg args[2];
+ int count = 0;
+
+ XtSetArg( args[count], XmNfont, 0 ); ++count;
+ XmRenditionRetrieve( (XmRendition) f->m_rendition, args, count );
+
+ return (WXFontSet) args[0].value;
+}
+
+void wxGetTextExtent(WXDisplay* display, const wxFont& font, double scale,
+ const wxString& str,
+ int* width, int* height, int* ascent, int* descent)
+{
+ XRectangle ink, logical;
+ WXFontSet fset = font.GetFontSet(scale, display);
+
+ XmbTextExtents( (XFontSet)fset, str.c_str(), str.length(), &ink, &logical);
+
+ if( width ) *width = logical.width;
+ if( height ) *height = logical.height;
+ if( ascent ) *ascent = -logical.y;
+ if( descent ) *descent = logical.height + logical.y;
+}
+
+#else // if !wxMOTIF_NEW_FONT_HANDLING
+
+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, (char*) str.c_str(), slen,
+ &direction, &ascent2, &descent2, &overall);
+
+ if ( width )
+ *width = (overall.width);
+ if ( height )
+ *height = (ascent2 + descent2);
+ if ( descent )
+ *descent = descent2;
+ if ( ascent )
+ *ascent = ascent2;
+}
+
+#endif // !wxMOTIF_NEW_FONT_HANDLING