Logo Search packages:      
Sourcecode: adesklets version File versions

void imlib_text_get_location_at_index ( const char *  text,
int  index,
int *  char_x_return,
int *  char_y_return,
int *  char_width_return,
int *  char_height_return 
)

Parameters:
text A string.
index The index of .
char_x_return The x coordinate of the character.
char_y_return The y coordinate of the character.
char_width_return The width of the character.
char_height_return The height of the character.
Gets the geometry of the character at index index in the text string using the current font.

Definition at line 3950 of file imlib2.c.

References imlib_get_text_size().

{
   ImlibFont          *fn;
   int                 cx, cy, cw, ch, w, h;

   if (!ctx)
      ctx = imlib_context_new();
   CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "font", ctx->font);
   CHECK_PARAM_POINTER("imlib_text_get_index_and_location", "text", text);
   fn = (ImlibFont *) ctx->font;

   imlib_font_query_char_coords(fn, text, index, &cx, &cy, &cw, &ch);

   imlib_get_text_size(text, &w, &h);

   switch (ctx->direction)
     {
       case IMLIB_TEXT_TO_RIGHT:
          if (char_x_return)
             *char_x_return = cx;
          if (char_y_return)
             *char_y_return = cy;
          if (char_width_return)
             *char_width_return = cw;
          if (char_height_return)
             *char_height_return = ch;
          return;
          break;
       case IMLIB_TEXT_TO_LEFT:
          cx = 1 + w - cx - cw;
          if (char_x_return)
             *char_x_return = cx;
          if (char_y_return)
             *char_y_return = cy;
          if (char_width_return)
             *char_width_return = cw;
          if (char_height_return)
             *char_height_return = ch;
          return;
          break;
       case IMLIB_TEXT_TO_DOWN:
          if (char_x_return)
             *char_x_return = cy;
          if (char_y_return)
             *char_y_return = cx;
          if (char_width_return)
             *char_width_return = ch;
          if (char_height_return)
             *char_height_return = cw;
          return;
          break;
       case IMLIB_TEXT_TO_UP:
          cy = 1 + h - cy - ch;
          if (char_x_return)
             *char_x_return = cy;
          if (char_y_return)
             *char_y_return = cx;
          if (char_width_return)
             *char_width_return = ch;
          if (char_height_return)
             *char_height_return = cw;
          return;
          break;
       default:
          return;
          break;
     }
}


Generated by  Doxygen 1.6.0   Back to index