提交 c07513ea authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Michael Jerris

FS-7506: make freetype optional

上级 83b72513
...@@ -149,6 +149,10 @@ if HAVE_PNG ...@@ -149,6 +149,10 @@ if HAVE_PNG
CORE_CFLAGS += -DSWITCH_HAVE_PNG $(LIBPNG_CFLAGS) CORE_CFLAGS += -DSWITCH_HAVE_PNG $(LIBPNG_CFLAGS)
endif endif
if HAVE_FREETYPE
CORE_CFLAGS += -DSWITCH_HAVE_FREETYPE $(LIBFREETYPE_CFLAGS)
endif
## ##
## libfreeswitch ## libfreeswitch
## ##
......
...@@ -1205,7 +1205,9 @@ PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.6.16],[ ...@@ -1205,7 +1205,9 @@ PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.6.16],[
PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.2.49],[ PKG_CHECK_MODULES([LIBPNG], [libpng >= 1.2.49],[
AM_CONDITIONAL([HAVE_PNG],[true])],[ AM_CONDITIONAL([HAVE_PNG],[true])],[
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_PNG],[false])])])]) 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([SQLITE], [sqlite3 >= 3.6.20])
PKG_CHECK_MODULES([CURL], [libcurl >= 7.19]) PKG_CHECK_MODULES([CURL], [libcurl >= 7.19])
PKG_CHECK_MODULES([PCRE], [libpcre >= 7.8]) PKG_CHECK_MODULES([PCRE], [libpcre >= 7.8])
......
...@@ -419,15 +419,19 @@ SWITCH_DECLARE(void) switch_color_set_yuv(switch_yuv_color_t *color, const char ...@@ -419,15 +419,19 @@ SWITCH_DECLARE(void) switch_color_set_yuv(switch_yuv_color_t *color, const char
switch_color_rgb2yuv(&rgb, color); switch_color_rgb2yuv(&rgb, color);
} }
#if SWITCH_HAVE_FREETYPE
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_GLYPH_H #include FT_GLYPH_H
#endif
#define MAX_GRADIENT 8 #define MAX_GRADIENT 8
struct switch_img_txt_handle_s { struct switch_img_txt_handle_s {
#if SWITCH_HAVE_FREETYPE
FT_Library library; FT_Library library;
FT_Face face; FT_Face face;
#endif
char *font_family; char *font_family;
double angle; double angle;
uint16_t font_size; uint16_t font_size;
...@@ -470,9 +474,13 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_create(switch_img_txt_hand ...@@ -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)); new_handle = switch_core_alloc(pool, sizeof(*new_handle));
#if SWITCH_HAVE_FREETYPE
if (FT_Init_FreeType(&new_handle->library)) { if (FT_Init_FreeType(&new_handle->library)) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
#else
return SWITCH_STATUS_FALSE;
#endif
new_handle->pool = pool; new_handle->pool = pool;
new_handle->free_pool = free_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 ...@@ -498,11 +506,12 @@ SWITCH_DECLARE(void) switch_img_txt_handle_destroy(switch_img_txt_handle_t **han
*handleP = NULL; *handleP = NULL;
#if SWITCH_HAVE_FREETYPE
if (old_handle->library) { if (old_handle->library) {
FT_Done_FreeType(old_handle->library); FT_Done_FreeType(old_handle->library);
old_handle->library = NULL; old_handle->library = NULL;
} }
#endif
pool = old_handle->pool; pool = old_handle->pool;
if (old_handle->free_pool) { if (old_handle->free_pool) {
...@@ -513,6 +522,7 @@ SWITCH_DECLARE(void) switch_img_txt_handle_destroy(switch_img_txt_handle_t **han ...@@ -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) 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; 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 ...@@ -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, 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, int x, int y, const char *text,
const char *font_family, const char *font_color, const char *bgcolor, uint16_t font_size, double angle) 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_GlyphSlot slot;
FT_Matrix matrix; /* transformation matrix */ FT_Matrix matrix; /* transformation matrix */
FT_Vector pen; /* untransformed origin */ FT_Vector pen; /* untransformed origin */
...@@ -667,6 +679,9 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand ...@@ -667,6 +679,9 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand
FT_Done_Face(face); FT_Done_Face(face);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
#else
return SWITCH_STATUS_FALSE;
#endif
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论