Street Fighter II/ModuleFont.cpp
void ModuleFont::BlitText(int x, int y, int font_id, const char* text) const
{
	if (text == nullptr || font_id < 0 || font_id >= MAX_FONTS || App->font->fonts[font_id].graphic == nullptr)
	{
		LOG("Unable to render text with bmp font id %d", font_id);
		return;
	}

	const Font* font = &App->font->fonts[font_id];
	SDL_Rect rect;
	uint len = strlen(text);

	rect.w = font->char_w;
	rect.h = font->char_h;

	for (int i = 0; i < len; i++)
	{
		bool foundCharacter = false;
		int j = 0;
		do
		{
			if (font->table[j] == text[i]) {
				rect.x = j * font->char_w;
				rect.y = 0;
				App->render->Blit(font->graphic, x, y, &rect, false);

				x += font->char_w;
				foundCharacter = true;
			}
			else
				j++;

		} while (!foundCharacter && j < font->len);
	}
}
// Render text using a bitmap font
Render text using a bitmap font
Render text using a bitmap font
void ModuleFont::BlitText(int x, int y, int font_id, const char* text) const
{
	if (text == nullptr || font_id < 0 || font_id >= MAX_FONTS || App->font->fonts[font_id].graphic == nullptr)
	{
		LOG("Unable to render text with bmp font id %d", font_id);
		return;
	}
	const Font* font = &App->font->fonts[font_id];
	SDL_Rect rect;
	uint len = strlen(text);
	rect.w = font->char_w;
	rect.h = font->char_h;
	for (int i = 0; i < len; i++)
	{
		bool foundCharacter = false;
		int j = 0;
		do
		{
			if (font->table[j] == text[i]) {
				rect.x = j * font->char_w;
				rect.y = 0;
				App->render->Blit(font->graphic, x, y, &rect, false);
				x += font->char_w;
				foundCharacter = true;
			}
			else
				j++;
		} while (!foundCharacter && j < font->len);
	}
}
void ModuleFont :: BlitText ( int x , int y , int font_id , const char * text ) const { if ( text == nullptr || font_id < 0 || font_id >= MAX_FONTS || App -> font -> fonts [ font_id ] . graphic == nullptr ) { LOG ( " " , font_id ) ; return ; } const Font * font = & App -> font -> fonts [ font_id ] ; SDL_Rect rect ; uint len = strlen ( text ) ; rect . w = font -> char_w ; rect . h = font -> char_h ; for ( int i = 0 ; i < len ; i ++ ) { bool foundCharacter = false ; int j = 0 ; do { if ( font -> table [ j ] == text [ i ] ) { rect . x = j * font -> char_w ; rect . y = 0 ; App -> render -> Blit ( font -> graphic , x , y , & rect , false ) ; x += font -> char_w ; foundCharacter = true ; } else j ++ ; } while ( ! foundCharacter && j < font -> len ) ; } }
Render text using a bitmap font
Render text using a bitmap font