Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
8c7481b5
提交
8c7481b5
authored
2月 10, 2015
作者:
Seven Du
提交者:
Anthony Minessale
5月 27, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7506: utf8 support of draw text
上级
20761800
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
582 行增加
和
7 行删除
+582
-7
Makefile.am
src/mod/applications/mod_conference/Makefile.am
+3
-3
mod_conference.c
src/mod/applications/mod_conference/mod_conference.c
+31
-4
utf8.c
src/mod/applications/mod_conference/utf8.c
+477
-0
utf8.h
src/mod/applications/mod_conference/utf8.h
+71
-0
没有找到文件。
src/mod/applications/mod_conference/Makefile.am
浏览文件 @
8c7481b5
...
@@ -2,10 +2,10 @@ include $(top_srcdir)/build/modmake.rulesam
...
@@ -2,10 +2,10 @@ include $(top_srcdir)/build/modmake.rulesam
MODNAME
=
mod_conference
MODNAME
=
mod_conference
mod_LTLIBRARIES
=
mod_conference.la
mod_LTLIBRARIES
=
mod_conference.la
mod_conference_la_SOURCES
=
mod_conference.c
mod_conference_la_SOURCES
=
mod_conference.c
utf8.c
mod_conference_la_CFLAGS
=
$(AM_CFLAGS)
mod_conference_la_CFLAGS
=
$(AM_CFLAGS)
-I
.
-I
/usr/include/freetype2
mod_conference_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
mod_conference_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
mod_conference_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
-lyuv
mod_conference_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
-lyuv
-lfreetype
if
HAVE_OPENAL
if
HAVE_OPENAL
mod_conference_la_LDFLAGS
+=
-lopenal
-lm
mod_conference_la_LDFLAGS
+=
-lopenal
-lm
...
...
src/mod/applications/mod_conference/mod_conference.c
浏览文件 @
8c7481b5
...
@@ -701,6 +701,31 @@ typedef struct layout_group_s {
...
@@ -701,6 +701,31 @@ typedef struct layout_group_s {
video_layout_node_t *layouts;
video_layout_node_t *layouts;
} layout_group_t;
} layout_group_t;
#include "utf8.h"
static const u_int32_t offsetsFromUTF8[6] = {
0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL
};
/* reads the next utf-8 sequence out of a string, updating an index */
uint32_t get_utf8_char(char *s, int *i)
{
u_int32_t ch = 0;
int sz = 0;
do {
ch <<= 6;
ch += (unsigned char)s[(*i)++];
sz++;
} while (s[*i] && !isutf(s[*i]));
ch -= offsetsFromUTF8[sz-1];
return ch;
}
#include <ft2build.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_GLYPH_H
...
@@ -735,13 +760,13 @@ SWITCH_DECLARE(void) switch_img_draw_text(switch_image_t *img, int x, int y, cha
...
@@ -735,13 +760,13 @@ SWITCH_DECLARE(void) switch_img_draw_text(switch_image_t *img, int x, int y, cha
int font_size = 64;
int font_size = 64;
double angle;
double angle;
int target_height;
int target_height;
int n, num_chars;
int index = 0;
FT_ULong ch;
switch_yuv_color_t color;
switch_yuv_color_t color;
if (zstr(text)) return;
if (zstr(text)) return;
switch_color_set(&color, "#FFFFFF");
switch_color_set(&color, "#FFFFFF");
num_chars = strlen(text);
angle = 0; // (45.0 / 360 ) * 3.14159 * 2;
angle = 0; // (45.0 / 360 ) * 3.14159 * 2;
target_height = img->d_h;
target_height = img->d_h;
...
@@ -768,12 +793,14 @@ SWITCH_DECLARE(void) switch_img_draw_text(switch_image_t *img, int x, int y, cha
...
@@ -768,12 +793,14 @@ SWITCH_DECLARE(void) switch_img_draw_text(switch_image_t *img, int x, int y, cha
pen.x = x * 64;
pen.x = x * 64;
pen.y = (target_height - y) * 64;
pen.y = (target_height - y) * 64;
for(n = 0; n < num_chars; n++) {
while(*(text + index)) {
ch = get_utf8_char(text, &index);
/* set transformation */
/* set transformation */
FT_Set_Transform(face, &matrix, &pen);
FT_Set_Transform(face, &matrix, &pen);
/* load glyph image into the slot (erase previous one) */
/* load glyph image into the slot (erase previous one) */
error = FT_Load_Char(face,
text[n]
, FT_LOAD_RENDER);
error = FT_Load_Char(face,
ch
, FT_LOAD_RENDER);
if (error) continue;
if (error) continue;
/* now, draw to our target surface (convert position) */
/* now, draw to our target surface (convert position) */
...
...
src/mod/applications/mod_conference/utf8.c
0 → 100644
浏览文件 @
8c7481b5
差异被折叠。
点击展开。
src/mod/applications/mod_conference/utf8.h
0 → 100644
浏览文件 @
8c7481b5
#include <stdarg.h>
/* is c the start of a utf8 sequence? */
#define isutf(c) (((c)&0xC0)!=0x80)
/* convert UTF-8 data to wide character */
int
u8_toucs
(
uint32_t
*
dest
,
int
sz
,
char
*
src
,
int
srcsz
);
/* the opposite conversion */
int
u8_toutf8
(
char
*
dest
,
int
sz
,
uint32_t
*
src
,
int
srcsz
);
/* single character to UTF-8 */
int
u8_wc_toutf8
(
char
*
dest
,
uint32_t
ch
);
/* character number to byte offset */
int
u8_offset
(
char
*
str
,
int
charnum
);
/* byte offset to character number */
int
u8_charnum
(
char
*
s
,
int
offset
);
/* return next character, updating an index variable */
uint32_t
u8_nextchar
(
char
*
s
,
int
*
i
);
/* move to next character */
void
u8_inc
(
char
*
s
,
int
*
i
);
/* move to previous character */
void
u8_dec
(
char
*
s
,
int
*
i
);
/* returns length of next utf-8 sequence */
int
u8_seqlen
(
char
*
s
);
/* assuming src points to the character after a backslash, read an
escape sequence, storing the result in dest and returning the number of
input characters processed */
int
u8_read_escape_sequence
(
char
*
src
,
uint32_t
*
dest
);
/* given a wide character, convert it to an ASCII escape sequence stored in
buf, where buf is "sz" bytes. returns the number of characters output.*/
int
u8_escape_wchar
(
char
*
buf
,
int
sz
,
uint32_t
ch
);
/* convert a string "src" containing escape sequences to UTF-8 */
int
u8_unescape
(
char
*
buf
,
int
sz
,
char
*
src
);
/* convert UTF-8 "src" to ASCII with escape sequences.
if escape_quotes is nonzero, quote characters will be preceded by
backslashes as well. */
int
u8_escape
(
char
*
buf
,
int
sz
,
char
*
src
,
int
escape_quotes
);
/* utility predicates used by the above */
int
octal_digit
(
char
c
);
int
hex_digit
(
char
c
);
/* return a pointer to the first occurrence of ch in s, or NULL if not
found. character index of found character returned in *charn. */
char
*
u8_strchr
(
char
*
s
,
uint32_t
ch
,
int
*
charn
);
/* same as the above, but searches a buffer of a given size instead of
a NUL-terminated string. */
char
*
u8_memchr
(
char
*
s
,
uint32_t
ch
,
size_t
sz
,
int
*
charn
);
/* count the number of characters in a UTF-8 string */
int
u8_strlen
(
char
*
s
);
int
u8_is_locale_utf8
(
char
*
locale
);
/* printf where the format string and arguments may be in UTF-8.
you can avoid this function and just use ordinary printf() if the current
locale is UTF-8. */
int
u8_vprintf
(
char
*
fmt
,
va_list
ap
);
int
u8_printf
(
char
*
fmt
,
...);
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论