Exemple #1
0
SDL_Surface *TTF_RenderText_Solid(TTF_Font *font,
                                const char *text, SDL_Color fg)
{
        SDL_Surface *textbuf;
        Uint16 *unicode_text;
        int unicode_len;
    
        /* Copy the Latin-1 text to a UNICODE text buffer */
        unicode_len = strlen(text);
        unicode_text = (Uint16 *)malloc((unicode_len+1)*(sizeof *unicode_text));
        if ( unicode_text == NULL ) {
                TTF_SetError("Out of memory");
                return(NULL);
        }
        ASCII_to_UNICODE(unicode_text, text, unicode_len);

	RenderUnicode(font, unicode_text, fg);
	
        /* Render the new text */
        textbuf = TTF_RenderUNICODE_Solid(font, unicode_text, fg);
    
        /* Free the text buffer and return */
        free(unicode_text);
        return(textbuf);
}
Exemple #2
0
int TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h)
{
	Uint16 *unicode_text;
	int unicode_len;
	int status;

	/* Copy the Latin-1 text to a UNICODE text buffer */
	unicode_len = strlen(text);
	unicode_text = (Uint16 *)malloc((unicode_len+1)*(sizeof *unicode_text));
	if ( unicode_text == NULL ) {
		SDL_SetError("Out of memory");
		return -1;
	}
	ASCII_to_UNICODE(unicode_text, text, unicode_len);

	/* Render the new text */
	status = TTF_SizeUNICODE(font, unicode_text, w, h);

	/* Free the text buffer and return */
	free(unicode_text);
	return status;
}
Exemple #3
0
unsigned char*TTF_RenderText_Shaded(TTF_Font *font, const char *text, unsigned int fg, unsigned int bg)
{
        unsigned char *textbuf;
        unsigned short *unicode_text;
        int unicode_len;
    
        /* Copy the Latin-1 text to a UNICODE text buffer */
        unicode_len = strlen(text);
        unicode_text = (unsigned short *)malloc((unicode_len+1)*(sizeof
*unicode_text));
        if ( unicode_text == NULL ) {
                printf("Out of memory\n");
                return(NULL);
        }               
        ASCII_to_UNICODE(unicode_text, text, unicode_len);
    
        /* Render the new text */
        textbuf = TTF_RenderUNICODE_Shaded(font, unicode_text, fg, bg);
    
        /* Free the text buffer and return */
        free(unicode_text);
        return(textbuf);
}