Calculate individual character positions
int PfExtentTextCharPositions(
PhRect_t * ptsExtent,
PhPoint_t * ptsPos,
char * psz,
const char * pckFont,
int32_t * piIndices,
int32_t * piPenPositions,
int32_t iArrayLen,
uint32_t ulFlags,
int32_t iBytes,
uint32_t uiExtentLen,
PhRect_t const * pktsClip );
For example, index 0 relates to the pen's x position at the start of the string, index 1 corresponds to the pen's x position after character 1, index 2 corresponds to the pen's x position after character 2, and so on.
The indexes must be in numerical order, in order to function as expected.
| This function assumes each character is represented by 2 bytes that conform to the ISO/IEC 10646-1 UCS-2 double-byte format. |
If this bit isn't set, the bearing x value of the next symbols are applied to the pen x positions. This is useful when drawing symbols individually, where you need to know where to place the x origin of each symbol:
strlen( psz ) / wstrlen( psz )
ph
PfExtentTextCharPositions() lets you obtain the pen's x position after every index specified in the function call.
#define MAX_INDICES 5
#define FALSE 0
int iaIndex[MAX_INDICES] = {0, 1, 2, 3, 4};
int iaPosition[MAX_INDICES];
PhRect_t tsExtent;
char caBuff[MAX_FONT_TAG];
PfGenerateFontName("Helvetica", 0, 24, caBuff);
if( PfExtentTextCharPositions( &tsExtent, NULL,
"Lucy", caBuff, iaIndex, iaPositon,
MAX_INDICES, 0L, 0, 0, NULL) != EOK)
printf("Error in PfExtentTextCharPositions().\n");
else
printf("Pixel penx positions after each character \
in string %s, are as follows: %d %d %d %d %d.\n",
"Lucy", iaPosition[0], iaPosition[1],
iaPosition[2], iaPosition[3],
iaPositionArray[4]);
The pixel pen x positions for each character in the string Lucy are placed in the integer array iaPos, according to the indexes specified in iaIndex. Index 0 corresponds to the position before symbol L, index 1 corresponds to the position after L, index 2 corresponds to the position after u, and so on.
Photon
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
PfExtent(), PfExtentCx(), PfExtentText(), PfExtentTextCharPositionsCx(), PfExtentTextToRect(), PfExtentFractTextCharPositions(), PfFractionalExtentText(), PfGenerateFontName(), PhPoint_t, PhRect_t
Fonts chapter of the Photon Programmer's Guide