Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
b739c05c
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,发现更多精彩内容 >>
提交
b739c05c
编写于
12月 25, 2006
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add OpenTypeFontFile.
上级
8596944b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
107 addition
and
8 deletion
+107
-8
src/Makefile
src/Makefile
+1
-1
src/hb-types-private.cc
src/hb-types-private.cc
+106
-7
未找到文件。
src/Makefile
浏览文件 @
b739c05c
all
:
hb-types-private
CXXFLAGS
=
-Wall
-Wextra
`
pkg-config
--cflags
glib-2.0
`
CXXFLAGS
=
-Wall
-Wextra
`
pkg-config
--cflags
--libs
glib-2.0
`
src/hb-types-private.cc
浏览文件 @
b739c05c
...
...
@@ -2,7 +2,13 @@
#include <assert.h>
#include <glib.h>
/* Public header */
typedef
uint32_t
hb_tag_t
;
#define HB_TAG(a,b,c,d) ((hb_tag_t)(((uint8_t)a<<24)|((uint8_t)b<<16)|((uint8_t)c<<8)|(uint8_t)d))
/* Implementation */
/* Macros to convert to/from BigEndian */
#define hb_be_uint8_t
...
...
@@ -146,7 +152,7 @@ struct F2DOT14 : SHORT {
* system, feature, or baseline */
struct
Tag
{
inline
Tag
(
void
)
{
v
[
0
]
=
v
[
1
]
=
v
[
2
]
=
v
[
3
]
=
0
;
}
inline
Tag
(
char
*
c
)
{
v
[
0
]
=
c
[
0
];
v
[
1
]
=
c
[
1
];
v
[
2
]
=
c
[
2
];
v
[
3
]
=
c
[
3
];
}
inline
Tag
(
c
onst
c
har
*
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
];
}
\
private
:
char
v
[
4
];
};
...
...
@@ -189,6 +195,10 @@ struct Fixed_Version : Fixed {
* Organization of an OpenType Font
*/
struct
OpenTypeFontFile
;
struct
OffsetTable
;
struct
TTCHeader
;
struct
TableDirectory
{
Tag
tag
;
/* 4-byte identifier. */
CheckSum
checkSum
;
/* CheckSum for this table. */
...
...
@@ -206,7 +216,6 @@ struct OffsetTable {
USHORT
entrySelector
;
/* Log2(maximum power of 2 <= numTables). */
USHORT
rangeShift
;
/* NumTables x 16-searchRange. */
TableDirectory
tableDir
[];
/* TableDirectory entries. numTables items */
};
...
...
@@ -229,6 +238,62 @@ struct TTCHeader {
};
/*
* OpenType Font File
*/
struct
OpenTypeFontFile
{
Tag
tag
;
/* 4-byte identifier. */
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
();
}
}
inline
const
OffsetTable
&
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
];
}
}
inline
OffsetTable
&
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
];
}
}
/* ::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
()
{}
};
...
...
@@ -270,19 +335,53 @@ struct Script {
};
struct
LangSys
{
};
#include <stdlib.h>
#include <stdio.h>
int
main
(
void
)
main
(
int
argc
,
char
**
argv
)
{
// Tag y("abcd");
// Tag &x = y;
// BYTE b(0);
if
(
argc
!=
2
)
{
fprintf
(
stderr
,
"usage: %s font-file.ttf
\n
"
,
argv
[
0
]);
exit
(
1
);
}
GMappedFile
*
mf
=
g_mapped_file_new
(
argv
[
1
],
FALSE
,
NULL
);
const
char
*
font_data
=
g_mapped_file_get_contents
(
mf
);
int
len
=
g_mapped_file_get_length
(
mf
);
printf
(
"Opened font file %s: %d bytes long
\n
"
,
argv
[
1
],
len
);
const
OpenTypeFontFile
&
ot
=
OpenTypeFontFile
::
get
(
font_data
);
switch
(
ot
.
tag
)
{
case
HB_TAG
(
0
,
1
,
0
,
0
):
printf
(
"OpenType font with TrueType outlines
\n
"
);
break
;
case
HB_TAG
(
'O'
,
'T'
,
'T'
,
'O'
):
printf
(
"OpenType font with CFF (Type1) outlines
\n
"
);
break
;
case
HB_TAG
(
't'
,
't'
,
'c'
,
'f'
):
printf
(
"TrueType Collection of OpenType fonts
\n
"
);
break
;
default:
fprintf
(
stderr
,
"Unknown font format
\n
"
);
exit
(
1
);
break
;
}
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
];
}
printf
(
"%d
\n
"
,
sizeof
(
ScriptList
));
//, x+0, y+0);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录