diff --git a/Makefile.am b/Makefile.am index 00b74f714b..ec4074f0e9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -149,6 +149,10 @@ if HAVE_PNG CORE_CFLAGS += -DSWITCH_HAVE_PNG $(LIBPNG_CFLAGS) endif +if HAVE_FREETYPE +CORE_CFLAGS += -DSWITCH_HAVE_FREETYPE $(LIBFREETYPE_CFLAGS) +endif + ## ## libfreeswitch ## diff --git a/configure.ac b/configure.ac index 2338798cf6..296ef27c81 100644 --- a/configure.ac +++ b/configure.ac @@ -1205,7 +1205,9 @@ PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.6.16],[ PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.2.49],[ AM_CONDITIONAL([HAVE_PNG],[true])],[ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_PNG],[false])])])]) -PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.4.9]) +PKG_CHECK_MODULES([FREETYPE], [freetype2 >= 2.4.9],[ + AM_CONDITIONAL([HAVE_FREETYPE],[true])],[ + AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_FREETYPE],[false])]) PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.6.20]) PKG_CHECK_MODULES([CURL], [libcurl >= 7.19]) PKG_CHECK_MODULES([PCRE], [libpcre >= 7.8]) diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 487324783e..ed9b918fe0 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -419,15 +419,19 @@ SWITCH_DECLARE(void) switch_color_set_yuv(switch_yuv_color_t *color, const char switch_color_rgb2yuv(&rgb, color); } +#if SWITCH_HAVE_FREETYPE #include #include FT_FREETYPE_H #include FT_GLYPH_H +#endif #define MAX_GRADIENT 8 struct switch_img_txt_handle_s { +#if SWITCH_HAVE_FREETYPE FT_Library library; FT_Face face; +#endif char *font_family; double angle; uint16_t font_size; @@ -470,9 +474,13 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_create(switch_img_txt_hand new_handle = switch_core_alloc(pool, sizeof(*new_handle)); +#if SWITCH_HAVE_FREETYPE if (FT_Init_FreeType(&new_handle->library)) { return SWITCH_STATUS_FALSE; } +#else + return SWITCH_STATUS_FALSE; +#endif new_handle->pool = pool; new_handle->free_pool = free_pool; @@ -498,11 +506,12 @@ SWITCH_DECLARE(void) switch_img_txt_handle_destroy(switch_img_txt_handle_t **han *handleP = NULL; +#if SWITCH_HAVE_FREETYPE if (old_handle->library) { FT_Done_FreeType(old_handle->library); old_handle->library = NULL; } - +#endif pool = old_handle->pool; if (old_handle->free_pool) { @@ -513,6 +522,7 @@ SWITCH_DECLARE(void) switch_img_txt_handle_destroy(switch_img_txt_handle_t **han } +#if SWITCH_HAVE_FREETYPE static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT_Bitmap* bitmap, FT_Int x, FT_Int y) { FT_Int i, j, p, q; @@ -569,12 +579,14 @@ static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT } } } +#endif SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_handle_t *handle, switch_image_t *img, int x, int y, const char *text, const char *font_family, const char *font_color, const char *bgcolor, uint16_t font_size, double angle) { +#if SWITCH_HAVE_FREETYPE FT_GlyphSlot slot; FT_Matrix matrix; /* transformation matrix */ FT_Vector pen; /* untransformed origin */ @@ -667,6 +679,9 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand FT_Done_Face(face); return SWITCH_STATUS_SUCCESS; +#else + return SWITCH_STATUS_FALSE; +#endif }