![]() |
![]() |
![]() |
![]() |
Calculate the extent rectangle of a text string
#include <photon/Pf.h> PhRect_t *PfExtentText( PhRect_t *extent, PhPoint_t const *pos, const char *font, const char *str, int len);
ph
This function calculates the extent rectangle of a text string. The base font is given by font, which you should create by calling PfGenerateFontName(). The base font determines the ascender anddescender values of the extent. The width is dependent on the string -- the actual font used by characters within the string may be different than this base font (as specified in the fontext and fontmap files).
The string str is a UTF-8 multibyte string of len bytes. If len is 0, strlen(str) is assumed.
The text extent is returned in a PhRect_t structure, with ul.x being the left bearing, lr.x-min(ul.x,0)+1 the right, ul.y the ascender, and lr.y the descender. The baseline of the font is at position y=0; the width of the string.
The resulting extent is offset by the point passed in the PhPoint_t structure pointed to by pos. If pos is NULL, no offset is applied.
If metrics for the base font have been loaded locally (see PfLoadMetrics()) then this extent may be calculated internally; otherwise a request is sent to the font server.
A pointer to the extent rectangle (extent) if successful, NULL otherwise.
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PfExtentTextToRect(), PfFractionalExtentText(), PfGenerateFontName(), PfLoadMetrics(), PgExtentText(), PhPoint_t, PhRect_t
Fonts chapter of the Photon Programmer's Guide
![]() |
![]() |
![]() |
![]() |