/// <summary>Calculate the average character width of indicated font data.</summary> /// <param name="x11display">The display pointer, that specifies the connection to the X server.<see cref="IntPtr"/></param> /// <param name="x11gc">The crapchics context to use for drawing.<see cref="IntPtr"/></param> /// <param name="fontData">The font data to calculate the average character width for.<see cref="X11FontData"/></param> /// <returns>The average character width of indicated font data.<see cref="System.Int32"/></returns> public static int AverageCharacterWidth(IntPtr x11display, IntPtr x11gc, X11FontData fontData) { if (fontData == null) { SimpleLog.LogLine(TraceEventType.Error, CLASS_NAME + "::AverageCharacterWidth () Argument null: fontData"); return(0); } if (fontData.UseFontset) { X11lib.XRectangle overallInc = new X11lib.XRectangle(); X11lib.XRectangle overallLogical = new X11lib.XRectangle(); X11.TWchar[] text = new X11.TWchar[] { (X11.TWchar) 'X', (X11.TWchar) ' ', (X11.TWchar) 'i' }; X11lib.XwcTextExtents(fontData.FontResourceId, text, (X11.TInt)text.Length, ref overallInc, ref overallLogical); return((int)(((int)overallLogical.width + 2) / 3)); } else { TInt direction = 0; TInt fontAscent = 0; TInt fontDescent = 0; X11lib.XCharStruct xCharStruct = new X11lib.XCharStruct(); X11lib.XChar2b[] text = new X11lib.XChar2b[] { new X11lib.XChar2b('X'), new X11lib.XChar2b(' '), new X11lib.XChar2b('i') }; X11lib.XSetFont(x11display, x11gc, fontData.FontResourceId); X11lib.XQueryTextExtents16(x11display, fontData.FontResourceId, text, (X11.TInt)text.Length, ref direction, ref fontAscent, ref fontDescent, ref xCharStruct); return((int)(((int)xCharStruct.width + 2) / 3)); } }
extern public static void XRenderFillRectangles(IntPtr x11display, TInt operation, IntPtr pictureDestination, ref XRenderColor color, ref X11lib.XRectangle rectangles, TInt numRects);