correctly render utf

Was using the wrong API. Also upgraded font to DejaVu Sans
This commit is contained in:
Eric House 2021-03-06 19:21:23 -08:00
parent f0d8a71deb
commit 430b6894f0
3 changed files with 3 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View file

@ -100,7 +100,7 @@ fontFor( WasmDrawCtx* wdctx, int height )
wdctx->fonts = rec;
rec->size = height;
rec->font = TTF_OpenFont( "assets_dir/FreeSans.ttf", height );
rec->font = TTF_OpenFont( "assets_dir/DejaVuSansCondensed.ttf", height );
result = rec->font;
}
@ -180,7 +180,7 @@ measureText( WasmDrawCtx* wdctx, const XP_UCHAR* text, int fontHeight,
{
SDL_Color black = { 0, 0, 0, 255 };
TTF_Font* font = fontFor( wdctx, fontHeight );
SDL_Surface* surface = TTF_RenderText_Blended( font, text, black );
SDL_Surface* surface = TTF_RenderUTF8_Blended( font, text, black );
SDL_Texture* texture = SDL_CreateTextureFromSurface( wdctx->renderer,
surface );
SDL_QueryTexture( texture, NULL, NULL, widthP, heightP );
@ -201,7 +201,7 @@ textInRect( WasmDrawCtx* wdctx, const XP_UCHAR* text, const XP_Rect* rect,
if ( NULL == color ) {
color = &black;
}
SDL_Surface* surface = TTF_RenderText_Blended( font, text, *color );
SDL_Surface* surface = TTF_RenderUTF8_Blended( font, text, *color );
SDL_Texture* texture = SDL_CreateTextureFromSurface( wdctx->renderer, surface );
SDL_FreeSurface( surface );