From 37ff8cb66f88304eda68738722e78a4fcb4b081c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 5 Nov 2016 20:45:23 +0100 Subject: [PATCH] Prevent stb_truetype from being included twice for Griffin --- Makefile.common | 1 + gfx/drivers_font_renderer/stb.c | 2 ++ gfx/drivers_font_renderer/stb_unicode.c | 5 ++--- griffin/griffin.c | 3 --- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile.common b/Makefile.common index d3e619c33b..fae29bd26c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -553,6 +553,7 @@ endif ifeq ($(HAVE_STB_FONT), 1) OBJ += gfx/drivers_font_renderer/stb.o + OBJ += gfx/drivers_font_renderer/stb_unicode.o endif ifeq ($(HAVE_FREETYPE), 1) diff --git a/gfx/drivers_font_renderer/stb.c b/gfx/drivers_font_renderer/stb.c index 5ddc0795df..87d3ff4748 100644 --- a/gfx/drivers_font_renderer/stb.c +++ b/gfx/drivers_font_renderer/stb.c @@ -23,6 +23,7 @@ #include "../font_driver.h" #include "../../verbosity.h" +#ifndef STB_TRUETYPE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION #define STBTT_STATIC @@ -30,6 +31,7 @@ #include "../../deps/stb/stb_rect_pack.h" #include "../../deps/stb/stb_truetype.h" #undef static +#endif typedef struct { diff --git a/gfx/drivers_font_renderer/stb_unicode.c b/gfx/drivers_font_renderer/stb_unicode.c index 2a51da7f17..7f834f5cc4 100644 --- a/gfx/drivers_font_renderer/stb_unicode.c +++ b/gfx/drivers_font_renderer/stb_unicode.c @@ -23,6 +23,7 @@ #include "../font_driver.h" #include "../../verbosity.h" +#ifndef STB_TRUETYPE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION #define STBRP_STATIC @@ -31,6 +32,7 @@ #include "../../deps/stb/stb_rect_pack.h" #include "../../deps/stb/stb_truetype.h" #undef static +#endif typedef struct { @@ -118,8 +120,6 @@ static uint32_t font_renderer_stb_unicode_update_atlas(stb_unicode_font_renderer glyph->draw_offset_y = - y1 * self->scale_factor; glyph->width = self->max_glyph_width; glyph->height = self->max_glyph_height; -// glyph->width = (x1 + x0 ) * self->scale_factor; -// glyph->height = (y1 - y0 ) * self->scale_factor; return id; } @@ -203,7 +203,6 @@ static void *font_renderer_stb_unicode_init(const char *font_path, float font_si else self->scale_factor = stbtt_ScaleForPixelHeight(&self->info, font_size); -// self->line_height = (ascent - descent + line_gap) * self->scale_factor; self->line_height = (ascent - descent) * self->scale_factor; if (!font_renderer_stb_unicode_create_atlas(self, font_size)) diff --git a/griffin/griffin.c b/griffin/griffin.c index 98cae85017..ebf9c1d116 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -354,12 +354,9 @@ FONTS #include "../gfx/font_driver.c" #if defined(HAVE_STB_FONT) -#if defined(VITA) || defined(ANDROID) || defined(_WIN32) && !defined(_XBOX) #include "../gfx/drivers_font_renderer/stb_unicode.c" -#else #include "../gfx/drivers_font_renderer/stb.c" #endif -#endif #if defined(HAVE_FREETYPE) #include "../gfx/drivers_font_renderer/freetype.c"