# NNS_G2dTextCanvasGetStringWidth

## Syntax

      #include <nnsys/g2d/g2d_TextCanvas.h>

      int NNS_G2dTextCanvasGetStringWidth(
      	const NNSG2dTextCanvas* pTxn,
      	const NNSG2dChar* str,
      	const NNSG2dChar** pPos
      );

## Arguments

pTxn | [IN] Pointer to TextCanvas
str | [IN] Pointer to text string
pPos | [OUT] Pointer to the buffer that holds the pointer to the next line. (Can be NULL.)

## Return Values

Returns the line width of one line of a string when drawn (in pixels).

## Description

Calculates the width that one line of the string has when drawn. The width is for the drawing of the string from str to '\n' (0x0A) or '\0'.

If pPos is a non-NULL value, when '\n' is included in text string str, a pointer to the next character after the first '\n' is stored in the buffer indicated by pPos. Otherwise, NULL is stored in the buffer.

For a vertically written font, this function calculates the string's height.

## Sample Code

`

    // Get the sum total text-string length for all lines
        const char* str = "abcdefg\n" "ghijk\n" "lmn";
        int sum = 0;

        while( str != NULL )
        {
            sum += NNS_G2dTextCanvasGetStringWidth(&tc, str, &str);
        }

`

## See Also

NNS_G2dFontGetStringWidth, NNS_G2dTextCanvasGetTextWidth, NNS_G2dTextCanvasGetTextHeight, NNS_G2dTextCanvasGetTextRect

## Revision History

2007/03/14 Added support for vertically written/vertically held fonts.
2005/05/25 Initial version.

CONFIDENTIAL