Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
8f174870
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看板
提交
8f174870
编写于
5月 08, 2019
作者:
R
rsheeter
提交者:
Rod Sheeter
5月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[subset] Dinner time, checkpoint
上级
723d054d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
39 deletion
+58
-39
src/hb-ot-glyf-table.hh
src/hb-ot-glyf-table.hh
+58
-39
未找到文件。
src/hb-ot-glyf-table.hh
浏览文件 @
8f174870
...
...
@@ -86,9 +86,13 @@ struct glyf
{
TRACE_SERIALIZE
(
this
);
// TODO actually copy glyph
// TODO worry about instructions
// TODO capture dest locations for loca
// pad glyphs to 2-byte boundaries to permit short loca
HBUINT8
pad
;
+
it
|
hb_apply
(
[
&
]
(
hb_bytes_t
glyph
)
{
glyph
.
copy
(
c
);
if
(
glyph
.
length
%
2
)
c
->
extend
(
pad
);
});
return_trace
(
true
);
}
...
...
@@ -103,32 +107,54 @@ struct glyf
OT
::
glyf
::
accelerator_t
glyf
;
glyf
.
init
(
c
->
plan
->
source
);
// stream new-gids => pair of start/end offsets
// can now copy glyph from <prev>=>end
// TODO(instructions)
// stream new-gids => glyph to keep
// if dropping hints the glyph to keep doesn't have them anymore
auto
it
=
+
hb_iota
(
c
->
plan
->
num_output_glyphs
())
|
hb_map
([
&
]
(
hb_codepoint_t
new_gid
)
{
unsigned
int
start_offset
=
0
,
end_offset
=
0
;
hb_codepoint_t
old_gid
;
// should never happen, ALL old gids should be mapped
if
(
!
c
->
plan
->
old_gid_for_new_gid
(
new_gid
,
&
old_gid
))
return
hb_pair
(
start_offset
,
end_offset
);
// being empty is perfectly normal
if
(
c
->
plan
->
is_empty_glyph
(
old_gid
))
return
hb_pair
(
start_offset
,
end_offset
);
// should never happen fail, ALL old gids should be mapped
if
(
!
c
->
plan
->
old_gid_for_new_gid
(
new_gid
,
&
old_gid
))
return
hb_bytes_t
();
unsigned
int
start_offset
,
end_offset
;
if
(
unlikely
(
!
(
glyf
.
get_offsets
(
old_gid
,
&
start_offset
,
&
end_offset
)
&&
glyf
.
remove_padding
(
start_offset
,
&
end_offset
))))
{
// TODO signal irreversible error
return
hb_pair
(
start_offset
,
end_offset
);
return
hb_bytes_t
();
}
hb_bytes_t
glyph
((
const
char
*
)
this
,
end_offset
-
start_offset
);
// if dropping hints, find hints region and subtract it
if
(
c
->
plan
->
drop_hints
)
{
unsigned
int
instruction_length
;
if
(
!
glyf
.
get_instruction_length
(
glyph
,
&
instruction_length
))
{
// TODO signal irreversible failure
return
hb_bytes_t
();
}
glyph
=
hb_bytes_t
(
&
glyph
,
glyph
.
length
-
instruction_length
);
}
return
hb_pair
(
start_offset
,
end_offset
);
return
glyph
;
});
glyf_prime
->
serialize
(
c
->
serializer
,
it
);
// we know enough to write loca
// TODO calculate size, do we need two or four byte loca entries
unsigned
int
offset
=
0
;
HBUINT16
loca_entry
;
loca
*
loca_prime
=
c
->
serializer
->
start_embed
<
loca
>
();
+
hb_enumerate
(
it
)
|
hb_apply
([
&
]
(
hb_pair_t
<
unsigned
,
hb_bytes_t
>
p
)
{
offset
+=
p
.
second
.
length
;
loca_entry
=
offset
/
2
;
c
->
serializer
->
embed
(
loca_entry
);
});
// one for the road
c
->
serializer
->
embed
(
loca_entry
);
return_trace
(
true
);
}
...
...
@@ -412,45 +438,40 @@ struct glyf
return
true
;
}
bool
get_instruction_offsets
(
unsigned
int
start_offset
,
unsigned
int
end_offset
,
unsigned
int
*
instruction_start
/* OUT */
,
unsigned
int
*
instruction_end
/* OUT */
)
const
bool
get_instruction_length
(
hb_bytes_t
glyph
,
unsigned
int
*
length
/* OUT */
)
const
{
if
(
end_offset
-
start_offset
<
GlyphHeader
::
static_size
)
/* Empty glyph; no instructions. */
if
(
glyph
.
get_size
()
<
GlyphHeader
::
static_size
)
{
*
instruction_start
=
0
;
*
instruction_end
=
0
;
return
true
;
/* Empty glyph; no instructions. */
*
length
=
0
;
return
true
;
}
const
GlyphHeader
&
glyph_header
=
StructAtOffset
<
GlyphHeader
>
(
glyf_table
,
start_offset
);
unsigned
int
start
=
glyph
.
length
;
unsigned
int
end
=
glyph
.
length
;
const
GlyphHeader
&
glyph_header
=
StructAtOffset
<
GlyphHeader
>
(
&
glyph
,
0
);
int16_t
num_contours
=
(
int16_t
)
glyph_header
.
numberOfContours
;
if
(
num_contours
<
0
)
{
CompositeGlyphHeader
::
Iterator
composite_it
;
if
(
unlikely
(
!
CompositeGlyphHeader
::
get_iterator
(
(
const
char
*
)
this
->
glyf_table
+
start_offset
,
end_offset
-
start_offset
,
&
composite_it
)))
return
false
;
if
(
unlikely
(
!
CompositeGlyphHeader
::
get_iterator
(
&
glyph
,
glyph
.
length
,
&
composite_it
)))
return
false
;
const
CompositeGlyphHeader
*
last
;
do
{
last
=
composite_it
.
current
;
}
while
(
composite_it
.
move_to_next
());
if
((
uint16_t
)
last
->
flags
&
CompositeGlyphHeader
::
WE_HAVE_INSTRUCTIONS
)
*
instruction_start
=
((
char
*
)
last
-
(
char
*
)
glyf_table
->
dataZ
.
arrayZ
)
+
last
->
get_size
();
else
*
instruction_start
=
end_offset
;
*
instruction_end
=
end_offset
;
if
(
unlikely
(
*
instruction_start
>
*
instruction_end
))
start
=
((
char
*
)
last
-
(
char
*
)
glyf_table
->
dataZ
.
arrayZ
)
+
last
->
get_size
();
if
(
unlikely
(
start
>
end
))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Invalid instruction offset, %d is outside
[%d, %d]"
,
*
instruction_start
,
start_offset
,
end_offset
);
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Invalid instruction offset, %d is outside
%d byte buffer"
,
start
,
glyph
.
length
);
return
false
;
}
}
else
{
unsigned
int
instruction_length_offset
=
start_offset
+
GlyphHeader
::
static_size
+
2
*
num_contours
;
if
(
unlikely
(
instruction_length_offset
+
2
>
end_offset
))
unsigned
int
instruction_length_offset
=
GlyphHeader
::
static_size
+
2
*
num_contours
;
if
(
unlikely
(
instruction_length_offset
+
2
>
glyph
.
length
))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"Glyph size is too short, missing field instructionLength."
);
return
false
;
...
...
@@ -459,15 +480,13 @@ struct glyf
const
HBUINT16
&
instruction_length
=
StructAtOffset
<
HBUINT16
>
(
glyf_table
,
instruction_length_offset
);
unsigned
int
start
=
instruction_length_offset
+
2
;
unsigned
int
end
=
start
+
(
uint16_t
)
instruction_length
;
if
(
unlikely
(
end
>
end_offset
))
// Out of bounds of the current glyph
if
(
unlikely
(
end
>
glyph
.
length
))
// Out of bounds of the current glyph
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"The instructions array overruns the glyph's boundaries."
);
return
false
;
}
*
instruction_start
=
start
;
*
instruction_end
=
end
;
}
*
length
=
end
-
start
;
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录