Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
76f7397c
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看板
提交
76f7397c
编写于
8月 02, 2018
作者:
M
Michiharu Ariza
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
templatized CFF2 accelerator for lean Private dict interpretting for subset
also fixed local subrs serialization
上级
43040564
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
109 addition
and
31 deletion
+109
-31
src/hb-ot-cff-common-private.hh
src/hb-ot-cff-common-private.hh
+7
-1
src/hb-ot-cff2-table.hh
src/hb-ot-cff2-table.hh
+95
-24
src/hb-subset-cff2.cc
src/hb-subset-cff2.cc
+7
-6
未找到文件。
src/hb-ot-cff-common-private.hh
浏览文件 @
76f7397c
...
...
@@ -289,6 +289,7 @@ struct Index
inline
const
unsigned
int
offset_at
(
unsigned
int
index
)
const
{
assert
(
index
<=
count
);
const
HBUINT8
*
p
=
offsets
+
offSize
*
index
;
unsigned
int
size
=
offSize
;
unsigned
int
offset
=
0
;
...
...
@@ -317,7 +318,12 @@ struct Index
inline
unsigned
int
get_size
(
void
)
const
{
if
(
this
!=
&
Null
(
Index
))
return
count
.
static_size
+
offSize
.
static_size
+
offset_array_size
()
+
(
offset_at
(
count
)
-
1
);
{
if
(
count
>
0
)
return
min_size
+
offset_array_size
()
+
(
offset_at
(
count
)
-
1
);
else
return
count
.
static_size
;
/* empty Index contains count only */
}
else
return
0
;
}
...
...
src/hb-ot-cff2-table.hh
浏览文件 @
76f7397c
...
...
@@ -212,16 +212,44 @@ struct CFF2FontDictOpSet
}
};
struct
CFF2PrivateDictValues
:
DictValues
struct
CFF2PrivateDictValues
_Base
:
DictValues
{
inline
void
init
(
void
)
{
DictValues
::
init
();
subrsOffset
.
set
(
0
);
localSubrs
=
&
Null
(
Subrs
);
}
inline
void
fini
(
void
)
{
DictValues
::
fini
();
}
inline
unsigned
int
calculate_serialized_size
(
void
)
const
{
unsigned
int
size
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
opStrs
.
len
;
i
++
)
if
(
opStrs
[
i
].
op
==
OpCode_Subrs
)
size
+=
OpCode_Size
(
OpCode_shortint
)
+
2
+
OpCode_Size
(
OpCode_Subrs
);
else
size
+=
opStrs
[
i
].
str
.
len
;
return
size
;
}
LOffsetTo
<
Subrs
>
subrsOffset
;
const
Subrs
*
localSubrs
;
};
struct
CFF2PrivateDictValues
:
CFF2PrivateDictValues_Base
{
inline
void
init
(
void
)
{
CFF2PrivateDictValues_Base
::
init
();
languageGroup
=
0
;
expansionFactor
=
0.06
f
;
vsIndex
=
0
;
subrsOffset
.
set
(
0
);
blueScale
=
0.039625
f
;
blueShift
=
7.0
f
;
blueFuzz
=
1.0
f
;
...
...
@@ -234,8 +262,6 @@ struct CFF2PrivateDictValues : DictValues
familyOtherBlues
.
init
();
stemSnapH
.
init
();
stemSnapV
.
init
();
localSubrs
=
&
Null
(
Subrs
);
}
inline
void
fini
(
void
)
...
...
@@ -247,24 +273,12 @@ struct CFF2PrivateDictValues : DictValues
stemSnapH
.
fini
();
stemSnapV
.
fini
();
DictValues
::
fini
();
}
inline
unsigned
int
calculate_serialized_size
(
void
)
const
{
unsigned
int
size
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
opStrs
.
len
;
i
++
)
if
(
opStrs
[
i
].
op
==
OpCode_Subrs
)
size
+=
OpCode_Size
(
OpCode_shortint
)
+
2
+
OpCode_Size
(
OpCode_Subrs
);
else
size
+=
opStrs
[
i
].
str
.
len
;
return
size
;
CFF2PrivateDictValues_Base
::
fini
();
}
int
languageGroup
;
float
expansionFactor
;
int
vsIndex
;
OffsetTo
<
Subrs
>
subrsOffset
;
float
blueScale
;
float
blueShift
;
float
blueFuzz
;
...
...
@@ -276,8 +290,6 @@ struct CFF2PrivateDictValues : DictValues
hb_vector_t
<
float
>
familyOtherBlues
;
hb_vector_t
<
float
>
stemSnapH
;
hb_vector_t
<
float
>
stemSnapV
;
const
Subrs
*
localSubrs
;
};
struct
CFF2PrivateDictOpSet
...
...
@@ -368,6 +380,56 @@ struct CFF2PrivateDictOpSet
}
};
struct
CFF2PrivateDictOpSet_Subset
{
static
inline
bool
process_op
(
const
ByteStr
&
str
,
unsigned
int
&
offset
,
OpCode
op
,
Stack
&
stack
,
CFF2PrivateDictValues_Base
&
val
)
{
switch
(
op
)
{
case
OpCode_BlueValues
:
case
OpCode_OtherBlues
:
case
OpCode_FamilyBlues
:
case
OpCode_FamilyOtherBlues
:
case
OpCode_StdHW
:
case
OpCode_StdVW
:
case
OpCode_BlueScale
:
case
OpCode_BlueShift
:
case
OpCode_BlueFuzz
:
case
OpCode_StemSnapH
:
case
OpCode_StemSnapV
:
case
OpCode_LanguageGroup
:
case
OpCode_ExpansionFactor
:
case
OpCode_blend
:
stack
.
clear
();
break
;
case
OpCode_BCD
:
{
float
v
;
return
parse_bcd
(
str
,
offset
,
v
);
}
case
OpCode_Subrs
:
if
(
unlikely
(
!
check_pop_offset
(
stack
,
val
.
subrsOffset
)))
return
false
;
break
;
case
OpCode_longint
:
/* 5-byte integer */
if
(
unlikely
(
!
str
.
check_limit
(
offset
,
5
)
||
!
stack
.
check_overflow
(
1
)))
return
false
;
stack
.
push_int
((
int32_t
)((
str
[
offset
+
1
]
<<
24
)
|
(
str
[
offset
+
2
]
<<
16
)
||
(
str
[
offset
+
3
]
<<
8
)
||
str
[
offset
+
4
]));
offset
+=
4
;
break
;
default:
return
false
;
}
if
(
op
!=
OpCode_blend
)
val
.
pushOpStr
(
op
,
str
,
offset
+
1
);
return
true
;
}
};
typedef
Interpreter
<
CFF2TopDictOpSet
,
CFF2TopDictValues
>
CFF2TopDict_Interpreter
;
typedef
Interpreter
<
CFF2FontDictOpSet
,
CFF2FontDictValues
>
CFF2FontDict_Interpreter
;
typedef
Interpreter
<
CFF2PrivateDictOpSet
,
CFF2PrivateDictValues
>
CFF2PrivateDict_Interpreter
;
...
...
@@ -389,7 +451,8 @@ struct cff2
likely
(
version
.
major
==
2
));
}
struct
accelerator_t
template
<
typename
PrivOpSet
,
typename
PrivDictVal
>
struct
accelerator_templ_t
{
inline
void
init
(
hb_face_t
*
face
)
{
...
...
@@ -402,7 +465,7 @@ struct cff2
sc
.
init
(
this
->
blob
);
sc
.
start_processing
();
const
OT
::
cff2
*
cff2
=
this
->
blob
->
as
<
OT
::
cff2
>
();
const
OT
::
cff2
*
cff2
=
this
->
blob
->
template
as
<
OT
::
cff2
>
();
if
(
cff2
==
&
Null
(
OT
::
cff2
))
{
...
...
@@ -460,7 +523,7 @@ struct cff2
}
const
ByteStr
privDictStr
(
font
->
privateDictOffset
(
cff2
),
font
->
privateDictSize
);
CFF2PrivateDict_Interpreter
priv_interp
;
Interpreter
<
PrivOpSet
,
PrivDictVal
>
priv_interp
;
if
(
unlikely
(
!
privDictStr
.
sanitize
(
&
sc
)
||
!
priv_interp
.
interpret
(
privDictStr
,
privateDicts
[
i
])))
{
...
...
@@ -468,7 +531,12 @@ struct cff2
return
;
}
privateDicts
[
i
].
localSubrs
=
&
privateDicts
[
i
].
subrsOffset
(
cff2
);
privateDicts
[
i
].
localSubrs
=
&
privateDicts
[
i
].
subrsOffset
(
privDictStr
.
str
);
if
(
unlikely
(
!
privateDicts
[
i
].
localSubrs
->
sanitize
(
&
sc
)))
{
fini
();
return
;
}
}
}
...
...
@@ -506,11 +574,14 @@ struct cff2
const
FDSelect
*
fdSelect
;
hb_vector_t
<
CFF2FontDictValues
>
fontDicts
;
hb_vector_t
<
CFF2PrivateDictValues
>
privateDicts
;
hb_vector_t
<
PrivDictVal
>
privateDicts
;
unsigned
int
num_glyphs
;
};
typedef
accelerator_templ_t
<
CFF2PrivateDictOpSet
,
CFF2PrivateDictValues
>
accelerator_t
;
typedef
accelerator_templ_t
<
CFF2PrivateDictOpSet_Subset
,
CFF2PrivateDictValues_Base
>
accelerator_subset_t
;
inline
bool
subset
(
hb_subset_plan_t
*
plan
)
const
{
hb_blob_t
*
cff2_prime
=
nullptr
;
...
...
src/hb-subset-cff2.cc
浏览文件 @
76f7397c
...
...
@@ -156,7 +156,7 @@ struct subset_plan {
private_off_and_size_pairs
.
fini
();
}
inline
bool
create
(
const
OT
::
cff2
::
accelerator_t
&
acc
,
inline
bool
create
(
const
OT
::
cff2
::
accelerator_
subset_
t
&
acc
,
hb_subset_plan_t
*
plan
)
{
final_size
=
0
;
...
...
@@ -233,7 +233,7 @@ struct subset_plan {
};
static
inline
bool
_write_cff2
(
const
subset_plan
&
plan
,
const
OT
::
cff2
::
accelerator_t
&
acc
,
const
OT
::
cff2
::
accelerator_
subset_
t
&
acc
,
unsigned
int
dest_sz
,
void
*
dest
)
{
...
...
@@ -329,14 +329,15 @@ static inline bool _write_cff2 (const subset_plan &plan,
PrivateDict
*
pd
=
c
.
start_embed
<
PrivateDict
>
();
if
(
unlikely
(
pd
==
nullptr
))
return
false
;
CFF2PrivateDict_OpSerializer
privSzr
;
if
(
unlikely
(
!
pd
->
serialize
(
&
c
,
acc
.
privateDicts
[
i
],
privSzr
,
acc
.
privateDicts
[
i
].
subrsOffset
)))
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
if
(
unlikely
(
!
pd
->
serialize
(
&
c
,
acc
.
privateDicts
[
i
],
privSzr
,
plan
.
private_off_and_size_pairs
[
i
].
size
)))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"failed to serialize CFF2 Private Dict[%d]"
,
i
);
return
false
;
}
if
(
acc
.
privateDicts
[
i
].
subrsOffset
!=
0
)
{
Subrs
*
subrs
=
c
.
allocate_size
<
Subrs
>
(
acc
.
privateDicts
[
i
].
localSubrs
->
get_size
()
);
Subrs
*
subrs
=
c
.
start_embed
<
Subrs
>
(
);
if
(
unlikely
(
subrs
==
nullptr
)
||
acc
.
privateDicts
[
i
].
localSubrs
==
&
Null
(
Subrs
))
{
DEBUG_MSG
(
SUBSET
,
nullptr
,
"CFF2 subset: local subrs unexpectedly null [%d]"
,
i
);
...
...
@@ -356,7 +357,7 @@ static inline bool _write_cff2 (const subset_plan &plan,
}
static
bool
_hb_subset_cff2
(
const
OT
::
cff2
::
accelerator_t
&
acc
,
_hb_subset_cff2
(
const
OT
::
cff2
::
accelerator_
subset_
t
&
acc
,
const
char
*
data
,
hb_subset_plan_t
*
plan
,
hb_blob_t
**
prime
/* OUT */
)
...
...
@@ -400,7 +401,7 @@ hb_subset_cff2 (hb_subset_plan_t *plan,
hb_blob_t
*
cff2_blob
=
hb_sanitize_context_t
().
reference_table
<
CFF
::
cff2
>
(
plan
->
source
);
const
char
*
data
=
hb_blob_get_data
(
cff2_blob
,
nullptr
);
OT
::
cff2
::
accelerator_t
acc
;
OT
::
cff2
::
accelerator_
subset_
t
acc
;
acc
.
init
(
plan
->
source
);
bool
result
=
likely
(
acc
.
is_valid
())
&&
_hb_subset_cff2
(
acc
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录