Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
2d15e72c
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看板
提交
2d15e72c
编写于
4月 15, 2009
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Give it a start at GSUB
上级
c4473359
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
253 addition
and
45 deletion
+253
-45
src/hb-common.h
src/hb-common.h
+4
-1
src/hb-ot-layout-gdef-private.h
src/hb-ot-layout-gdef-private.h
+12
-12
src/hb-ot-layout-gsub-private.h
src/hb-ot-layout-gsub-private.h
+119
-1
src/hb-ot-layout-open-private.h
src/hb-ot-layout-open-private.h
+30
-21
src/hb-ot-layout-private.h
src/hb-ot-layout-private.h
+1
-1
src/hb-ot-layout.cc
src/hb-ot-layout.cc
+59
-4
src/hb-ot-layout.h
src/hb-ot-layout.h
+26
-3
src/main.cc
src/main.cc
+2
-2
未找到文件。
src/hb-common.h
浏览文件 @
2d15e72c
...
@@ -46,6 +46,9 @@ typedef uint32_t hb_tag_t;
...
@@ -46,6 +46,9 @@ typedef uint32_t hb_tag_t;
((const char *) s)[2], \
((const char *) s)[2], \
((const char *) s)[3]))
((const char *) s)[3]))
typedef
uint16_t
hb_glyph_t
;
typedef
uint32_t
hb_codepoint_t
;
/* XXX */
typedef
struct
HB_BufferRec_
hb_buffer_t
;
#endif
/* HB_COMMON_H */
#endif
/* HB_COMMON_H */
src/hb-ot-layout-gdef-private.h
浏览文件 @
2d15e72c
...
@@ -33,18 +33,18 @@
...
@@ -33,18 +33,18 @@
#define DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP(Type, name) \
#define DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP(Type, name) \
inline const Type& name (hb_
glyph_t glyph_id
) { \
inline const Type& name (hb_
codepoint_t glyph
) { \
const Coverage &c = get_coverage (); \
const Coverage &c = get_coverage (); \
hb_ot_layout_coverage_t c_index = c.get_coverage (glyph
_id
); \
hb_ot_layout_coverage_t c_index = c.get_coverage (glyph); \
return (*this)[c_index]; \
return (*this)[c_index]; \
}
}
struct
GlyphClassDef
:
ClassDef
{
struct
GlyphClassDef
:
ClassDef
{
static
const
u
int16_
t
BaseGlyph
=
0x0001u
;
static
const
u
nsigned
in
t
BaseGlyph
=
0x0001u
;
static
const
u
int16_t
LigatureGlyph
=
0x0002u
;
static
const
u
nsigned
int
LigatureGlyph
=
0x0002u
;
static
const
u
int16_
t
MarkGlyph
=
0x0003u
;
static
const
u
nsigned
in
t
MarkGlyph
=
0x0003u
;
static
const
u
int16_t
ComponentGlyph
=
0x0004u
;
static
const
u
nsigned
int
ComponentGlyph
=
0x0004u
;
};
};
/*
/*
...
@@ -72,7 +72,7 @@ struct AttachList {
...
@@ -72,7 +72,7 @@ struct AttachList {
friend
struct
GDEF
;
friend
struct
GDEF
;
private:
private:
/* const AttachPoint& get_attach_points (hb_
glyph_t glyph_id
); */
/* const AttachPoint& get_attach_points (hb_
codepoint_t glyph
); */
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP
(
AttachPoint
,
get_attach_points
);
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP
(
AttachPoint
,
get_attach_points
);
private:
private:
...
@@ -205,7 +205,7 @@ struct LigCaretList {
...
@@ -205,7 +205,7 @@ struct LigCaretList {
friend
struct
GDEF
;
friend
struct
GDEF
;
private:
private:
/* const LigGlyph& get_lig_glyph (hb_
glyph_t glyph_id
); */
/* const LigGlyph& get_lig_glyph (hb_
codepoint_t glyph
); */
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP
(
LigGlyph
,
get_lig_glyph
);
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP
(
LigGlyph
,
get_lig_glyph
);
private:
private:
...
@@ -245,12 +245,12 @@ struct GDEF {
...
@@ -245,12 +245,12 @@ struct GDEF {
DEFINE_GET_HAS_ACCESSOR
(
LigCaretList
,
lig_caret_list
,
ligCaretList
);
DEFINE_GET_HAS_ACCESSOR
(
LigCaretList
,
lig_caret_list
,
ligCaretList
);
DEFINE_GET_HAS_ACCESSOR
(
ClassDef
,
mark_attachment_types
,
markAttachClassDef
);
DEFINE_GET_HAS_ACCESSOR
(
ClassDef
,
mark_attachment_types
,
markAttachClassDef
);
inline
hb_ot_layout_class_t
get_glyph_class
(
hb_
glyph_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_glyph_class
(
hb_
codepoint_t
glyph
)
const
{
return
get_glyph_classes
().
get_class
(
glyph
_id
);
return
get_glyph_classes
().
get_class
(
glyph
);
}
}
inline
hb_ot_layout_class_t
get_mark_attachment_type
(
hb_
glyph_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_mark_attachment_type
(
hb_
codepoint_t
glyph
)
const
{
return
get_mark_attachment_types
().
get_class
(
glyph
_id
);
return
get_mark_attachment_types
().
get_class
(
glyph
);
}
}
/* TODO get_attach and get_lig_caret */
/* TODO get_attach and get_lig_caret */
...
...
src/hb-ot-layout-gsub-private.h
浏览文件 @
2d15e72c
...
@@ -34,7 +34,17 @@
...
@@ -34,7 +34,17 @@
struct
SingleSubstFormat1
{
struct
SingleSubstFormat1
{
/* TODO */
friend
struct
SingleSubst
;
private:
inline
bool
substitute
(
hb_ot_layout_t
*
layout
,
hb_buffer_t
*
buffer
,
unsigned
int
context_length
,
unsigned
int
nesting_level_left
)
const
{
// if (get_coverage (IN_CURGLYPH()))
// return ;
}
private:
private:
USHORT
substFormat
;
/* Format identifier--format = 1 */
USHORT
substFormat
;
/* Format identifier--format = 1 */
...
@@ -449,6 +459,108 @@ struct ReverseChainSingleSubstFormat1 {
...
@@ -449,6 +459,108 @@ struct ReverseChainSingleSubstFormat1 {
};
};
ASSERT_SIZE
(
ReverseChainSingleSubstFormat1
,
10
);
ASSERT_SIZE
(
ReverseChainSingleSubstFormat1
,
10
);
/*
* SubstLookup
*/
struct
SubstLookupSubTable
{
DEFINE_NON_INSTANTIABLE
(
SubstLookupSubTable
);
friend
struct
SubstLookup
;
unsigned
int
get_size
(
unsigned
int
lookup_type
)
const
{
switch
(
lookup_type
)
{
// case 1: return u.format1.get_size ();
// case 2: return u.format2.get_size ();
/*
case Single:
case Multiple:
case Alternate:
case Ligature:
case Context:
case ChainingContext:
case Extension:
case ReverseChainingContextSingle:
*/
default:
return
sizeof
(
LookupSubTable
);
}
}
inline
bool
substitute
(
hb_ot_layout_t
*
layout
,
hb_buffer_t
*
buffer
,
unsigned
int
context_length
,
unsigned
int
nesting_level_left
,
unsigned
int
lookup_type
)
const
{
}
private:
union
{
USHORT
substFormat
;
CoverageFormat1
format1
;
CoverageFormat2
format2
;
}
u
;
};
struct
SubstLookup
:
Lookup
{
DEFINE_NON_INSTANTIABLE
(
SubstLookup
);
static
const
unsigned
int
Single
=
1
;
static
const
unsigned
int
Multiple
=
2
;
static
const
unsigned
int
Alternate
=
3
;
static
const
unsigned
int
Ligature
=
4
;
static
const
unsigned
int
Context
=
5
;
static
const
unsigned
int
ChainingContext
=
6
;
static
const
unsigned
int
Extension
=
7
;
static
const
unsigned
int
ReverseChainingContextSingle
=
8
;
inline
const
SubstLookupSubTable
&
get_subtable
(
unsigned
int
i
)
const
{
return
*
(
SubstLookupSubTable
*
)
&
(((
Lookup
*
)
this
)
->
get_subtable
(
i
));
}
/* Like get_type(), but looks through extension lookups.
* Never returns SubstLookup::Extension */
inline
unsigned
int
get_effective_type
(
void
)
const
{
unsigned
int
type
=
get_type
();
if
(
HB_UNLIKELY
(
type
==
Extension
))
{
/* Return lookup type of first extension subtable.
* The spec says all of them should have the same type.
* XXX check for that somehow */
//XXX type = get_subtable(0).v.extension.get_type ();
}
return
type
;
}
inline
bool
is_reverse
(
void
)
const
{
switch
(
get_effective_type
())
{
case
ReverseChainingContextSingle
:
return
true
;
default:
return
false
;
}
}
inline
bool
substitute
(
hb_ot_layout_t
*
layout
,
hb_buffer_t
*
buffer
,
unsigned
int
context_length
,
unsigned
int
nesting_level_left
)
const
{
unsigned
int
lookup_type
=
get_type
();
if
(
HB_UNLIKELY
(
nesting_level_left
==
0
))
return
false
;
nesting_level_left
--
;
for
(
unsigned
int
i
=
0
;
i
<
get_subtable_count
();
i
++
)
if
(
get_subtable
(
i
).
substitute
(
layout
,
buffer
,
context_length
,
nesting_level_left
,
lookup_type
))
return
true
;
return
false
;
}
};
DEFINE_NULL_ALIAS
(
SubstLookup
,
Lookup
);
/*
/*
* GSUB
* GSUB
*/
*/
...
@@ -458,6 +570,12 @@ struct GSUB : GSUBGPOS {
...
@@ -458,6 +570,12 @@ struct GSUB : GSUBGPOS {
STATIC_DEFINE_GET_FOR_DATA
(
GSUB
);
STATIC_DEFINE_GET_FOR_DATA
(
GSUB
);
/* XXX check version here? */
/* XXX check version here? */
inline
const
SubstLookup
&
get_lookup
(
unsigned
int
i
)
const
{
return
*
(
SubstLookup
*
)
&
(((
GSUBGPOS
*
)
this
)
->
get_lookup
(
i
));
}
};
};
DEFINE_NULL_ALIAS
(
GSUB
,
GSUBGPOS
);
DEFINE_NULL_ALIAS
(
GSUB
,
GSUBGPOS
);
...
...
src/hb-ot-layout-open-private.h
浏览文件 @
2d15e72c
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#define NO_INDEX ((unsigned int) 0xFFFF)
#define NO_INDEX ((unsigned int) 0xFFFF)
#define NO_CONTEXT ((unsigned int) -1)
/*
/*
* Int types
* Int types
...
@@ -191,7 +192,7 @@
...
@@ -191,7 +192,7 @@
/* makes class uninstantiable. should be used for union classes that don't
/* makes class uninstantiable. should be used for union classes that don't
* contain any complete type */
* contain any complete type */
#define DEFINE_NON_INSTANTIABLE(Type) \
#define DEFINE_NON_INSTANTIABLE(Type) \
pr
ivate
: inline Type() {}
/* cannot be instantiated */
\
pr
otected
: inline Type() {}
/* cannot be instantiated */
\
public:
public:
// TODO use a global nul-array for most Null's
// TODO use a global nul-array for most Null's
...
@@ -236,6 +237,7 @@
...
@@ -236,6 +237,7 @@
/*
/*
*
*
* The OpenType Font File
* The OpenType Font File
...
@@ -642,12 +644,12 @@ struct FeatureList {
...
@@ -642,12 +644,12 @@ struct FeatureList {
DEFINE_NULL_ASSERT_SIZE
(
FeatureList
,
2
);
DEFINE_NULL_ASSERT_SIZE
(
FeatureList
,
2
);
struct
LookupFlag
:
USHORT
{
struct
LookupFlag
:
USHORT
{
static
const
u
int16_
t
RightToLeft
=
0x0001u
;
static
const
u
nsigned
in
t
RightToLeft
=
0x0001u
;
static
const
u
int16_
t
IgnoreBaseGlyphs
=
0x0002u
;
static
const
u
nsigned
in
t
IgnoreBaseGlyphs
=
0x0002u
;
static
const
u
int16_t
IgnoreLigatures
=
0x0004u
;
static
const
u
nsigned
int
IgnoreLigatures
=
0x0004u
;
static
const
u
int16_
t
IgnoreMarks
=
0x0008u
;
static
const
u
nsigned
in
t
IgnoreMarks
=
0x0008u
;
static
const
u
int16_
t
Reserved
=
0x00F0u
;
static
const
u
nsigned
in
t
Reserved
=
0x00F0u
;
static
const
u
int16_
t
MarkAttachmentType
=
0xFF00u
;
static
const
u
nsigned
in
t
MarkAttachmentType
=
0xFF00u
;
};
};
DEFINE_NULL_ASSERT_SIZE
(
LookupFlag
,
2
);
DEFINE_NULL_ASSERT_SIZE
(
LookupFlag
,
2
);
...
@@ -661,8 +663,9 @@ DEFINE_NULL_ASSERT_SIZE (LookupSubTable, 2);
...
@@ -661,8 +663,9 @@ DEFINE_NULL_ASSERT_SIZE (LookupSubTable, 2);
struct
Lookup
{
struct
Lookup
{
/* SubTables, in the desired order */
DEFINE_NON_INSTANTIABLE
(
Lookup
);
DEFINE_OFFSET_ARRAY_TYPE
(
LookupSubTable
,
subTableOffset
,
subTableCount
);
DEFINE_ARRAY_INTERFACE
(
LookupSubTable
,
subtable
);
/* get_subtable_count(), get_subtable(i) */
inline
bool
is_right_to_left
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
RightToLeft
;
}
inline
bool
is_right_to_left
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
RightToLeft
;
}
inline
bool
ignore_base_glyphs
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
IgnoreBaseGlyphs
;
}
inline
bool
ignore_base_glyphs
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
IgnoreBaseGlyphs
;
}
...
@@ -670,10 +673,14 @@ struct Lookup {
...
@@ -670,10 +673,14 @@ struct Lookup {
inline
bool
ignore_marks
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
IgnoreMarks
;
}
inline
bool
ignore_marks
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
IgnoreMarks
;
}
inline
bool
get_mark_attachment_type
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
MarkAttachmentType
;
}
inline
bool
get_mark_attachment_type
(
void
)
const
{
return
lookupFlag
&
LookupFlag
::
MarkAttachmentType
;
}
inline
u
int16_
t
get_type
(
void
)
const
{
return
lookupType
;
}
inline
u
nsigned
in
t
get_type
(
void
)
const
{
return
lookupType
;
}
inline
u
int16_
t
get_flag
(
void
)
const
{
return
lookupFlag
;
}
inline
u
nsigned
in
t
get_flag
(
void
)
const
{
return
lookupFlag
;
}
private:
private:
/* SubTables, in the desired order */
DEFINE_OFFSET_ARRAY_TYPE
(
LookupSubTable
,
subTableOffset
,
subTableCount
);
protected:
USHORT
lookupType
;
/* Different enumerations for GSUB and GPOS */
USHORT
lookupType
;
/* Different enumerations for GSUB and GPOS */
USHORT
lookupFlag
;
/* Lookup qualifiers */
USHORT
lookupFlag
;
/* Lookup qualifiers */
USHORT
subTableCount
;
/* Number of SubTables for this lookup */
USHORT
subTableCount
;
/* Number of SubTables for this lookup */
...
@@ -710,8 +717,10 @@ struct CoverageFormat1 {
...
@@ -710,8 +717,10 @@ struct CoverageFormat1 {
/* GlyphIDs, in sorted numerical order */
/* GlyphIDs, in sorted numerical order */
DEFINE_ARRAY_TYPE
(
GlyphID
,
glyphArray
,
glyphCount
);
DEFINE_ARRAY_TYPE
(
GlyphID
,
glyphArray
,
glyphCount
);
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_
glyph
_t
glyph_id
)
const
{
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_
codepoint
_t
glyph_id
)
const
{
GlyphID
gid
;
GlyphID
gid
;
if
(
HB_UNLIKELY
(
glyph_id
>
65535
))
return
-
1
;
gid
=
glyph_id
;
gid
=
glyph_id
;
// TODO: bsearch
// TODO: bsearch
for
(
unsigned
int
i
=
0
;
i
<
glyphCount
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
glyphCount
;
i
++
)
...
@@ -732,7 +741,7 @@ struct CoverageRangeRecord {
...
@@ -732,7 +741,7 @@ struct CoverageRangeRecord {
friend
struct
CoverageFormat2
;
friend
struct
CoverageFormat2
;
private:
private:
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_
glyph
_t
glyph_id
)
const
{
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_
codepoint
_t
glyph_id
)
const
{
if
(
glyph_id
>=
start
&&
glyph_id
<=
end
)
if
(
glyph_id
>=
start
&&
glyph_id
<=
end
)
return
startCoverageIndex
+
(
glyph_id
-
start
);
return
startCoverageIndex
+
(
glyph_id
-
start
);
return
-
1
;
return
-
1
;
...
@@ -754,7 +763,7 @@ struct CoverageFormat2 {
...
@@ -754,7 +763,7 @@ struct CoverageFormat2 {
/* CoverageRangeRecords, in sorted numerical start order */
/* CoverageRangeRecords, in sorted numerical start order */
DEFINE_ARRAY_TYPE
(
CoverageRangeRecord
,
rangeRecord
,
rangeCount
);
DEFINE_ARRAY_TYPE
(
CoverageRangeRecord
,
rangeRecord
,
rangeCount
);
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_
glyph
_t
glyph_id
)
const
{
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_
codepoint
_t
glyph_id
)
const
{
// TODO: bsearch
// TODO: bsearch
for
(
unsigned
int
i
=
0
;
i
<
rangeCount
;
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
rangeCount
;
i
++
)
{
int
coverage
=
rangeRecord
[
i
].
get_coverage
(
glyph_id
);
int
coverage
=
rangeRecord
[
i
].
get_coverage
(
glyph_id
);
...
@@ -784,7 +793,7 @@ struct Coverage {
...
@@ -784,7 +793,7 @@ struct Coverage {
}
}
}
}
hb_ot_layout_coverage_t
get_coverage
(
hb_
glyph
_t
glyph_id
)
const
{
hb_ot_layout_coverage_t
get_coverage
(
hb_
codepoint
_t
glyph_id
)
const
{
switch
(
u
.
coverageFormat
)
{
switch
(
u
.
coverageFormat
)
{
case
1
:
return
u
.
format1
.
get_coverage
(
glyph_id
);
case
1
:
return
u
.
format1
.
get_coverage
(
glyph_id
);
case
2
:
return
u
.
format2
.
get_coverage
(
glyph_id
);
case
2
:
return
u
.
format2
.
get_coverage
(
glyph_id
);
...
@@ -813,7 +822,7 @@ struct ClassDefFormat1 {
...
@@ -813,7 +822,7 @@ struct ClassDefFormat1 {
/* GlyphIDs, in sorted numerical order */
/* GlyphIDs, in sorted numerical order */
DEFINE_ARRAY_TYPE
(
USHORT
,
classValueArray
,
glyphCount
);
DEFINE_ARRAY_TYPE
(
USHORT
,
classValueArray
,
glyphCount
);
inline
hb_ot_layout_class_t
get_class
(
hb_
glyph
_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_class
(
hb_
codepoint
_t
glyph_id
)
const
{
if
(
glyph_id
>=
startGlyph
&&
glyph_id
-
startGlyph
<
glyphCount
)
if
(
glyph_id
>=
startGlyph
&&
glyph_id
-
startGlyph
<
glyphCount
)
return
classValueArray
[
glyph_id
-
startGlyph
];
return
classValueArray
[
glyph_id
-
startGlyph
];
return
0
;
return
0
;
...
@@ -832,7 +841,7 @@ struct ClassRangeRecord {
...
@@ -832,7 +841,7 @@ struct ClassRangeRecord {
friend
struct
ClassDefFormat2
;
friend
struct
ClassDefFormat2
;
private:
private:
inline
hb_ot_layout_class_t
get_class
(
hb_
glyph
_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_class
(
hb_
codepoint
_t
glyph_id
)
const
{
if
(
glyph_id
>=
start
&&
glyph_id
<=
end
)
if
(
glyph_id
>=
start
&&
glyph_id
<=
end
)
return
classValue
;
return
classValue
;
return
0
;
return
0
;
...
@@ -853,9 +862,9 @@ struct ClassDefFormat2 {
...
@@ -853,9 +862,9 @@ struct ClassDefFormat2 {
/* ClassRangeRecords, in sorted numerical start order */
/* ClassRangeRecords, in sorted numerical start order */
DEFINE_ARRAY_TYPE
(
ClassRangeRecord
,
rangeRecord
,
rangeCount
);
DEFINE_ARRAY_TYPE
(
ClassRangeRecord
,
rangeRecord
,
rangeCount
);
inline
hb_ot_layout_class_t
get_class
(
hb_
glyph
_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_class
(
hb_
codepoint
_t
glyph_id
)
const
{
// TODO: bsearch
// TODO: bsearch
for
(
int
i
=
0
;
i
<
rangeCount
;
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
rangeCount
;
i
++
)
{
int
classValue
=
rangeRecord
[
i
].
get_class
(
glyph_id
);
int
classValue
=
rangeRecord
[
i
].
get_class
(
glyph_id
);
if
(
classValue
>
0
)
if
(
classValue
>
0
)
return
classValue
;
return
classValue
;
...
@@ -882,7 +891,7 @@ struct ClassDef {
...
@@ -882,7 +891,7 @@ struct ClassDef {
}
}
}
}
hb_ot_layout_class_t
get_class
(
hb_
glyph
_t
glyph_id
)
const
{
hb_ot_layout_class_t
get_class
(
hb_
codepoint
_t
glyph_id
)
const
{
switch
(
u
.
classFormat
)
{
switch
(
u
.
classFormat
)
{
case
1
:
return
u
.
format1
.
get_class
(
glyph_id
);
case
1
:
return
u
.
format1
.
get_class
(
glyph_id
);
case
2
:
return
u
.
format2
.
get_class
(
glyph_id
);
case
2
:
return
u
.
format2
.
get_class
(
glyph_id
);
...
@@ -949,7 +958,7 @@ DEFINE_NULL_ASSERT_SIZE (Device, 6);
...
@@ -949,7 +958,7 @@ DEFINE_NULL_ASSERT_SIZE (Device, 6);
* GSUB/GPOS Common
* GSUB/GPOS Common
*/
*/
typedef
struct
GSUBGPOS
{
struct
GSUBGPOS
{
static
const
hb_tag_t
GSUBTag
=
HB_TAG
(
'G'
,
'S'
,
'U'
,
'B'
);
static
const
hb_tag_t
GSUBTag
=
HB_TAG
(
'G'
,
'S'
,
'U'
,
'B'
);
static
const
hb_tag_t
GPOSTag
=
HB_TAG
(
'G'
,
'P'
,
'O'
,
'S'
);
static
const
hb_tag_t
GPOSTag
=
HB_TAG
(
'G'
,
'P'
,
'O'
,
'S'
);
...
...
src/hb-ot-layout-private.h
浏览文件 @
2d15e72c
...
@@ -53,7 +53,7 @@ _hb_ot_layout_has_new_glyph_classes (hb_ot_layout_t *layout);
...
@@ -53,7 +53,7 @@ _hb_ot_layout_has_new_glyph_classes (hb_ot_layout_t *layout);
HB_OT_LAYOUT_INTERNAL
hb_ot_layout_glyph_properties_t
HB_OT_LAYOUT_INTERNAL
hb_ot_layout_glyph_properties_t
_hb_ot_layout_get_glyph_properties
(
hb_ot_layout_t
*
layout
,
_hb_ot_layout_get_glyph_properties
(
hb_ot_layout_t
*
layout
,
hb_
glyph_t
glyph
);
hb_
codepoint_t
glyph
);
HB_OT_LAYOUT_INTERNAL
hb_bool_t
HB_OT_LAYOUT_INTERNAL
hb_bool_t
_hb_ot_layout_check_glyph_properties
(
hb_ot_layout_t
*
layout
,
_hb_ot_layout_check_glyph_properties
(
hb_ot_layout_t
*
layout
,
...
...
src/hb-ot-layout.cc
浏览文件 @
2d15e72c
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
#include "hb-ot-layout-gdef-private.h"
#include "hb-ot-layout-gdef-private.h"
#include "hb-ot-layout-gsub-private.h"
#include "hb-ot-layout-gsub-private.h"
/* XXX */
#include "harfbuzz-buffer-private.h"
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
...
@@ -50,6 +52,7 @@ struct _hb_ot_layout_t {
...
@@ -50,6 +52,7 @@ struct _hb_ot_layout_t {
unsigned
int
len
;
unsigned
int
len
;
}
new_gdef
;
}
new_gdef
;
/* TODO add max-nesting-level here? */
};
};
hb_ot_layout_t
*
hb_ot_layout_t
*
...
@@ -109,7 +112,7 @@ _hb_ot_layout_has_new_glyph_classes (hb_ot_layout_t *layout)
...
@@ -109,7 +112,7 @@ _hb_ot_layout_has_new_glyph_classes (hb_ot_layout_t *layout)
HB_OT_LAYOUT_INTERNAL
hb_ot_layout_glyph_properties_t
HB_OT_LAYOUT_INTERNAL
hb_ot_layout_glyph_properties_t
_hb_ot_layout_get_glyph_properties
(
hb_ot_layout_t
*
layout
,
_hb_ot_layout_get_glyph_properties
(
hb_ot_layout_t
*
layout
,
hb_
glyph_t
glyph
)
hb_
codepoint_t
glyph
)
{
{
hb_ot_layout_class_t
klass
;
hb_ot_layout_class_t
klass
;
...
@@ -186,7 +189,7 @@ _hb_ot_layout_check_glyph_properties (hb_ot_layout_t *layout,
...
@@ -186,7 +189,7 @@ _hb_ot_layout_check_glyph_properties (hb_ot_layout_t *layout,
hb_ot_layout_glyph_class_t
hb_ot_layout_glyph_class_t
hb_ot_layout_get_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_get_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_
glyph_t
glyph
)
hb_
codepoint_t
glyph
)
{
{
hb_ot_layout_glyph_properties_t
properties
;
hb_ot_layout_glyph_properties_t
properties
;
hb_ot_layout_class_t
klass
;
hb_ot_layout_class_t
klass
;
...
@@ -201,7 +204,7 @@ hb_ot_layout_get_glyph_class (hb_ot_layout_t *layout,
...
@@ -201,7 +204,7 @@ hb_ot_layout_get_glyph_class (hb_ot_layout_t *layout,
void
void
hb_ot_layout_set_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_set_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_
glyph_t
glyph
,
hb_
codepoint_t
glyph
,
hb_ot_layout_glyph_class_t
klass
)
hb_ot_layout_glyph_class_t
klass
)
{
{
/* TODO optimize this, similar to old harfbuzz code for example */
/* TODO optimize this, similar to old harfbuzz code for example */
...
@@ -243,7 +246,7 @@ hb_ot_layout_set_glyph_class (hb_ot_layout_t *layout,
...
@@ -243,7 +246,7 @@ hb_ot_layout_set_glyph_class (hb_ot_layout_t *layout,
void
void
hb_ot_layout_build_glyph_classes
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_build_glyph_classes
(
hb_ot_layout_t
*
layout
,
uint16_t
num_total_glyphs
,
uint16_t
num_total_glyphs
,
hb_
glyph_t
*
glyphs
,
hb_
codepoint_t
*
glyphs
,
unsigned
char
*
klasses
,
unsigned
char
*
klasses
,
uint16_t
count
)
uint16_t
count
)
{
{
...
@@ -508,3 +511,55 @@ hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t *layout,
...
@@ -508,3 +511,55 @@ hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t *layout,
return
f
.
get_lookup_index
(
num_lookup
);
return
f
.
get_lookup_index
(
num_lookup
);
}
}
/*
* GSUB
*/
hb_bool_t
hb_ot_layout_substitute_lookup
(
hb_ot_layout_t
*
layout
,
hb_buffer_t
*
buffer
,
unsigned
int
lookup_index
,
hb_ot_layout_feature_mask_t
mask
)
{
const
GSUB
&
gsub
=
*
(
layout
->
gsub
);
const
SubstLookup
&
l
=
gsub
.
get_lookup
(
lookup_index
);
unsigned
int
lookup_type
=
l
.
get_type
();
unsigned
int
nesting_level_left
=
HB_OT_LAYOUT_MAX_NESTING_LEVEL
;
unsigned
int
context_length
=
NO_CONTEXT
;
bool
handled
,
ret
=
false
;
if
(
!
l
.
is_reverse
())
{
/* in/out forward substitution */
_hb_buffer_clear_output
(
buffer
);
buffer
->
in_pos
=
0
;
while
(
buffer
->
in_pos
<
buffer
->
in_length
)
{
if
((
~
IN_PROPERTIES
(
buffer
->
in_pos
)
&
mask
)
&&
l
.
substitute
(
layout
,
buffer
,
context_length
,
nesting_level_left
))
ret
=
true
;
else
_hb_buffer_copy_output_glyph
(
buffer
);
}
_hb_buffer_swap
(
buffer
);
}
else
{
/* in-place backward substitution */
buffer
->
in_pos
=
buffer
->
in_length
-
1
;
do
{
if
((
~
IN_PROPERTIES
(
buffer
->
in_pos
)
&
mask
)
&&
l
.
substitute
(
layout
,
buffer
,
context_length
,
nesting_level_left
))
ret
=
true
;
else
buffer
->
in_pos
--
;
}
while
(
buffer
->
in_pos
);
}
return
ret
;
}
src/hb-ot-layout.h
浏览文件 @
2d15e72c
...
@@ -67,17 +67,17 @@ hb_ot_layout_has_font_glyph_classes (hb_ot_layout_t *layout);
...
@@ -67,17 +67,17 @@ hb_ot_layout_has_font_glyph_classes (hb_ot_layout_t *layout);
hb_ot_layout_glyph_class_t
hb_ot_layout_glyph_class_t
hb_ot_layout_get_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_get_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_
glyph_t
glyph
);
hb_
codepoint_t
glyph
);
void
void
hb_ot_layout_set_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_set_glyph_class
(
hb_ot_layout_t
*
layout
,
hb_
glyph_t
glyph
,
hb_
codepoint_t
glyph
,
hb_ot_layout_glyph_class_t
klass
);
hb_ot_layout_glyph_class_t
klass
);
void
void
hb_ot_layout_build_glyph_classes
(
hb_ot_layout_t
*
layout
,
hb_ot_layout_build_glyph_classes
(
hb_ot_layout_t
*
layout
,
uint16_t
num_total_glyphs
,
uint16_t
num_total_glyphs
,
hb_
glyph_t
*
glyphs
,
hb_
codepoint_t
*
glyphs
,
unsigned
char
*
klasses
,
unsigned
char
*
klasses
,
uint16_t
count
);
uint16_t
count
);
...
@@ -91,6 +91,10 @@ typedef enum {
...
@@ -91,6 +91,10 @@ typedef enum {
HB_OT_LAYOUT_TABLE_TYPE_NONE
HB_OT_LAYOUT_TABLE_TYPE_NONE
}
hb_ot_layout_table_type_t
;
}
hb_ot_layout_table_type_t
;
typedef
uint16_t
hb_ot_layout_feature_mask_t
;
#define HB_OT_LAYOUT_MAX_NESTING_LEVEL 100
#define HB_OT_LAYOUT_NO_SCRIPT_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_NO_SCRIPT_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_NO_FEATURE_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_NO_FEATURE_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX ((unsigned int) 0xFFFF)
#define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX ((unsigned int) 0xFFFF)
...
@@ -195,6 +199,25 @@ hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t *layout,
...
@@ -195,6 +199,25 @@ hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t *layout,
unsigned
int
feature_index
,
unsigned
int
feature_index
,
unsigned
int
num_lookup
);
unsigned
int
num_lookup
);
/*
* GSUB
*/
hb_bool_t
hb_ot_layout_substitute_lookup
(
hb_ot_layout_t
*
layout
,
hb_buffer_t
*
buffer
,
unsigned
int
lookup_index
,
hb_ot_layout_feature_mask_t
mask
);
/*
/*
#define PANGO_OT_ALL_GLYPHS ((guint) 0xFFFF)
#define PANGO_OT_ALL_GLYPHS ((guint) 0xFFFF)
...
...
src/main.cc
浏览文件 @
2d15e72c
...
@@ -125,10 +125,10 @@ main (int argc, char **argv)
...
@@ -125,10 +125,10 @@ main (int argc, char **argv)
feature
.
get_lookup_count
());
feature
.
get_lookup_count
());
int
num_lookups
=
feature
.
get_lookup_count
();
int
num_lookups
=
feature
.
get_lookup_count
();
printf
(
" %d lookup(s) found in
language system
\n
"
,
num_lookups
);
printf
(
" %d lookup(s) found in
feature
\n
"
,
num_lookups
);
for
(
int
n_lookup
=
0
;
n_lookup
<
num_lookups
;
n_lookup
++
)
{
for
(
int
n_lookup
=
0
;
n_lookup
<
num_lookups
;
n_lookup
++
)
{
unsigned
int
lookup_index
=
feature
.
get_lookup_index
(
n_lookup
);
unsigned
int
lookup_index
=
feature
.
get_lookup_index
(
n_lookup
);
printf
(
"
Feature
index %2d of %2d: %d
\n
"
,
n_lookup
,
num_lookups
,
printf
(
"
Lookup
index %2d of %2d: %d
\n
"
,
n_lookup
,
num_lookups
,
feature
.
get_lookup_index
(
n_lookup
));
feature
.
get_lookup_index
(
n_lookup
));
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录