Added defines to prevent symbol collision with stb

If you already have stb_rect_pack.h and stb_truetype.h inside your
project zahnrad will cause symbol collisions since it will import
the implementation a second time.

To prevent this from happening I added two defines which can be set
to 1 to disable the implementation generation of both stb_truetype.h
as well as stb_rect_pack.h in zahnrad.
This commit is contained in:
vurtun 2016-01-21 00:41:02 +01:00
parent c98153b59a
commit e015c447ec
2 changed files with 15 additions and 6 deletions

View File

@ -1309,11 +1309,11 @@ static zr_size
zr_use_font_glyph_clamp(const struct zr_user_font *font, const char *text,
zr_size text_len, float space, zr_size *glyphs, float *text_width)
{
zr_size len = 0;
zr_size glyph_len;
float width = 0;
zr_size glyph_len = 0;
float last_width = 0;
zr_rune unicode;
zr_rune unicode = 0;
float width = 0;
zr_size len = 0;
zr_size g = 0;
glyph_len = zr_utf_decode(text, &unicode, text_len);
@ -1321,6 +1321,7 @@ zr_use_font_glyph_clamp(const struct zr_user_font *font, const char *text,
zr_size s;
len += glyph_len;
s = font->width(font->userdata, font->height, text, len);
last_width = width;
width = (float)s;
glyph_len = zr_utf_decode(&text[len], &unicode, text_len - len);
@ -2893,13 +2894,13 @@ zr__draw_next(const struct zr_draw_command *cmd,
#pragma warning (disable: 4456)
#endif
#ifndef ZR_DISABLE_STB_RECT_PACK_IMPLEMENTATION
#if !ZR_DISABLE_STB_RECT_PACK_IMPLEMENTATION
#define STBRP_STATIC
#define STB_RECT_PACK_IMPLEMENTATION
#endif
#include "stb_rect_pack.h"
#ifndef ZR_DISABLE_STB_TRUETYPE_IMPLEMENTATION
#if !ZR_DISABLE_STB_TRUETYPE_IMPLEMENTATION
#define STBTT_STATIC
#define STB_TRUETYPE_IMPLEMENTATION
#endif

View File

@ -68,6 +68,14 @@ extern "C" {
If you already have font handling or do not want to use this font handler
you can just set this define to zero and the font module will not be compiled
and the two headers will not be needed. */
#define ZR_DISABLE_STB_RECT_PACK_IMPLEMENTATION 0
/* If you already provide the implementation for stb_rect_pack.h in one of your
files you have to define this as 1 to prevent another implementation and the
resulting symbol collision. */
#define ZR_DISABLE_STB_TRUETYPE_IMPLEMENTATION 0
/* If you already provide the implementation for stb_truetype.h in one of your
files you have to define this as 1 to prevent another implementation and the
resulting symbol collision. */
/*
* ===============================================================
*