[Previous] [Contents] [Index] [Next]

PfTextWidthChars()

Calculate the width of a char string of multibyte UTF-8 characters

Synopsis:

int PfTextWidthChars( const char *font,
                      const char *str,
                      int len );

Library:

ph

Description:

PfTextWidthChars() is a convenience function that calculates the width of the given string in the given font, using the formula:

extent.lr.x - min(extent.ul.x, 0) + 1

The font argument is the name of the desired font. You should use PfGenerateFontName() to create this.

The str argument is a char string of multibyte UTF-8 characters. The len argument gives the number of characters in the string. If len is 0, strlen(str) is assumed.

PfTextWidthBytes() is similar, but you pass it the number of bytes in the string, not the number of characters.

Returns:

The width of the string, or 0 if an error occurred.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PfGenerateFontName(), PfTextWidthBytes()

Fonts chapter of the Photon Programmer's Guide


[Previous] [Contents] [Index] [Next]