# Calculate Rectangular XTEXT Metrics

> [HTML Version](calculaterectxtextmetrics.htm)

**xcall MIAMEX, MX\_GDICALC, MXGDI\_CALCRECTX, handle, status, lft, top, rght, btm, file, height, offset**

This is used to calculated the XTEXT metrics required for use with the GDI print command //XTEXT, and is essentially the same as the existing MXGDI\_CALCRECT except:

•	The_ memo_ argument in MXGDI\_CALCRECT is replaced here by _file_, which specifies the filespec of the text file to analyze.

•	The _overflow_ argument in MXGDI\_CALCRECT is replaced here by _offset_, which indicates the offset within the file. On input, it is the starting offset (default 0). On output, it will be 0 if the entire file fits within the specified rectangle. Otherwise, it will be the offset to the first character that did not fit (which can then be passed to a subsequent MX\_GDICALC call).

•	Note that unlike MXGDI\_CALCRECT, where the font and other spacing factors must be set in advance (via MX\_GDICALC_ opcode_ 2), with XTEXT printing, the font and other layout parameters are set within the text file (particularly in the case of RTF files).

The sample program [MMOGDI in EXLIB:\[908,37\]](https://bitbucket.org/microsabio/exlib/src/master/908037/mmogdi.bp) illustrates the use of //XTEXT and MX\_GDICALC, MXGDI\_CALCRECTX.

This function also works in ATE. As with XTEXT[xs](keyword-types.md), a file resident on the server will be transferred to ATECACHEDIR on PC. Since the use of MXGDI\_CALCRECTX implies that this will happen multiple times per file printed, you might want to optimize the operation, if you are doing it on a lot of files, by pre-transferring the files to the ATECACHEDIR and then referencing the filespec as %atecachedir%\\xxxxxx.yyy.

