示例#1
0
void			text(char *str, t_itfc *itfc, int x, int y)
{
  static unsigned int	curs = 0;
  int			i;
  int			size;

  itfc->txt.txt_pos.x = x;
  itfc->txt.txt_pos.y = y;
  size = my_strlen(str);
  i = 0;
  while (i < size)
    {
      blit_char(&itfc->txt, itfc->txt.font, str[i]);
      i++;
    }
  if (curs++ % 60 < 40)
    blit_char(&itfc->txt, itfc->txt.font, '|');
}
示例#2
0
/*
	blit a line of text into the text_tile buffer
*/
static void blit_text(int x, int y, char *str, Color4 *color, int max_width, int flags) {
	while(*str) {
		switch((unsigned char)*str) {
			case ' ':
				x += FONT_W;
				break;

			case '\r':
				x = 0;
				break;

			case '\n':			/* can only handle a single line */
				return;

			default:
#ifdef TEXTBOX_COLORCODES
/*
	support for changing color within a string using color codes
*/
				if ((unsigned char)*str >= CHAR_BLACK
					&& (unsigned char)*str <= CHAR_WHITE) {				/* change color */
					if (color->a == 0xff && color != &text_colors[BLACK])
						color = &text_colors[(unsigned char)*str - CHAR_BLACK];
				} else
#endif
					x += blit_char(x, y, *str, color, max_width, flags) + FONT_LINING+FONT_SPACING;
		}
		if (x >= max_width)		/* wrap past end of buffer */
			break;

		if (!*str)
			break;

		str++;
	}
}