Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
f6496663
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6496663
编写于
9月 19, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[util] If no text is provided, simply call cairo_show_glyphs()
上级
5c299343
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
41 deletion
+51
-41
util/view-cairo.cc
util/view-cairo.cc
+51
-41
未找到文件。
util/view-cairo.cc
浏览文件 @
f6496663
...
...
@@ -94,13 +94,19 @@ view_cairo_t::consume_line (hb_buffer_t *buffer,
hb_glyph_info_t
*
hb_glyph
=
hb_buffer_get_glyph_infos
(
buffer
,
NULL
);
hb_glyph_position_t
*
hb_position
=
hb_buffer_get_glyph_positions
(
buffer
,
NULL
);
l
.
glyphs
=
cairo_glyph_allocate
(
l
.
num_glyphs
+
1
);
l
.
utf8
=
g_strndup
(
text
,
text_len
);
l
.
utf8_len
=
text_len
;
l
.
num_clusters
=
l
.
num_glyphs
?
1
:
0
;
for
(
unsigned
int
i
=
1
;
i
<
l
.
num_glyphs
;
i
++
)
if
(
hb_glyph
[
i
].
cluster
!=
hb_glyph
[
i
-
1
].
cluster
)
l
.
num_clusters
++
;
l
.
clusters
=
cairo_text_cluster_allocate
(
l
.
num_clusters
);
if
(
text
)
{
l
.
utf8
=
g_strndup
(
text
,
text_len
);
l
.
utf8_len
=
text_len
;
l
.
num_clusters
=
l
.
num_glyphs
?
1
:
0
;
for
(
unsigned
int
i
=
1
;
i
<
l
.
num_glyphs
;
i
++
)
if
(
hb_glyph
[
i
].
cluster
!=
hb_glyph
[
i
-
1
].
cluster
)
l
.
num_clusters
++
;
l
.
clusters
=
cairo_text_cluster_allocate
(
l
.
num_clusters
);
}
else
{
l
.
utf8_len
=
0
;
l
.
num_clusters
=
0
;
}
if
((
l
.
num_glyphs
&&
!
l
.
glyphs
)
||
(
l
.
utf8_len
&&
!
l
.
utf8
)
||
...
...
@@ -113,46 +119,48 @@ view_cairo_t::consume_line (hb_buffer_t *buffer,
hb_position_t
x
=
0
,
y
=
0
;
int
i
;
for
(
i
=
0
;
i
<
(
int
)
l
.
num_glyphs
;
i
++
)
{
l
.
glyphs
[
i
].
index
=
hb_glyph
[
i
].
codepoint
;
l
.
glyphs
[
i
].
x
=
(
hb_position
->
x_offset
+
x
)
*
scale
;
l
.
glyphs
[
i
].
y
=
(
-
hb_position
->
y_offset
+
y
)
*
scale
;
x
+=
hb_position
->
x_advance
;
y
+=
-
hb_position
->
y_advance
;
hb_position
++
;
}
{
l
.
glyphs
[
i
].
index
=
hb_glyph
[
i
].
codepoint
;
l
.
glyphs
[
i
].
x
=
(
hb_position
->
x_offset
+
x
)
*
scale
;
l
.
glyphs
[
i
].
y
=
(
-
hb_position
->
y_offset
+
y
)
*
scale
;
x
+=
hb_position
->
x_advance
;
y
+=
-
hb_position
->
y_advance
;
hb_position
++
;
}
l
.
glyphs
[
i
].
index
=
0
;
l
.
glyphs
[
i
].
x
=
x
;
l
.
glyphs
[
i
].
y
=
y
;
memset
((
void
*
)
l
.
clusters
,
0
,
l
.
num_clusters
*
sizeof
(
l
.
clusters
[
0
]));
bool
backward
=
HB_DIRECTION_IS_BACKWARD
(
hb_buffer_get_direction
(
buffer
));
l
.
cluster_flags
=
backward
?
CAIRO_TEXT_CLUSTER_FLAG_BACKWARD
:
(
cairo_text_cluster_flags_t
)
0
;
unsigned
int
cluster
=
0
;
if
(
!
l
.
num_glyphs
)
goto
done
;
l
.
clusters
[
cluster
].
num_glyphs
++
;
if
(
backward
)
{
for
(
i
=
l
.
num_glyphs
-
2
;
i
>=
0
;
i
--
)
{
if
(
hb_glyph
[
i
].
cluster
!=
hb_glyph
[
i
+
1
].
cluster
)
{
g_assert
(
hb_glyph
[
i
].
cluster
>
hb_glyph
[
i
+
1
].
cluster
);
l
.
clusters
[
cluster
].
num_bytes
+=
hb_glyph
[
i
].
cluster
-
hb_glyph
[
i
+
1
].
cluster
;
cluster
++
;
if
(
l
.
num_clusters
)
{
memset
((
void
*
)
l
.
clusters
,
0
,
l
.
num_clusters
*
sizeof
(
l
.
clusters
[
0
]));
bool
backward
=
HB_DIRECTION_IS_BACKWARD
(
hb_buffer_get_direction
(
buffer
));
l
.
cluster_flags
=
backward
?
CAIRO_TEXT_CLUSTER_FLAG_BACKWARD
:
(
cairo_text_cluster_flags_t
)
0
;
unsigned
int
cluster
=
0
;
if
(
!
l
.
num_glyphs
)
goto
done
;
l
.
clusters
[
cluster
].
num_glyphs
++
;
if
(
backward
)
{
for
(
i
=
l
.
num_glyphs
-
2
;
i
>=
0
;
i
--
)
{
if
(
hb_glyph
[
i
].
cluster
!=
hb_glyph
[
i
+
1
].
cluster
)
{
g_assert
(
hb_glyph
[
i
].
cluster
>
hb_glyph
[
i
+
1
].
cluster
);
l
.
clusters
[
cluster
].
num_bytes
+=
hb_glyph
[
i
].
cluster
-
hb_glyph
[
i
+
1
].
cluster
;
cluster
++
;
}
l
.
clusters
[
cluster
].
num_glyphs
++
;
}
l
.
clusters
[
cluster
].
num_
glyphs
++
;
}
l
.
clusters
[
cluster
].
num_bytes
+=
text_len
-
hb_glyph
[
0
].
cluster
;
}
else
{
for
(
i
=
1
;
i
<
(
int
)
l
.
num_glyphs
;
i
++
)
{
if
(
hb_glyph
[
i
].
cluster
!=
hb_glyph
[
i
-
1
].
cluster
)
{
g_assert
(
hb_glyph
[
i
].
cluster
>
hb_glyph
[
i
-
1
].
cluster
)
;
l
.
clusters
[
cluster
].
num_bytes
+=
hb_glyph
[
i
].
cluster
-
hb_glyph
[
i
-
1
].
cluster
;
cluster
++
;
l
.
clusters
[
cluster
].
num_
bytes
+=
text_len
-
hb_glyph
[
0
].
cluster
;
}
else
{
for
(
i
=
1
;
i
<
(
int
)
l
.
num_glyphs
;
i
++
)
{
if
(
hb_glyph
[
i
].
cluster
!=
hb_glyph
[
i
-
1
].
cluster
)
{
g_assert
(
hb_glyph
[
i
].
cluster
>
hb_glyph
[
i
-
1
].
cluster
);
l
.
clusters
[
cluster
].
num_bytes
+=
hb_glyph
[
i
].
cluster
-
hb_glyph
[
i
-
1
].
cluster
;
cluster
++
;
}
l
.
clusters
[
cluster
].
num_glyphs
++
;
}
l
.
clusters
[
cluster
].
num_
glyphs
++
;
l
.
clusters
[
cluster
].
num_
bytes
+=
text_len
-
hb_glyph
[
i
-
1
].
cluster
;
}
l
.
clusters
[
cluster
].
num_bytes
+=
text_len
-
hb_glyph
[
i
-
1
].
cluster
;
}
done:
...
...
@@ -476,12 +484,14 @@ view_cairo_t::draw (cairo_t *cr)
/* cairo_show_glyphs() doesn't support subpixel positioning */
cairo_glyph_path
(
cr
,
l
.
glyphs
,
l
.
num_glyphs
);
cairo_fill
(
cr
);
}
else
}
else
if
(
l
.
num_clusters
)
cairo_show_text_glyphs
(
cr
,
l
.
utf8
,
l
.
utf8_len
,
l
.
glyphs
,
l
.
num_glyphs
,
l
.
clusters
,
l
.
num_clusters
,
l
.
cluster_flags
);
else
cairo_show_glyphs
(
cr
,
l
.
glyphs
,
l
.
num_glyphs
);
cairo_translate
(
cr
,
0
,
font_extents
.
height
-
font_extents
.
ascent
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录