comparison nuklear_ui/blastem_nuklear.c @ 1527:4f6e8acd7b6a nuklear_ui

Added support for TTC and dfont format true type fonts. More robust font selection on Windows
author Michael Pavone <pavone@retrodev.com>
date Tue, 06 Mar 2018 21:27:12 -0800
parents 9bea1a199f15
children 3faf917bab56
comparison
equal deleted inserted replaced
1526:9bea1a199f15 1527:4f6e8acd7b6a
900 static void context_created(void) 900 static void context_created(void)
901 { 901 {
902 nk_sdl_device_create(); 902 nk_sdl_device_create();
903 struct nk_font_atlas *atlas; 903 struct nk_font_atlas *atlas;
904 nk_sdl_font_stash_begin(&atlas); 904 nk_sdl_font_stash_begin(&atlas);
905 char *font = default_font_path(); 905 uint32_t font_size;
906 uint8_t *font = default_font(&font_size);
906 if (!font) { 907 if (!font) {
907 fatal_error("Failed to find default font path\n"); 908 fatal_error("Failed to find default font path\n");
908 } 909 }
909 struct nk_font *def_font = nk_font_atlas_add_from_file(atlas, font, 30, NULL); 910 struct nk_font *def_font = nk_font_atlas_add_from_memory(atlas, font, font_size, 30, NULL);
910 nk_sdl_font_stash_end(); 911 nk_sdl_font_stash_end();
911 nk_style_set_font(context, &def_font->handle); 912 nk_style_set_font(context, &def_font->handle);
912 } 913 }
913 914
914 void show_pause_menu(void) 915 void show_pause_menu(void)
942 { 943 {
943 context = nk_sdl_init(render_get_window()); 944 context = nk_sdl_init(render_get_window());
944 945
945 struct nk_font_atlas *atlas; 946 struct nk_font_atlas *atlas;
946 nk_sdl_font_stash_begin(&atlas); 947 nk_sdl_font_stash_begin(&atlas);
947 char *font = default_font_path(); 948 //char *font = default_font_path();
949 uint32_t font_size;
950 uint8_t *font = default_font(&font_size);
948 if (!font) { 951 if (!font) {
949 fatal_error("Failed to find default font path\n"); 952 fatal_error("Failed to find default font path\n");
950 } 953 }
951 struct nk_font *def_font = nk_font_atlas_add_from_file(atlas, font, 30, NULL); 954 //struct nk_font *def_font = nk_font_atlas_add_from_file(atlas, font, 30, NULL);
955 struct nk_font *def_font = nk_font_atlas_add_from_memory(atlas, font, font_size, 30, NULL);
952 nk_sdl_font_stash_end(); 956 nk_sdl_font_stash_end();
953 nk_style_set_font(context, &def_font->handle); 957 nk_style_set_font(context, &def_font->handle);
954 current_view = file_loaded ? view_play : view_menu; 958 current_view = file_loaded ? view_play : view_menu;
955 render_set_ui_render_fun(blastem_nuklear_render); 959 render_set_ui_render_fun(blastem_nuklear_render);
956 render_set_event_handler(handle_event); 960 render_set_event_handler(handle_event);