Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
23335dea
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
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看板
提交
23335dea
编写于
2月 24, 2016
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ot-font] Accelerate cmap format4 get_glyph
上级
e0f16a71
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
77 addition
and
48 deletion
+77
-48
src/hb-ot-cmap-table.hh
src/hb-ot-cmap-table.hh
+64
-47
src/hb-ot-font.cc
src/hb-ot-font.cc
+13
-1
未找到文件。
src/hb-ot-cmap-table.hh
浏览文件 @
23335dea
...
...
@@ -69,61 +69,78 @@ struct CmapSubtableFormat0
struct
CmapSubtableFormat4
{
inline
bool
get_glyph
(
hb_codepoint_t
codepoint
,
hb_codepoint_t
*
glyph
)
cons
t
struct
accelerator_
t
{
unsigned
int
segCount
;
const
USHORT
*
endCount
;
const
USHORT
*
startCount
;
const
USHORT
*
idDelta
;
const
USHORT
*
idRangeOffset
;
const
USHORT
*
glyphIdArray
;
unsigned
int
glyphIdArrayLength
;
inline
void
init
(
const
CmapSubtableFormat4
*
subtable
)
{
segCount
=
subtable
->
segCountX2
/
2
;
endCount
=
subtable
->
values
;
startCount
=
endCount
+
segCount
+
1
;
idDelta
=
startCount
+
segCount
;
idRangeOffset
=
idDelta
+
segCount
;
glyphIdArray
=
idRangeOffset
+
segCount
;
glyphIdArrayLength
=
(
subtable
->
length
-
16
-
8
*
segCount
)
/
2
;
}
segCount
=
this
->
segCountX2
/
2
;
endCount
=
this
->
values
;
startCount
=
endCount
+
segCount
+
1
;
idDelta
=
startCount
+
segCount
;
idRangeOffset
=
idDelta
+
segCount
;
glyphIdArray
=
idRangeOffset
+
segCount
;
glyphIdArrayLength
=
(
this
->
length
-
16
-
8
*
segCount
)
/
2
;
/* Custom two-array bsearch. */
int
min
=
0
,
max
=
(
int
)
segCount
-
1
;
unsigned
int
i
;
while
(
min
<=
max
)
static
inline
bool
get_glyph_func
(
const
void
*
obj
,
hb_codepoint_t
codepoint
,
hb_codepoint_t
*
glyph
)
{
int
mid
=
(
min
+
max
)
/
2
;
if
(
codepoint
<
startCount
[
mid
])
max
=
mid
-
1
;
else
if
(
codepoint
>
endCount
[
mid
])
min
=
mid
+
1
;
const
accelerator_t
*
thiz
=
(
const
accelerator_t
*
)
obj
;
/* Custom two-array bsearch. */
int
min
=
0
,
max
=
(
int
)
thiz
->
segCount
-
1
;
const
USHORT
*
startCount
=
thiz
->
startCount
;
const
USHORT
*
endCount
=
thiz
->
endCount
;
unsigned
int
i
;
while
(
min
<=
max
)
{
int
mid
=
(
min
+
max
)
/
2
;
if
(
codepoint
<
startCount
[
mid
])
max
=
mid
-
1
;
else
if
(
codepoint
>
endCount
[
mid
])
min
=
mid
+
1
;
else
{
i
=
mid
;
goto
found
;
}
}
return
false
;
found:
hb_codepoint_t
gid
;
unsigned
int
rangeOffset
=
thiz
->
idRangeOffset
[
i
];
if
(
rangeOffset
==
0
)
gid
=
codepoint
+
thiz
->
idDelta
[
i
];
else
{
i
=
mid
;
goto
found
;
/* Somebody has been smoking... */
unsigned
int
index
=
rangeOffset
/
2
+
(
codepoint
-
thiz
->
startCount
[
i
])
+
i
-
thiz
->
segCount
;
if
(
unlikely
(
index
>=
thiz
->
glyphIdArrayLength
))
return
false
;
gid
=
thiz
->
glyphIdArray
[
index
];
if
(
unlikely
(
!
gid
))
return
false
;
gid
+=
thiz
->
idDelta
[
i
];
}
}
return
false
;
found:
hb_codepoint_t
gid
;
unsigned
int
rangeOffset
=
idRangeOffset
[
i
];
if
(
rangeOffset
==
0
)
gid
=
codepoint
+
idDelta
[
i
];
else
{
/* Somebody has been smoking... */
unsigned
int
index
=
rangeOffset
/
2
+
(
codepoint
-
startCount
[
i
])
+
i
-
segCount
;
if
(
unlikely
(
index
>=
glyphIdArrayLength
))
return
false
;
gid
=
glyphIdArray
[
index
];
if
(
unlikely
(
!
gid
))
return
false
;
gid
+=
idDelta
[
i
];
*
glyph
=
gid
&
0xFFFFu
;
return
true
;
}
*
glyph
=
gid
&
0xFFFFu
;
return
true
;
const
USHORT
*
endCount
;
const
USHORT
*
startCount
;
const
USHORT
*
idDelta
;
const
USHORT
*
idRangeOffset
;
const
USHORT
*
glyphIdArray
;
unsigned
int
segCount
;
unsigned
int
glyphIdArrayLength
;
};
inline
bool
get_glyph
(
hb_codepoint_t
codepoint
,
hb_codepoint_t
*
glyph
)
const
{
accelerator_t
accel
;
accel
.
init
(
this
);
return
accel
.
get_glyph_func
(
&
accel
,
codepoint
,
glyph
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
...
...
src/hb-ot-font.cc
浏览文件 @
23335dea
...
...
@@ -218,6 +218,7 @@ struct hb_ot_face_cmap_accelerator_t
{
hb_cmap_get_glyph_func_t
get_glyph_func
;
const
void
*
get_glyph_data
;
OT
::
CmapSubtableFormat4
::
accelerator_t
format4_accel
;
const
OT
::
CmapSubtableFormat14
*
uvs_table
;
hb_blob_t
*
blob
;
...
...
@@ -255,8 +256,19 @@ struct hb_ot_face_cmap_accelerator_t
this
->
uvs_table
=
subtable_uvs
;
this
->
get_glyph_func
=
get_glyph_from
<
OT
::
CmapSubtable
>
;
this
->
get_glyph_data
=
subtable
;
switch
(
subtable
->
u
.
format
)
{
/* Accelerate format 4 and format 12. */
default:
this
->
get_glyph_func
=
get_glyph_from
<
OT
::
CmapSubtable
>
;
break
;
case
12
:
this
->
get_glyph_func
=
get_glyph_from
<
OT
::
CmapSubtableFormat12
>
;
break
;
case
4
:
{
this
->
format4_accel
.
init
(
&
subtable
->
u
.
format4
);
this
->
get_glyph_data
=
&
this
->
format4_accel
;
this
->
get_glyph_func
=
this
->
format4_accel
.
get_glyph_func
;
}
break
;
}
}
inline
void
fini
(
void
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录