Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
efe252e6
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,发现更多精彩内容 >>
提交
efe252e6
编写于
12月 17, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[OTLayout] Fix 'size' featureParams implementation
Looks at alternate location now.
上级
e77b4425
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
109 deletion
+117
-109
src/hb-ot-layout-common-private.hh
src/hb-ot-layout-common-private.hh
+103
-30
src/hb-ot-layout.cc
src/hb-ot-layout.cc
+14
-79
未找到文件。
src/hb-ot-layout-common-private.hh
浏览文件 @
efe252e6
...
...
@@ -261,7 +261,71 @@ struct FeatureParamsSize
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
TRACE_SANITIZE
(
this
);
return
TRACE_RETURN
(
c
->
check_struct
(
this
));
if
(
unlikely
(
!
c
->
check_struct
(
this
)))
return
TRACE_RETURN
(
false
);
/* This subtable has some "history", if you will. Some earlier versions of
* Adobe tools calculated the offset of the FeatureParams sutable from the
* beginning of the FeatureList table! Now, that is dealt with in the
* Feature implementation. But we still need to be able to tell junk from
* real data. Note: We don't check that the nameID actually exists.
*
* Read Roberts wrote on 9/15/06 on opentype-list@indx.co.uk :
*
* Yes, it is correct that a new version of the AFDKO (version 2.0) will be
* coming out soon, and that the makeotf program will build a font with a
* 'size' feature that is correct by the specification.
*
* The specification for this feature tag is in the "OpenType Layout Tag
* Registry". You can see a copy of this at:
* http://partners.adobe.com/public/developer/opentype/index_tag8.html#size
*
* Here is one set of rules to determine if the 'size' feature is built
* correctly, or as by the older versions of MakeOTF. You may be able to do
* better.
*
* Assume that the offset to the size feature is according to specification,
* and make the following value checks. If it fails, assume the the size
* feature is calculated as versions of MakeOTF before the AFDKO 2.0 built it.
* If this fails, reject the 'size' feature. The older makeOTF's calculated the
* offset from the beginning of the FeatureList table, rather than from the
* beginning of the 'size' Feature table.
*
* If "design size" == 0:
* fails check
*
* Else if ("subfamily identifier" == 0 and
* "range start" == 0 and
* "range end" == 0 and
* "range start" == 0 and
* "menu name ID" == 0)
* passes check: this is the format used when there is a design size
* specified, but there is no recommended size range.
*
* Else if ("design size" < "range start" or
* "design size" > "range end" or
* "range end" <= "range start" or
* "menu name ID" < 256 or
* "menu name ID" > 32767 or
* menu name ID is not a name ID which is actually in the name table)
* fails test
* Else
* passes test.
*/
if
(
!
designSize
)
return
TRACE_RETURN
(
false
);
else
if
(
subfamilyID
==
0
&&
subfamilyNameID
==
0
&&
rangeStart
==
0
&&
rangeEnd
==
0
)
return
TRACE_RETURN
(
true
);
else
if
(
designSize
<
rangeStart
||
designSize
>
rangeEnd
||
subfamilyNameID
<
256
||
subfamilyNameID
>
32767
)
return
TRACE_RETURN
(
false
);
else
return
TRACE_RETURN
(
true
);
}
USHORT
designSize
;
/* Represents the design size in 720/inch
...
...
@@ -343,9 +407,7 @@ struct FeatureParamsCharacterVariants
return
TRACE_RETURN
(
c
->
check_struct
(
this
)
&&
characters
.
sanitize
(
c
));
}
/* TODO: This is made private since we don't have the facilities in
* FeatureParams to correctly sanitize this. */
private:
USHORT
format
;
/* Format number is set to 0. */
USHORT
featUILableNameID
;
/* The ‘name’ table name ID that
* specifies a string (or strings,
...
...
@@ -380,24 +442,25 @@ struct FeatureParamsCharacterVariants
struct
FeatureParams
{
/* Note:
*
* FeatureParams structures unfortunately don't have a generic length argument,
* so their length depends on the feature name / requested use. We don't have
* that information at sanitize time. As such, we sanitize for the longest
* subtable possible. This may nuke a possibly valid subtable if it's unfortunate
* enough to happen at the very end of the GSUB/GPOS table. But that's very
* unlikely (I hope!).
*
* When we fully implement FeatureParamsCharacterVariants, we should fix this
* shortcoming...
*/
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
,
hb_tag_t
tag
)
{
TRACE_SANITIZE
(
this
);
return
TRACE_RETURN
(
c
->
check_struct
(
this
));
if
(
tag
==
HB_TAG
(
's'
,
'i'
,
'z'
,
'e'
))
return
TRACE_RETURN
(
u
.
size
.
sanitize
(
c
));
if
((
tag
&
0xFFFF0000
)
==
HB_TAG
(
's'
,
's'
,
'\0'
,
'\0'
))
/* ssXX */
return
TRACE_RETURN
(
u
.
stylisticSet
.
sanitize
(
c
));
if
((
tag
&
0xFFFF0000
)
==
HB_TAG
(
'c'
,
'v'
,
'\0'
,
'\0'
))
/* cvXX */
return
TRACE_RETURN
(
u
.
characterVariants
.
sanitize
(
c
));
return
TRACE_RETURN
(
true
);
}
inline
const
FeatureParamsSize
&
get_size_params
(
hb_tag_t
tag
)
const
{
if
(
tag
==
HB_TAG
(
's'
,
'i'
,
'z'
,
'e'
))
return
u
.
size
;
return
Null
(
FeatureParamsSize
);
}
private:
union
{
FeatureParamsSize
size
;
FeatureParamsStylisticSet
stylisticSet
;
...
...
@@ -426,26 +489,36 @@ struct Feature
if
(
unlikely
(
!
(
c
->
check_struct
(
this
)
&&
lookupIndex
.
sanitize
(
c
))))
return
TRACE_RETURN
(
false
);
/* Some earlier versions of Adobe tools calculated the offset of the
* FeatureParams subtable from the beginning of the FeatureList table!
*
* If sanitizing "failed" for the FeatureParams subtable, try it with the
* alternative location. We would know sanitize "failed" if old value
* of the offset was non-zero, but it's zeroed now.
*/
Offset
orig_offset
=
featureParams
;
if
(
likely
(
featureParams
.
sanitize
(
c
,
this
)))
if
(
unlikely
(
!
featureParams
.
sanitize
(
c
,
this
,
closure
?
closure
->
tag
:
HB_TAG_NONE
)))
return
TRACE_RETURN
(
false
);
if
(
likely
(
!
orig_offset
))
return
TRACE_RETURN
(
true
);
/* Some earlier versions of Adobe tools calculated the offset of the
* FeatureParams sutable from the beginning of the FeatureList table!
* Try that instead... */
if
(
closure
&&
closure
->
list_base
)
if
(
featureParams
==
0
&&
closure
&&
closure
->
list_base
&&
closure
->
list_base
<
this
)
{
unsigned
int
new_offset_int
=
(
unsigned
int
)
orig_offset
-
((
char
*
)
this
-
(
char
*
)
closure
->
list_base
);
Offset
new_offset
;
new_offset
.
set
(
orig_offset
-
((
char
*
)
this
-
(
char
*
)
closure
->
list_base
));
/* Check that it did not overflow. */
if
(
new_offset
!=
(
orig_offset
-
((
char
*
)
this
-
(
char
*
)
closure
->
list_base
)))
new_offset
.
set
(
new_offset_int
);
if
(
new_offset
==
new_offset_int
&&
featureParams
.
try_set
(
c
,
new_offset
)
&&
!
featureParams
.
sanitize
(
c
,
this
,
closure
?
closure
->
tag
:
HB_TAG_NONE
))
return
TRACE_RETURN
(
false
);
return
TRACE_RETURN
(
featureParams
.
try_set
(
c
,
new_offset
)
&&
featureParams
.
sanitize
(
c
,
this
));
}
return
TRACE_RETURN
(
fals
e
);
return
TRACE_RETURN
(
tru
e
);
}
OffsetTo
<
FeatureParams
>
...
...
src/hb-ot-layout.cc
浏览文件 @
efe252e6
...
...
@@ -647,104 +647,39 @@ hb_ot_layout_get_size_params (hb_face_t *face,
unsigned
int
*
range_start
,
/* OUT. May be NULL */
unsigned
int
*
range_end
/* OUT. May be NULL */
)
{
bool
ret
=
false
;
const
OT
::
GPOS
&
gpos
=
_get_gpos
(
face
);
const
hb_tag_t
tag
=
HB_TAG
(
's'
,
'i'
,
'z'
,
'e'
);
unsigned
int
num_features
=
gpos
.
get_feature_count
();
for
(
unsigned
int
i
=
0
;
i
<
num_features
;
i
++
)
{
if
(
HB_TAG
(
's'
,
'i'
,
'z'
,
'e'
)
==
gpos
.
get_feature_tag
(
i
))
if
(
tag
==
gpos
.
get_feature_tag
(
i
))
{
const
OT
::
Feature
&
f
=
gpos
.
get_feature
(
i
);
const
OT
::
FeatureParamsSize
&
params
=
f
.
get_feature_params
().
u
.
size
;
/* This subtable has some "history", if you will. Some earlier versions of
* Adobe tools calculated the offset of the FeatureParams sutable from the
* beginning of the FeatureList table! Now, we don't check for that possibility,
* but we want to at least detect junk data and reject it.
*
* Read Roberts wrote on 9/15/06 on opentype-list@indx.co.uk :
*
* Yes, it is correct that a new version of the AFDKO (version 2.0) will be
* coming out soon, and that the makeotf program will build a font with a
* 'size' feature that is correct by the specification.
*
* The specification for this feature tag is in the "OpenType Layout Tag
* Registry". You can see a copy of this at:
* http://partners.adobe.com/public/developer/opentype/index_tag8.html#size
*
* Here is one set of rules to determine if the 'size' feature is built
* correctly, or as by the older versions of MakeOTF. You may be able to do
* better.
*
* Assume that the offset to the size feature is according to specification,
* and make the following value checks. If it fails, assume the the size
* feature is calculated as versions of MakeOTF before the AFDKO 2.0 built it.
* If this fails, reject the 'size' feature. The older makeOTF's calculated the
* offset from the beginning of the FeatureList table, rather than from the
* beginning of the 'size' Feature table.
*
* If "design size" == 0:
* fails check
*
* Else if ("subfamily identifier" == 0 and
* "range start" == 0 and
* "range end" == 0 and
* "range start" == 0 and
* "menu name ID" == 0)
* passes check: this is the format used when there is a design size
* specified, but there is no recommended size range.
*
* Else if ("design size" < "range start" or
* "design size" > "range end" or
* "range end" <= "range start" or
* "menu name ID" < 256 or
* "menu name ID" > 32767 or
* menu name ID is not a name ID which is actually in the name table)
* fails test
* Else
* passes test.
*/
if
(
!
params
.
designSize
)
ret
=
false
;
else
if
(
params
.
subfamilyID
==
0
&&
params
.
subfamilyNameID
==
0
&&
params
.
rangeStart
==
0
&&
params
.
rangeEnd
==
0
)
ret
=
true
;
else
if
(
params
.
designSize
<
params
.
rangeStart
||
params
.
designSize
>
params
.
rangeEnd
||
params
.
subfamilyNameID
<
256
||
params
.
subfamilyNameID
>
32767
)
ret
=
false
;
else
ret
=
true
;
const
OT
::
FeatureParamsSize
&
params
=
f
.
get_feature_params
().
get_size_params
(
tag
);
#define PARAM(a, A) if (a) *a = params.A
if
(
ret
)
if
(
params
.
designSize
)
{
#define PARAM(a, A) if (a) *a = params.A
PARAM
(
design_size
,
designSize
);
PARAM
(
subfamily_id
,
subfamilyID
);
PARAM
(
subfamily_name_id
,
subfamilyNameID
);
PARAM
(
range_start
,
rangeStart
);
PARAM
(
range_end
,
rangeEnd
);
break
;
}
#undef PARAM
return
true
;
}
}
}
#define PARAM(a, A) if (a) *a = 0
if
(
!
ret
)
{
PARAM
(
design_size
,
designSize
);
PARAM
(
subfamily_id
,
subfamilyID
);
PARAM
(
subfamily_name_id
,
subfamilyNameID
);
PARAM
(
range_start
,
rangeStart
);
PARAM
(
range_end
,
rangeEnd
);
}
PARAM
(
design_size
,
designSize
);
PARAM
(
subfamily_id
,
subfamilyID
);
PARAM
(
subfamily_name_id
,
subfamilyNameID
);
PARAM
(
range_start
,
rangeStart
);
PARAM
(
range_end
,
rangeEnd
);
#undef PARAM
return
ret
;
return
false
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录