Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pg/pgextenttext.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pg/pgextenttext.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pg/pgextenttext.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pg/pgextenttext.html on line 8

PgExtentText()

Calculate the extent of a string of text

Synopsis:

PhRect_t *PgExtentText( PhRect_t *extent,
                        PhPoint_t const *pos,
                        char const *font,
                        char const *str,
                        unsigned n );

Library:

ph

Description:

This function determines the extent that would be occupied if str were rendered at pos, using font (which you should create by calling PfGenerateFontName()). The extent information is stored in the PhRect_t structure pointed to by extent. If you pass extent as NULL, the function returns NULL.

The function calculates the extent of the first n characters of the string. To have the function calculate the extent of the entire string, set n to zero. If you pass pos as NULL, it's assumed to be (0,0).

Returns:

The same as pointer extent, or NULL if an error occurred.

Examples:

The following fragment determines the extent of a string drawn in 18-point, bold, italic Helvetica:

PhRect_t extent;
char Helvetica18bi[MAX_FONT_TAG];

if(PfGenerateFontName("Helvetica", 
                      PF_STYLE_BOLD | PF_STYLE_ITALIC, 18, 
                      Helvetica18bi) == NULL) {
    perror("Unable to find font");
} else {
    if( PgExtentText( &extent, NULL, Helvetica18bi,
                      "Hello World!", 0 ) ) {
       printf( "Ascent: %d Descent: %d Width: %d\n",
               -extent.ul.y, extent.lr.y, 
               extent.lr.x - extent.ul.x + 1 );
    } else {
       printf( "Error.\n" );
    }
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PfGenerateFontName(), PgDrawMultiTextArea(), PgDrawText(), PgExtentMultiText(), PgSetFont(), PhPoint_t, PhRect_t

Text in the Raw Drawing and Animation chapter of the Photon Programmer's Guide


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pg/pgextenttext.html on line 145

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pg/pgextenttext.html on line 145