Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
31081f73
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
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看板
提交
31081f73
编写于
4月 23, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement closure() for Context and ChainContext lookups
上级
c64ddab3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
351 addition
and
73 deletion
+351
-73
src/hb-ot-layout-common-private.hh
src/hb-ot-layout-common-private.hh
+54
-0
src/hb-ot-layout-gsubgpos-private.hh
src/hb-ot-layout-gsubgpos-private.hh
+279
-68
src/hb-ot-layout-private.hh
src/hb-ot-layout-private.hh
+18
-5
未找到文件。
src/hb-ot-layout-common-private.hh
浏览文件 @
31081f73
...
...
@@ -131,6 +131,10 @@ struct RangeRecord
return
c
->
check_struct
(
this
);
}
inline
bool
intersects
(
const
hb_glyph_map_t
*
glyphs
)
const
{
return
glyphs
->
intersects
(
start
,
end
);
}
GlyphID
start
;
/* First GlyphID in the range */
GlyphID
end
;
/* Last GlyphID in the range */
USHORT
value
;
/* Value */
...
...
@@ -354,6 +358,10 @@ struct CoverageFormat1
return
glyphArray
.
sanitize
(
c
);
}
inline
bool
intersects_coverage
(
const
hb_glyph_map_t
*
glyphs
,
unsigned
int
index
)
const
{
return
glyphs
->
has
(
glyphArray
[
index
]);
}
struct
Iter
{
inline
void
init
(
const
struct
CoverageFormat1
&
c_
)
{
c
=
&
c_
;
i
=
0
;
};
inline
bool
more
(
void
)
{
return
i
<
c
->
glyphArray
.
len
;
}
...
...
@@ -394,6 +402,21 @@ struct CoverageFormat2
return
rangeRecord
.
sanitize
(
c
);
}
inline
bool
intersects_coverage
(
const
hb_glyph_map_t
*
glyphs
,
unsigned
int
index
)
const
{
unsigned
int
i
;
unsigned
int
count
=
rangeRecord
.
len
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
const
RangeRecord
&
range
=
rangeRecord
[
i
];
if
(
range
.
value
<=
index
&&
index
<
range
.
value
+
(
range
.
end
-
range
.
start
)
&&
range
.
intersects
(
glyphs
))
return
true
;
else
if
(
index
<
range
.
value
)
return
false
;
}
return
false
;
}
struct
Iter
{
inline
void
init
(
const
CoverageFormat2
&
c_
)
{
c
=
&
c_
;
...
...
@@ -461,7 +484,14 @@ struct Coverage
return
true
;
}
return
false
;
}
inline
bool
intersects_coverage
(
const
hb_glyph_map_t
*
glyphs
,
unsigned
int
index
)
const
{
switch
(
u
.
format
)
{
case
1
:
return
u
.
format1
.
intersects_coverage
(
glyphs
,
index
);
case
2
:
return
u
.
format2
.
intersects_coverage
(
glyphs
,
index
);
default:
return
false
;
}
}
struct
Iter
{
...
...
@@ -544,6 +574,14 @@ struct ClassDefFormat1
&&
classValue
.
sanitize
(
c
);
}
inline
bool
intersects_class
(
const
hb_glyph_map_t
*
glyphs
,
unsigned
int
klass
)
const
{
unsigned
int
count
=
classValue
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
classValue
[
i
]
==
klass
&&
glyphs
->
has
(
startGlyph
+
i
))
return
true
;
return
false
;
}
USHORT
classFormat
;
/* Format identifier--format = 1 */
GlyphID
startGlyph
;
/* First GlyphID of the classValueArray */
ArrayOf
<
USHORT
>
...
...
@@ -570,6 +608,14 @@ struct ClassDefFormat2
return
rangeRecord
.
sanitize
(
c
);
}
inline
bool
intersects_class
(
const
hb_glyph_map_t
*
glyphs
,
unsigned
int
klass
)
const
{
unsigned
int
count
=
rangeRecord
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
rangeRecord
[
i
].
value
==
klass
&&
rangeRecord
[
i
].
intersects
(
glyphs
))
return
true
;
return
false
;
}
USHORT
classFormat
;
/* Format identifier--format = 2 */
SortedArrayOf
<
RangeRecord
>
rangeRecord
;
/* Array of glyph ranges--ordered by
...
...
@@ -601,6 +647,14 @@ struct ClassDef
}
}
inline
bool
intersects_class
(
const
hb_glyph_map_t
*
glyphs
,
unsigned
int
klass
)
const
{
switch
(
u
.
format
)
{
case
1
:
return
u
.
format1
.
intersects_class
(
glyphs
,
klass
);
case
2
:
return
u
.
format2
.
intersects_class
(
glyphs
,
klass
);
default:
return
false
;
}
}
private:
union
{
USHORT
format
;
/* Format identifier */
...
...
src/hb-ot-layout-gsubgpos-private.hh
浏览文件 @
31081f73
...
...
@@ -71,8 +71,6 @@ struct hb_closure_context_t
debug_depth
(
0
)
{}
};
typedef
bool
(
*
closure_lookup_func_t
)
(
hb_closure_context_t
*
c
,
unsigned
int
lookup_index
);
#ifndef HB_DEBUG_APPLY
...
...
@@ -229,31 +227,63 @@ struct hb_apply_context_t
typedef
bool
(
*
intersects_func_t
)
(
hb_glyph_map_t
*
glyphs
,
const
USHORT
&
value
,
const
void
*
data
);
typedef
bool
(
*
match_func_t
)
(
hb_codepoint_t
glyph_id
,
const
USHORT
&
value
,
const
void
*
data
);
typedef
bool
(
*
closure_lookup_func_t
)
(
hb_closure_context_t
*
c
,
unsigned
int
lookup_index
);
typedef
bool
(
*
apply_lookup_func_t
)
(
hb_apply_context_t
*
c
,
unsigned
int
lookup_index
);
struct
ContextFuncs
struct
ContextClosureFuncs
{
intersects_func_t
intersects
;
closure_lookup_func_t
closure
;
};
struct
ContextApplyFuncs
{
match_func_t
match
;
apply_lookup_func_t
apply
;
};
static
inline
bool
intersects_glyph
(
hb_glyph_map_t
*
glyphs
,
const
USHORT
&
value
,
const
void
*
data
HB_UNUSED
)
{
return
glyphs
->
has
(
value
);
}
static
inline
bool
intersects_class
(
hb_glyph_map_t
*
glyphs
,
const
USHORT
&
value
,
const
void
*
data
)
{
const
ClassDef
&
class_def
=
*
reinterpret_cast
<
const
ClassDef
*>
(
data
);
return
class_def
.
intersects_class
(
glyphs
,
value
);
}
static
inline
bool
intersects_coverage
(
hb_glyph_map_t
*
glyphs
,
const
USHORT
&
value
,
const
void
*
data
)
{
const
OffsetTo
<
Coverage
>
&
coverage
=
(
const
OffsetTo
<
Coverage
>&
)
value
;
return
(
data
+
coverage
).
intersects
(
glyphs
);
}
static
inline
bool
intersects_array
(
hb_closure_context_t
*
c
,
unsigned
int
count
,
const
USHORT
values
[],
intersects_func_t
intersects_func
,
const
void
*
intersects_data
)
{
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
likely
(
!
intersects_func
(
c
->
glyphs
,
values
[
i
],
intersects_data
)))
return
false
;
return
true
;
}
static
inline
bool
match_glyph
(
hb_codepoint_t
glyph_id
,
const
USHORT
&
value
,
const
void
*
data
HB_UNUSED
)
{
return
glyph_id
==
value
;
}
static
inline
bool
match_class
(
hb_codepoint_t
glyph_id
,
const
USHORT
&
value
,
const
void
*
data
)
{
const
ClassDef
&
class_def
=
*
reinterpret_cast
<
const
ClassDef
*>
(
data
);
return
class_def
.
get_class
(
glyph_id
)
==
value
;
}
static
inline
bool
match_coverage
(
hb_codepoint_t
glyph_id
,
const
USHORT
&
value
,
const
void
*
data
)
{
const
OffsetTo
<
Coverage
>
&
coverage
=
(
const
OffsetTo
<
Coverage
>&
)
value
;
return
(
data
+
coverage
)
(
glyph_id
)
!=
NOT_COVERED
;
return
(
data
+
coverage
)
.
get_coverage
(
glyph_id
)
!=
NOT_COVERED
;
}
...
...
@@ -345,6 +375,16 @@ struct LookupRecord
};
static
inline
bool
closure_lookup
(
hb_closure_context_t
*
c
,
unsigned
int
lookupCount
,
const
LookupRecord
lookupRecord
[],
/* Array of LookupRecords--in design order */
closure_lookup_func_t
closure_func
)
{
bool
ret
=
false
;
for
(
unsigned
int
i
=
0
;
i
<
lookupCount
;
i
++
)
ret
=
closure_func
(
c
,
lookupRecord
->
lookupListIndex
)
||
ret
;
return
ret
;
}
static
inline
bool
apply_lookup
(
hb_apply_context_t
*
c
,
unsigned
int
count
,
/* Including the first glyph */
...
...
@@ -408,18 +448,40 @@ static inline bool apply_lookup (hb_apply_context_t *c,
/* Contextual lookups */
struct
ContextLookupContext
struct
ContextClosureLookupContext
{
ContextClosureFuncs
funcs
;
const
void
*
intersects_data
;
};
struct
ContextApplyLookupContext
{
ContextFuncs
funcs
;
Context
Apply
Funcs
funcs
;
const
void
*
match_data
;
};
static
inline
bool
context_lookup
(
hb_apply_context_t
*
c
,
unsigned
int
inputCount
,
/* Including the first glyph (not matched) */
const
USHORT
input
[],
/* Array of input values--start with second glyph */
unsigned
int
lookupCount
,
const
LookupRecord
lookupRecord
[],
ContextLookupContext
&
lookup_context
)
static
inline
bool
context_closure_lookup
(
hb_closure_context_t
*
c
,
unsigned
int
inputCount
,
/* Including the first glyph (not matched) */
const
USHORT
input
[],
/* Array of input values--start with second glyph */
unsigned
int
lookupCount
,
const
LookupRecord
lookupRecord
[],
ContextClosureLookupContext
&
lookup_context
)
{
return
intersects_array
(
c
,
inputCount
?
inputCount
-
1
:
0
,
input
,
lookup_context
.
funcs
.
intersects
,
lookup_context
.
intersects_data
)
&&
closure_lookup
(
c
,
lookupCount
,
lookupRecord
,
lookup_context
.
funcs
.
closure
);
}
static
inline
bool
context_apply_lookup
(
hb_apply_context_t
*
c
,
unsigned
int
inputCount
,
/* Including the first glyph (not matched) */
const
USHORT
input
[],
/* Array of input values--start with second glyph */
unsigned
int
lookupCount
,
const
LookupRecord
lookupRecord
[],
ContextApplyLookupContext
&
lookup_context
)
{
hb_apply_context_t
new_context
=
*
c
;
return
match_input
(
c
,
...
...
@@ -437,14 +499,25 @@ struct Rule
friend
struct
RuleSet
;
private:
inline
bool
apply
(
hb_apply_context_t
*
c
,
ContextLookupContext
&
lookup_context
)
const
inline
bool
closure
(
hb_closure_context_t
*
c
,
ContextClosureLookupContext
&
lookup_context
)
const
{
TRACE_CLOSURE
();
const
LookupRecord
*
lookupRecord
=
&
StructAtOffset
<
LookupRecord
>
(
input
,
input
[
0
].
static_size
*
(
inputCount
?
inputCount
-
1
:
0
));
return
context_closure_lookup
(
c
,
inputCount
,
input
,
lookupCount
,
lookupRecord
,
lookup_context
);
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
ContextApplyLookupContext
&
lookup_context
)
const
{
TRACE_APPLY
();
const
LookupRecord
*
lookupRecord
=
&
StructAtOffset
<
LookupRecord
>
(
input
,
input
[
0
].
static_size
*
(
inputCount
?
inputCount
-
1
:
0
));
return
context_lookup
(
c
,
inputCount
,
input
,
lookupCount
,
lookupRecord
,
lookup_context
);
return
context_
apply_
lookup
(
c
,
inputCount
,
input
,
lookupCount
,
lookupRecord
,
lookup_context
);
}
public:
...
...
@@ -459,7 +532,7 @@ struct Rule
private:
USHORT
inputCount
;
/* Total number of glyphs in input
* glyph sequence--includes the
first
* glyph sequence--includes the first
* glyph */
USHORT
lookupCount
;
/* Number of LookupRecords */
USHORT
input
[
VAR
];
/* Array of match inputs--start with
...
...
@@ -472,7 +545,17 @@ struct Rule
struct
RuleSet
{
inline
bool
apply
(
hb_apply_context_t
*
c
,
ContextLookupContext
&
lookup_context
)
const
inline
bool
closure
(
hb_closure_context_t
*
c
,
ContextClosureLookupContext
&
lookup_context
)
const
{
TRACE_CLOSURE
();
bool
ret
=
false
;
unsigned
int
num_rules
=
rule
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
num_rules
;
i
++
)
ret
=
(
this
+
rule
[
i
]).
closure
(
c
,
lookup_context
)
||
ret
;
return
ret
;
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
ContextApplyLookupContext
&
lookup_context
)
const
{
TRACE_APPLY
();
unsigned
int
num_rules
=
rule
.
len
;
...
...
@@ -481,7 +564,6 @@ struct RuleSet
if
((
this
+
rule
[
i
]).
apply
(
c
,
lookup_context
))
return
true
;
}
return
false
;
}
...
...
@@ -508,8 +590,22 @@ struct ContextFormat1
inline
bool
closure
(
hb_closure_context_t
*
c
,
closure_lookup_func_t
closure_func
)
const
{
TRACE_CLOSURE
();
/* TODO FILLME */
return
false
;
const
Coverage
&
cov
=
(
this
+
coverage
);
struct
ContextClosureLookupContext
lookup_context
=
{
{
intersects_glyph
,
closure_func
},
NULL
};
bool
ret
=
false
;
unsigned
int
count
=
ruleSet
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
cov
.
intersects_coverage
(
c
->
glyphs
,
i
))
{
const
RuleSet
&
rule_set
=
this
+
ruleSet
[
i
];
ret
=
rule_set
.
closure
(
c
,
lookup_context
)
||
ret
;
}
return
ret
;
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
apply_lookup_func_t
apply_func
)
const
...
...
@@ -520,7 +616,7 @@ struct ContextFormat1
return
false
;
const
RuleSet
&
rule_set
=
this
+
ruleSet
[
index
];
struct
ContextLookupContext
lookup_context
=
{
struct
Context
Apply
LookupContext
lookup_context
=
{
{
match_glyph
,
apply_func
},
NULL
};
...
...
@@ -555,8 +651,24 @@ struct ContextFormat2
inline
bool
closure
(
hb_closure_context_t
*
c
,
closure_lookup_func_t
closure_func
)
const
{
TRACE_CLOSURE
();
/* TODO FILLME */
return
false
;
if
(
!
(
this
+
coverage
).
intersects
(
c
->
glyphs
))
return
false
;
const
ClassDef
&
class_def
=
this
+
classDef
;
struct
ContextClosureLookupContext
lookup_context
=
{
{
intersects_class
,
closure_func
},
NULL
};
bool
ret
=
false
;
unsigned
int
count
=
ruleSet
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
class_def
.
intersects_class
(
c
->
glyphs
,
i
))
{
const
RuleSet
&
rule_set
=
this
+
ruleSet
[
i
];
ret
=
rule_set
.
closure
(
c
,
lookup_context
)
||
ret
;
}
return
ret
;
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
apply_lookup_func_t
apply_func
)
const
...
...
@@ -569,7 +681,7 @@ struct ContextFormat2
const
ClassDef
&
class_def
=
this
+
classDef
;
index
=
class_def
(
c
->
buffer
->
info
[
c
->
buffer
->
idx
].
codepoint
);
const
RuleSet
&
rule_set
=
this
+
ruleSet
[
index
];
struct
ContextLookupContext
lookup_context
=
{
struct
Context
Apply
LookupContext
lookup_context
=
{
{
match_class
,
apply_func
},
&
class_def
};
...
...
@@ -608,8 +720,18 @@ struct ContextFormat3
inline
bool
closure
(
hb_closure_context_t
*
c
,
closure_lookup_func_t
closure_func
)
const
{
TRACE_CLOSURE
();
/* TODO FILLME */
return
false
;
if
(
!
(
this
+
coverage
[
0
]).
intersects
(
c
->
glyphs
))
return
false
;
const
LookupRecord
*
lookupRecord
=
&
StructAtOffset
<
LookupRecord
>
(
coverage
,
coverage
[
0
].
static_size
*
glyphCount
);
struct
ContextClosureLookupContext
lookup_context
=
{
{
intersects_coverage
,
closure_func
},
this
};
return
context_closure_lookup
(
c
,
glyphCount
,
(
const
USHORT
*
)
(
coverage
+
1
),
lookupCount
,
lookupRecord
,
lookup_context
);
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
apply_lookup_func_t
apply_func
)
const
...
...
@@ -620,14 +742,14 @@ struct ContextFormat3
return
false
;
const
LookupRecord
*
lookupRecord
=
&
StructAtOffset
<
LookupRecord
>
(
coverage
,
coverage
[
0
].
static_size
*
glyphCount
);
struct
ContextLookupContext
lookup_context
=
{
struct
Context
Apply
LookupContext
lookup_context
=
{
{
match_coverage
,
apply_func
},
this
};
return
context_lookup
(
c
,
glyphCount
,
(
const
USHORT
*
)
(
coverage
+
1
),
lookupCount
,
lookupRecord
,
lookup_context
);
return
context_
apply_
lookup
(
c
,
glyphCount
,
(
const
USHORT
*
)
(
coverage
+
1
),
lookupCount
,
lookupRecord
,
lookup_context
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
...
...
@@ -704,22 +826,53 @@ struct Context
/* Chaining Contextual lookups */
struct
ChainContextLookupContext
struct
ChainContext
Closure
LookupContext
{
ContextFuncs
funcs
;
ContextClosureFuncs
funcs
;
const
void
*
intersects_data
[
3
];
};
struct
ChainContextApplyLookupContext
{
ContextApplyFuncs
funcs
;
const
void
*
match_data
[
3
];
};
static
inline
bool
chain_context_lookup
(
hb_apply_context_t
*
c
,
unsigned
int
backtrackCount
,
const
USHORT
backtrack
[],
unsigned
int
inputCount
,
/* Including the first glyph (not matched) */
const
USHORT
input
[],
/* Array of input values--start with second glyph */
unsigned
int
lookaheadCount
,
const
USHORT
lookahead
[],
unsigned
int
lookupCount
,
const
LookupRecord
lookupRecord
[],
ChainContextLookupContext
&
lookup_context
)
static
inline
bool
chain_context_closure_lookup
(
hb_closure_context_t
*
c
,
unsigned
int
backtrackCount
,
const
USHORT
backtrack
[],
unsigned
int
inputCount
,
/* Including the first glyph (not matched) */
const
USHORT
input
[],
/* Array of input values--start with second glyph */
unsigned
int
lookaheadCount
,
const
USHORT
lookahead
[],
unsigned
int
lookupCount
,
const
LookupRecord
lookupRecord
[],
ChainContextClosureLookupContext
&
lookup_context
)
{
return
intersects_array
(
c
,
backtrackCount
,
backtrack
,
lookup_context
.
funcs
.
intersects
,
lookup_context
.
intersects_data
[
0
])
&&
intersects_array
(
c
,
inputCount
?
inputCount
-
1
:
0
,
input
,
lookup_context
.
funcs
.
intersects
,
lookup_context
.
intersects_data
[
1
])
&&
intersects_array
(
c
,
lookaheadCount
,
lookahead
,
lookup_context
.
funcs
.
intersects
,
lookup_context
.
intersects_data
[
2
])
&&
closure_lookup
(
c
,
lookupCount
,
lookupRecord
,
lookup_context
.
funcs
.
closure
);
}
static
inline
bool
chain_context_apply_lookup
(
hb_apply_context_t
*
c
,
unsigned
int
backtrackCount
,
const
USHORT
backtrack
[],
unsigned
int
inputCount
,
/* Including the first glyph (not matched) */
const
USHORT
input
[],
/* Array of input values--start with second glyph */
unsigned
int
lookaheadCount
,
const
USHORT
lookahead
[],
unsigned
int
lookupCount
,
const
LookupRecord
lookupRecord
[],
ChainContextApplyLookupContext
&
lookup_context
)
{
/* First guess */
if
(
unlikely
(
c
->
buffer
->
backtrack_len
()
<
backtrackCount
||
...
...
@@ -750,18 +903,33 @@ struct ChainRule
friend
struct
ChainRuleSet
;
private:
inline
bool
apply
(
hb_apply_context_t
*
c
,
ChainContextLookupContext
&
lookup_context
)
const
inline
bool
closure
(
hb_closure_context_t
*
c
,
ChainContextClosureLookupContext
&
lookup_context
)
const
{
TRACE_CLOSURE
();
const
HeadlessArrayOf
<
USHORT
>
&
input
=
StructAfter
<
HeadlessArrayOf
<
USHORT
>
>
(
backtrack
);
const
ArrayOf
<
USHORT
>
&
lookahead
=
StructAfter
<
ArrayOf
<
USHORT
>
>
(
input
);
const
ArrayOf
<
LookupRecord
>
&
lookup
=
StructAfter
<
ArrayOf
<
LookupRecord
>
>
(
lookahead
);
return
chain_context_closure_lookup
(
c
,
backtrack
.
len
,
backtrack
.
array
,
input
.
len
,
input
.
array
,
lookahead
.
len
,
lookahead
.
array
,
lookup
.
len
,
lookup
.
array
,
lookup_context
);
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
ChainContextApplyLookupContext
&
lookup_context
)
const
{
TRACE_APPLY
();
const
HeadlessArrayOf
<
USHORT
>
&
input
=
StructAfter
<
HeadlessArrayOf
<
USHORT
>
>
(
backtrack
);
const
ArrayOf
<
USHORT
>
&
lookahead
=
StructAfter
<
ArrayOf
<
USHORT
>
>
(
input
);
const
ArrayOf
<
LookupRecord
>
&
lookup
=
StructAfter
<
ArrayOf
<
LookupRecord
>
>
(
lookahead
);
return
chain_context_lookup
(
c
,
backtrack
.
len
,
backtrack
.
array
,
input
.
len
,
input
.
array
,
lookahead
.
len
,
lookahead
.
array
,
lookup
.
len
,
lookup
.
array
,
lookup_context
);
return
chain_context_
apply_
lookup
(
c
,
backtrack
.
len
,
backtrack
.
array
,
input
.
len
,
input
.
array
,
lookahead
.
len
,
lookahead
.
array
,
lookup
.
len
,
lookup
.
array
,
lookup_context
);
}
public:
...
...
@@ -796,7 +964,17 @@ struct ChainRule
struct
ChainRuleSet
{
inline
bool
apply
(
hb_apply_context_t
*
c
,
ChainContextLookupContext
&
lookup_context
)
const
inline
bool
closure
(
hb_closure_context_t
*
c
,
ChainContextClosureLookupContext
&
lookup_context
)
const
{
TRACE_CLOSURE
();
bool
ret
=
false
;
unsigned
int
num_rules
=
rule
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
num_rules
;
i
++
)
ret
=
(
this
+
rule
[
i
]).
closure
(
c
,
lookup_context
)
||
ret
;
return
ret
;
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
ChainContextApplyLookupContext
&
lookup_context
)
const
{
TRACE_APPLY
();
unsigned
int
num_rules
=
rule
.
len
;
...
...
@@ -831,8 +1009,21 @@ struct ChainContextFormat1
inline
bool
closure
(
hb_closure_context_t
*
c
,
closure_lookup_func_t
closure_func
)
const
{
TRACE_CLOSURE
();
/* TODO FILLME */
return
false
;
const
Coverage
&
cov
=
(
this
+
coverage
);
struct
ChainContextClosureLookupContext
lookup_context
=
{
{
intersects_glyph
,
closure_func
},
{
NULL
,
NULL
,
NULL
}
};
bool
ret
=
false
;
unsigned
int
count
=
ruleSet
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
cov
.
intersects_coverage
(
c
->
glyphs
,
i
))
{
const
ChainRuleSet
&
rule_set
=
this
+
ruleSet
[
i
];
ret
=
rule_set
.
closure
(
c
,
lookup_context
)
||
ret
;
}
return
ret
;
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
apply_lookup_func_t
apply_func
)
const
...
...
@@ -843,7 +1034,7 @@ struct ChainContextFormat1
return
false
;
const
ChainRuleSet
&
rule_set
=
this
+
ruleSet
[
index
];
struct
ChainContextLookupContext
lookup_context
=
{
struct
ChainContext
Apply
LookupContext
lookup_context
=
{
{
match_glyph
,
apply_func
},
{
NULL
,
NULL
,
NULL
}
};
...
...
@@ -877,8 +1068,28 @@ struct ChainContextFormat2
inline
bool
closure
(
hb_closure_context_t
*
c
,
closure_lookup_func_t
closure_func
)
const
{
TRACE_CLOSURE
();
/* TODO FILLME */
return
false
;
if
(
!
(
this
+
coverage
).
intersects
(
c
->
glyphs
))
return
false
;
const
ClassDef
&
backtrack_class_def
=
this
+
backtrackClassDef
;
const
ClassDef
&
input_class_def
=
this
+
inputClassDef
;
const
ClassDef
&
lookahead_class_def
=
this
+
lookaheadClassDef
;
struct
ChainContextClosureLookupContext
lookup_context
=
{
{
intersects_class
,
closure_func
},
{
&
backtrack_class_def
,
&
input_class_def
,
&
lookahead_class_def
}
};
bool
ret
=
false
;
unsigned
int
count
=
ruleSet
.
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
input_class_def
.
intersects_class
(
c
->
glyphs
,
i
))
{
const
ChainRuleSet
&
rule_set
=
this
+
ruleSet
[
i
];
ret
=
rule_set
.
closure
(
c
,
lookup_context
)
||
ret
;
}
return
ret
;
}
inline
bool
apply
(
hb_apply_context_t
*
c
,
apply_lookup_func_t
apply_func
)
const
...
...
@@ -894,7 +1105,7 @@ struct ChainContextFormat2
index
=
input_class_def
(
c
->
buffer
->
info
[
c
->
buffer
->
idx
].
codepoint
);
const
ChainRuleSet
&
rule_set
=
this
+
ruleSet
[
index
];
struct
ChainContextLookupContext
lookup_context
=
{
struct
ChainContext
Apply
LookupContext
lookup_context
=
{
{
match_class
,
apply_func
},
{
&
backtrack_class_def
,
&
input_class_def
,
...
...
@@ -960,16 +1171,16 @@ struct ChainContextFormat3
const
OffsetArrayOf
<
Coverage
>
&
lookahead
=
StructAfter
<
OffsetArrayOf
<
Coverage
>
>
(
input
);
const
ArrayOf
<
LookupRecord
>
&
lookup
=
StructAfter
<
ArrayOf
<
LookupRecord
>
>
(
lookahead
);
struct
ChainContextLookupContext
lookup_context
=
{
struct
ChainContext
Apply
LookupContext
lookup_context
=
{
{
match_coverage
,
apply_func
},
{
this
,
this
,
this
}
};
return
chain_context_lookup
(
c
,
backtrack
.
len
,
(
const
USHORT
*
)
backtrack
.
array
,
input
.
len
,
(
const
USHORT
*
)
input
.
array
+
1
,
lookahead
.
len
,
(
const
USHORT
*
)
lookahead
.
array
,
lookup
.
len
,
lookup
.
array
,
lookup_context
);
return
chain_context_
apply_
lookup
(
c
,
backtrack
.
len
,
(
const
USHORT
*
)
backtrack
.
array
,
input
.
len
,
(
const
USHORT
*
)
input
.
array
+
1
,
lookahead
.
len
,
(
const
USHORT
*
)
lookahead
.
array
,
lookup
.
len
,
lookup
.
array
,
lookup_context
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
...
...
src/hb-ot-layout-private.hh
浏览文件 @
31081f73
...
...
@@ -100,11 +100,8 @@ struct _hb_glyph_map_t
void
clear
(
void
)
{
memset
(
elts
,
0
,
sizeof
elts
);
}
bool
has
(
hb_codepoint_t
g
)
const
{
if
(
unlikely
(
g
>
MAX_G
))
return
false
;
return
!!
(
elt
(
g
)
&
mask
(
g
));
}
bool
add
(
hb_codepoint_t
g
)
{
bool
add
(
hb_codepoint_t
g
)
{
if
(
unlikely
(
g
>
MAX_G
))
return
false
;
elt_t
&
e
=
elt
(
g
);
elt_t
m
=
mask
(
g
);
...
...
@@ -112,6 +109,22 @@ struct _hb_glyph_map_t
e
|=
m
;
return
ret
;
}
bool
has
(
hb_codepoint_t
g
)
const
{
if
(
unlikely
(
g
>
MAX_G
))
return
false
;
return
!!
(
elt
(
g
)
&
mask
(
g
));
}
bool
intersects
(
hb_codepoint_t
first
,
hb_codepoint_t
last
)
const
{
if
(
unlikely
(
first
>
MAX_G
))
return
false
;
if
(
unlikely
(
last
>
MAX_G
))
last
=
MAX_G
;
unsigned
int
end
=
last
+
1
;
for
(
hb_codepoint_t
i
=
first
;
i
<
end
;
i
++
)
if
(
has
(
i
))
return
true
;
return
false
;
}
private:
typedef
uint32_t
elt_t
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录