Browse Source

Added ability to use user fonts after initialization in allegro5 backend

Andrew Kravchuk 5 years ago
parent
commit
74db09cdab
1 changed files with 11 additions and 0 deletions
  1. 11 0
      demo/allegro5/nuklear_allegro5.h

+ 11 - 0
demo/allegro5/nuklear_allegro5.h

@@ -33,6 +33,7 @@ NK_API void                   nk_allegro5_del_image(struct nk_image* image);
 /* Fonts. We wrap normal allegro fonts in some nuklear book keeping */
 NK_API NkAllegro5Font*        nk_allegro5_font_create_from_file(const char *file_name, int font_size, int flags);
 NK_API void                   nk_allegro5_font_del(NkAllegro5Font *font);
+NK_API struct nk_user_font*   nk_allegro5_font(NkAllegro5Font *allegro5font);
 NK_API void                   nk_allegro5_font_set_font(NkAllegro5Font *font);
 
 #endif
@@ -138,6 +139,16 @@ nk_allegro5_font_get_text_width(nk_handle handle, float height, const char *text
     return al_get_text_width(font->font, strcpy);
 }
 
+NK_API struct nk_user_font*
+nk_allegro5_font(NkAllegro5Font *allegro5font)
+{
+    struct nk_user_font *font = &allegro5font->nk;
+    font->userdata = nk_handle_ptr(allegro5font);
+    font->height = (float)allegro5font->height;
+    font->width = nk_allegro5_font_get_text_width;
+    return font;
+}
+
 NK_API void
 nk_allegro5_font_set_font(NkAllegro5Font *allegro5font)
 {