Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
808dbe28
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
808dbe28
编写于
12月 25, 2006
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make types not instantiable
上级
b739c05c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
47 deletion
+57
-47
src/hb-types-private.cc
src/hb-types-private.cc
+57
-47
未找到文件。
src/hb-types-private.cc
浏览文件 @
808dbe28
...
...
@@ -26,6 +26,7 @@ typedef uint32_t hb_tag_t;
#define DEFINE_INT_TYPE1(NAME, TYPE, BIG_ENDIAN) \
struct NAME { \
inline NAME (void) { v = 0; } \
inline NAME (TYPE i) { v = BIG_ENDIAN(i); } \
inline NAME& operator = (TYPE i) { v = BIG_ENDIAN(i); return *this; } \
inline operator TYPE(void) const { return BIG_ENDIAN(v); } \
...
...
@@ -52,6 +53,10 @@ struct NAME { \
DEFINE_LEN(Type, array, num) \
DEFINE_SIZE(Type, array, num)
#define DEFINE_NOT_INSTANTIABLE(Type) \
private: inline Type() {}
/* cannot be instantiated */
\
public:
/* An array type is one that contains a variable number of objects
* as its last item. An array object is extended with len() and size()
* methods, as well as overloaded [] operator. */
...
...
@@ -154,6 +159,11 @@ struct Tag {
inline
Tag
(
void
)
{
v
[
0
]
=
v
[
1
]
=
v
[
2
]
=
v
[
3
]
=
0
;
}
inline
Tag
(
const
char
*
c
)
{
v
[
0
]
=
c
[
0
];
v
[
1
]
=
c
[
1
];
v
[
2
]
=
c
[
2
];
v
[
3
]
=
c
[
3
];
}
inline
operator
uint32_t
(
void
)
const
{
return
(
v
[
0
]
<<
24
)
+
(
v
[
1
]
<<
16
)
+
(
v
[
2
]
<<
8
)
+
v
[
3
];
}
\
/* The char* these two return is NOT nul-terminated. Print using "%.4s" */
inline
operator
const
char
*
(
void
)
const
{
return
(
const
char
*
)
this
;
}
inline
operator
char
*
(
void
)
{
return
(
char
*
)
this
;
}
private:
char
v
[
4
];
};
...
...
@@ -199,16 +209,18 @@ struct OpenTypeFontFile;
struct
OffsetTable
;
struct
TTCHeader
;
struct
TableDirectory
{
typedef
struct
TableDirectory
{
Tag
tag
;
/* 4-byte identifier. */
CheckSum
checkSum
;
/* CheckSum for this table. */
ULONG
offset
;
/* Offset from beginning of TrueType font
* file. */
ULONG
length
;
/* Length of this table. */
};
}
OpenTypeTable
;
struct
OffsetTable
{
typedef
struct
OffsetTable
{
DEFINE_NOT_INSTANTIABLE
(
OffsetTable
);
DEFINE_ARRAY_TYPE
(
TableDirectory
,
tableDir
,
numTables
);
// TODO: Implement find_table
Tag
sfnt_version
;
/* '\0\001\0\00' if TrueType / 'OTTO' if CFF */
USHORT
numTables
;
/* Number of tables. */
...
...
@@ -216,14 +228,14 @@ struct OffsetTable {
USHORT
entrySelector
;
/* Log2(maximum power of 2 <= numTables). */
USHORT
rangeShift
;
/* NumTables x 16-searchRange. */
TableDirectory
tableDir
[];
/* TableDirectory entries. numTables items */
};
}
OpenTypeFont
;
/*
* TrueType Collections
*/
struct
TTCHeader
{
DEFINE_NOT_INSTANTIABLE
(
TTCHeader
);
/* This works as an array type because TTCHeader is always located at the
* beginning of the file */
DEFINE_OFFSET_ARRAY_TYPE
(
OffsetTable
,
offsetTable
,
numFonts
);
...
...
@@ -242,57 +254,46 @@ struct TTCHeader {
* OpenType Font File
*/
struct
OpenTypeFontFile
{
Tag
tag
;
/* 4-byte identifier. */
typedef
struct
OpenTypeFontFile
{
DEFINE_NOT_INSTANTIABLE
(
OpenTypeFontFile
);
static
const
hb_tag_t
truetype_tag
=
HB_TAG
(
0
,
1
,
0
,
0
);
static
const
hb_tag_t
cff_tag
=
HB_TAG
(
'O'
,
'T'
,
'T'
,
'O'
);
static
const
hb_tag_t
ttc_tag
=
HB_TAG
(
't'
,
't'
,
'c'
,
'f'
);
unsigned
int
get_len
(
void
)
const
{
/* Factory: ::get(font_data)
* This is how you get a handle to one of these
*/
static
inline
const
OpenTypeFontFile
&
get
(
const
char
*
font_data
)
{
return
(
const
OpenTypeFontFile
&
)
*
font_data
;
}
static
inline
OpenTypeFontFile
&
get
(
char
*
font_data
)
{
return
(
OpenTypeFontFile
&
)
*
font_data
;
}
/* Array interface sans get_size() */
inline
unsigned
int
get_len
(
void
)
const
{
switch
(
tag
)
{
default:
return
0
;
case
HB_TAG
(
0
,
1
,
0
,
0
):
case
HB_TAG
(
'O'
,
'T'
,
'T'
,
'O'
):
return
1
;
case
HB_TAG
(
't'
,
't'
,
'c'
,
'f'
):
const
TTCHeader
&
ttc
=
(
TTCHeader
&
)
*
this
;
return
ttc
.
get_len
();
default:
return
0
;
case
truetype_tag
:
case
cff_tag
:
return
1
;
case
ttc_tag
:
return
((
const
TTCHeader
&
)
*
this
).
get_len
();
}
}
inline
const
OffsetTable
&
operator
[]
(
unsigned
int
i
)
const
{
inline
const
OpenTypeFont
&
operator
[]
(
unsigned
int
i
)
const
{
assert
(
i
<
get_len
());
switch
(
tag
)
{
default:
case
HB_TAG
(
0
,
1
,
0
,
0
):
case
HB_TAG
(
'O'
,
'T'
,
'T'
,
'O'
):
return
(
const
OffsetTable
&
)
*
this
;
case
HB_TAG
(
't'
,
't'
,
'c'
,
'f'
):
const
TTCHeader
&
ttc
=
(
const
TTCHeader
&
)
*
this
;
return
ttc
[
i
];
default:
case
truetype_tag
:
case
cff_tag
:
return
(
const
OffsetTable
&
)
*
this
;
case
ttc_tag
:
return
((
const
TTCHeader
&
)
*
this
)[
i
];
}
}
inline
O
ffsetTable
&
operator
[]
(
unsigned
int
i
)
{
inline
O
penTypeFont
&
operator
[]
(
unsigned
int
i
)
{
assert
(
i
<
get_len
());
switch
(
tag
)
{
default:
case
HB_TAG
(
0
,
1
,
0
,
0
):
case
HB_TAG
(
'O'
,
'T'
,
'T'
,
'O'
):
return
(
OffsetTable
&
)
*
this
;
case
HB_TAG
(
't'
,
't'
,
'c'
,
'f'
):
TTCHeader
&
ttc
=
(
TTCHeader
&
)
*
this
;
return
ttc
[
i
];
default:
case
truetype_tag
:
case
cff_tag
:
return
(
OffsetTable
&
)
*
this
;
case
ttc_tag
:
return
((
TTCHeader
&
)
*
this
)[
i
];
}
}
/* ::get(font_data). This is how you get a handle to one of these */
static
inline
const
OpenTypeFontFile
&
get
(
const
char
*
font_data
)
{
return
(
const
OpenTypeFontFile
&
)
*
font_data
;
}
static
inline
OpenTypeFontFile
&
get
(
char
*
font_data
)
{
return
(
OpenTypeFontFile
&
)
*
font_data
;
}
/* cannot be instantiated */
private:
OpenTypeFontFile
()
{}
Tag
tag
;
/* 4-byte identifier. */
};
...
...
@@ -316,6 +317,7 @@ typedef struct Record {
struct
Script
;
struct
ScriptList
{
DEFINE_NOT_INSTANTIABLE
(
ScriptList
);
DEFINE_RECORD_ARRAY_TYPE
(
Script
,
scriptRecord
,
scriptCount
);
USHORT
scriptCount
;
/* Number of ScriptRecords */
...
...
@@ -324,6 +326,7 @@ struct ScriptList {
};
struct
Script
{
DEFINE_NOT_INSTANTIABLE
(
Script
);
DEFINE_RECORD_ARRAY_TYPE
(
LangSys
,
langSysRecord
,
langSysCount
);
Offset
defaultLangSys
;
/* Offset to DefaultLangSys table--from
...
...
@@ -377,10 +380,17 @@ main (int argc, char **argv)
int
num_fonts
=
ot
.
get_len
();
printf
(
"%d font(s) found in file
\n
"
,
num_fonts
);
for
(
int
i
=
0
;
i
<
num_fonts
;
i
++
)
{
printf
(
"Font %d of %d
\n
"
,
i
+
1
,
num_fonts
);
const
OffsetTable
&
offset_table
=
ot
[
i
];
for
(
int
n_font
=
0
;
n_font
<
num_fonts
;
n_font
++
)
{
const
OpenTypeFont
&
font
=
ot
[
n_font
];
printf
(
"Font %d of %d
\n
"
,
n_font
+
1
,
num_fonts
);
int
num_tables
=
font
.
get_len
();
printf
(
"%d table(s) found in font
\n
"
,
num_tables
);
for
(
int
n_table
=
0
;
n_table
<
num_tables
;
n_table
++
)
{
const
OpenTypeTable
&
table
=
font
[
n_table
];
printf
(
"Table %d of %d: %.4s (%04x+%04x)
\n
"
,
n_table
+
1
,
num_tables
,
(
const
char
*
)
table
.
tag
,
(
int
)
table
.
offset
,
(
int
)
table
.
length
);
}
}
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录