Sfoglia il codice sorgente

Demonstrate how to render a single emojii

Luna Stadler 4 anni fa
parent
commit
0a9fad79b0
1 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 4 4
      c/sdl/hello_sdl.c

+ 4 - 4
c/sdl/hello_sdl.c

@ -1,7 +1,7 @@
1 1
#include <SDL.h>
2 2
#include <SDL_ttf.h>
3 3
4
char *font_file = "./FantasqueSansMono-Regular.ttf";
4
char *font_file = "./NotoColorEmoji.ttf";
5 5
6 6
int main(int argc, char *argv[]) {
7 7
	printf("hello, world!\n");
@ -41,12 +41,12 @@ int main(int argc, char *argv[]) {
41 41
42 42
	SDL_Surface *surface = SDL_GetWindowSurface(window);
43 43
44
	char *msg = "howdy there, enby! 🐘";
44
	char *msg = "🐘";
45 45
46 46
	// thanks to https://stackoverflow.com/questions/22886500/how-to-render-text-in-sdl2 for some actually useful code here
47
	SDL_Color white = {255, 255, 255};
47
	SDL_Color white = {255, 255, 255, 255};
48 48
	SDL_Color black = {0, 0, 0};
49
	SDL_Surface* text = TTF_RenderUTF8_Blended(font, msg, white);
49
	SDL_Surface* text = TTF_RenderUTF8_Shaded(font, msg, white, black);
50 50
	SDL_BlitSurface(text, NULL, surface, NULL);
51 51
52 52
	// monospace -> fixed width (duh)