Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
e35a763c
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
12 个月 前同步成功
通知
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e35a763c
编写于
10月 30, 2017
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[post] Implement glyph_from_name()
This concludes
https://github.com/behdad/harfbuzz/pull/568
上级
6c738f35
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
96 addition
and
35 deletion
+96
-35
src/hb-ot-post-table.hh
src/hb-ot-post-table.hh
+90
-29
src/hb-private.hh
src/hb-private.hh
+5
-5
src/hb-sort-r.hh
src/hb-sort-r.hh
+1
-1
未找到文件。
src/hb-ot-post-table.hh
浏览文件 @
e35a763c
...
...
@@ -108,9 +108,97 @@ struct post
inline
void
fini
(
void
)
{
index_to_offset
.
finish
();
free
(
gids_sorted_by_name
);
}
inline
hb_string_t
_find_glyph_name
(
hb_codepoint_t
glyph
)
const
inline
bool
get_glyph_name
(
hb_codepoint_t
glyph
,
char
*
buf
,
unsigned
int
buf_len
)
const
{
hb_string_t
s
=
find_glyph_name
(
glyph
);
if
(
!
s
.
len
)
return
false
;
if
(
!
buf_len
)
return
true
;
if
(
buf_len
<=
s
.
len
)
/* What to do with truncation? Returning false for now. */
return
false
;
strncpy
(
buf
,
s
.
bytes
,
s
.
len
);
buf
[
s
.
len
]
=
'\0'
;
return
true
;
}
inline
bool
get_glyph_from_name
(
const
char
*
name
,
int
len
,
hb_codepoint_t
*
glyph
)
const
{
unsigned
int
count
=
get_glyph_count
();
if
(
unlikely
(
!
count
))
return
false
;
if
(
len
<
0
)
len
=
strlen
(
name
);
if
(
unlikely
(
!
len
))
return
false
;
retry:
uint16_t
*
gids
=
(
uint16_t
*
)
hb_atomic_ptr_get
(
&
gids_sorted_by_name
);
if
(
unlikely
(
!
gids
))
{
gids
=
(
uint16_t
*
)
malloc
(
count
*
sizeof
(
gids
[
0
]));
if
(
unlikely
(
!
gids
))
return
false
;
/* Anything better?! */
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
gids
[
i
]
=
i
;
hb_sort_r
(
gids
,
count
,
sizeof
(
gids
[
0
]),
cmp_gids
,
(
void
*
)
this
);
if
(
!
hb_atomic_ptr_cmpexch
(
&
gids_sorted_by_name
,
nullptr
,
gids
))
{
free
(
gids
);
goto
retry
;
}
}
hb_string_t
st
(
name
,
len
);
const
uint16_t
*
gid
=
(
const
uint16_t
*
)
hb_bsearch_r
(
&
st
,
gids
,
count
,
sizeof
(
gids
[
0
]),
cmp_key
,
(
void
*
)
this
);
if
(
gid
)
{
*
glyph
=
*
gid
;
return
true
;
}
return
false
;
}
protected:
inline
unsigned
int
get_glyph_count
(
void
)
const
{
if
(
version
==
0x00010000
)
return
NUM_FORMAT1_NAMES
;
if
(
version
==
0x00020000
)
return
glyphNameIndex
->
len
;
return
0
;
}
static
inline
int
cmp_gids
(
const
void
*
pa
,
const
void
*
pb
,
void
*
arg
)
{
const
accelerator_t
*
thiz
=
(
const
accelerator_t
*
)
arg
;
uint16_t
a
=
*
(
const
uint16_t
*
)
pa
;
uint16_t
b
=
*
(
const
uint16_t
*
)
pb
;
return
thiz
->
find_glyph_name
(
b
).
cmp
(
thiz
->
find_glyph_name
(
a
));
}
static
inline
int
cmp_key
(
const
void
*
pk
,
const
void
*
po
,
void
*
arg
)
{
const
accelerator_t
*
thiz
=
(
const
accelerator_t
*
)
arg
;
const
hb_string_t
*
key
=
(
const
hb_string_t
*
)
pk
;
uint16_t
o
=
*
(
const
uint16_t
*
)
po
;
return
thiz
->
find_glyph_name
(
o
).
cmp
(
*
key
);
}
inline
hb_string_t
find_glyph_name
(
hb_codepoint_t
glyph
)
const
{
if
(
version
==
0x00010000
)
{
...
...
@@ -139,38 +227,11 @@ struct post
return
hb_string_t
((
const
char
*
)
data
,
name_length
);
}
inline
bool
get_glyph_name
(
hb_codepoint_t
glyph
,
char
*
buf
,
unsigned
int
buf_len
)
const
{
hb_string_t
s
=
_find_glyph_name
(
glyph
);
if
(
!
s
.
len
)
return
false
;
if
(
!
buf_len
)
return
true
;
if
(
buf_len
<=
s
.
len
)
/* What to do with truncation? Returning false for now. */
return
false
;
strncpy
(
buf
,
s
.
bytes
,
s
.
len
);
buf
[
s
.
len
]
=
'\0'
;
return
true
;
}
inline
bool
get_glyph_from_name
(
const
char
*
name
,
int
len
,
hb_codepoint_t
*
glyph
)
const
{
if
(
len
<
0
)
len
=
strlen
(
name
);
if
(
unlikely
(
!
len
))
return
false
;
/* TODO format2 */
return
false
;
}
uint32_t
version
;
const
ArrayOf
<
USHORT
>
*
glyphNameIndex
;
hb_prealloced_array_t
<
uint32_t
,
1
>
index_to_offset
;
const
uint8_t
*
pool
;
mutable
uint16_t
*
gids_sorted_by_name
;
};
public:
...
...
src/hb-private.hh
浏览文件 @
e35a763c
...
...
@@ -1145,18 +1145,18 @@ struct hb_string_t
inline
hb_string_t
(
void
)
:
bytes
(
nullptr
),
len
(
0
)
{}
inline
hb_string_t
(
const
char
*
bytes_
,
unsigned
int
len_
)
:
bytes
(
bytes_
),
len
(
len_
)
{}
inline
int
cmp
(
const
hb_string_t
*
a
)
const
inline
int
cmp
(
const
hb_string_t
&
a
)
const
{
if
(
len
!=
a
->
len
)
return
(
int
)
a
->
len
-
(
int
)
len
;
if
(
len
!=
a
.
len
)
return
(
int
)
a
.
len
-
(
int
)
len
;
return
memcmp
(
a
->
bytes
,
bytes
,
len
);
return
memcmp
(
a
.
bytes
,
bytes
,
len
);
}
static
inline
int
cmp
(
const
void
*
pa
,
const
void
*
pb
)
{
hb_string_t
*
a
=
(
hb_string_t
*
)
pa
;
hb_string_t
*
b
=
(
hb_string_t
*
)
pb
;
return
b
->
cmp
(
a
);
return
b
->
cmp
(
*
a
);
}
const
char
*
bytes
;
...
...
src/hb-sort-r.hh
浏览文件 @
e35a763c
...
...
@@ -33,7 +33,7 @@
static
inline
void
*
hb_bsearch_r
(
const
void
*
key
,
const
void
*
base
,
size_t
nmemb
,
size_t
size
,
int
(
*
compar
)(
const
void
*
_
a
,
const
void
*
_b
,
const
void
*
_arg
),
int
(
*
compar
)(
const
void
*
_
key
,
const
void
*
_item
,
void
*
_arg
),
void
*
arg
)
{
int
min
=
0
,
max
=
(
int
)
nmemb
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录