Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
fd92a3dd
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
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看板
提交
fd92a3dd
编写于
1月 24, 2008
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Starting public interface
上级
7586089c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
225 addition
and
41 deletion
+225
-41
src/Makefile.ng
src/Makefile.ng
+0
-0
src/hb-ot-layout-gdef-private.h
src/hb-ot-layout-gdef-private.h
+7
-10
src/hb-ot-layout-gsub-private.h
src/hb-ot-layout-gsub-private.h
+1
-2
src/hb-ot-layout-open-private.h
src/hb-ot-layout-open-private.h
+66
-26
src/hb-ot-layout-private.h
src/hb-ot-layout-private.h
+51
-0
src/hb-ot-layout.cc
src/hb-ot-layout.cc
+67
-0
src/hb-ot-layout.h
src/hb-ot-layout.h
+32
-3
src/main.cc
src/main.cc
+1
-0
未找到文件。
src/Makefile
→
src/Makefile
.ng
浏览文件 @
fd92a3dd
文件已移动
src/hb-ot-layout-gdef-private.h
浏览文件 @
fd92a3dd
...
...
@@ -27,16 +27,15 @@
#ifndef HB_OT_LAYOUT_GDEF_PRIVATE_H
#define HB_OT_LAYOUT_GDEF_PRIVATE_H
#include "hb-private.h"
#include "hb-ot-layout.h"
#include "hb-ot-layout-private.h"
#include "hb-ot-layout-open-private.h"
#define DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP(Type, name) \
inline const Type& name (
uint16
_t glyph_id) { \
inline const Type& name (
hb_ot_layout_glyph
_t glyph_id) { \
const Coverage &c = get_coverage (); \
in
t c_index = c.get_coverage (glyph_id); \
hb_ot_layout_coverage_
t c_index = c.get_coverage (glyph_id); \
return (*this)[c_index]; \
}
...
...
@@ -73,7 +72,7 @@ struct AttachList {
friend
struct
GDEF
;
private:
/* const AttachPoint& get_attach_points (
uint16
_t glyph_id); */
/* const AttachPoint& get_attach_points (
hb_ot_layout_glyph
_t glyph_id); */
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP
(
AttachPoint
,
get_attach_points
);
private:
...
...
@@ -206,7 +205,7 @@ struct LigCaretList {
friend
struct
GDEF
;
private:
/* const LigGlyph& get_lig_glyph (
uint16
_t glyph_id); */
/* const LigGlyph& get_lig_glyph (
hb_ot_layout_glyph
_t glyph_id); */
DEFINE_INDIRECT_GLYPH_ARRAY_LOOKUP
(
LigGlyph
,
get_lig_glyph
);
private:
...
...
@@ -241,17 +240,15 @@ struct GDEF {
DEFINE_ACCESSOR
(
ClassDef
,
get_mark_attach_class_def
,
markAttachClassDef
);
/* Returns 0 if not found. */
inline
int
get_glyph_class
(
uint16
_t
glyph_id
)
const
{
inline
int
get_glyph_class
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
return
get_glyph_class_def
().
get_class
(
glyph_id
);
}
/* Returns 0 if not found. */
inline
int
get_mark_attachment_type
(
uint16
_t
glyph_id
)
const
{
inline
int
get_mark_attachment_type
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
return
get_mark_attach_class_def
().
get_class
(
glyph_id
);
}
/* TODO get_glyph_property */
/* TODO get_attach and get_lig_caret */
private:
...
...
src/hb-ot-layout-gsub-private.h
浏览文件 @
fd92a3dd
...
...
@@ -27,8 +27,7 @@
#ifndef HB_OT_LAYOUT_GSUB_PRIVATE_H
#define HB_OT_LAYOUT_GSUB_PRIVATE_H
#include "hb-private.h"
#include "hb-ot-layout.h"
#include "hb-ot-layout-private.h"
#include "hb-ot-layout-open-private.h"
#include "hb-ot-layout-gdef-private.h"
...
...
src/hb-ot-layout-open-private.h
浏览文件 @
fd92a3dd
...
...
@@ -27,8 +27,7 @@
#ifndef HB_OT_LAYOUT_OPEN_PRIVATE_H
#define HB_OT_LAYOUT_OPEN_PRIVATE_H
#include "hb-private.h"
#include "hb-ot-layout.h"
#include "hb-ot-layout-private.h"
/*
...
...
@@ -89,6 +88,9 @@
return *(const Type *)((const char*)this + array[i]); \
}
/* A record array type is like an array type, but it contains a table
* of records to the objects. Each record has a tag, and an offset
* relative to the beginning of the current object. */
#define DEFINE_RECORD_ARRAY_TYPE(Type, array, num) \
DEFINE_RECORD_ACCESSOR(Type, array, num) \
DEFINE_LEN_AND_SIZE(Record, array, num)
...
...
@@ -104,6 +106,37 @@
} \
/* TODO: implement find_tag() */
#define DEFINE_ARRAY_INTERFACE(Type, name) \
inline const Type& get_##name (unsigned int i) const { \
return (*this)[i]; \
} \
inline unsigned int get_##name##_count (void) const { \
return this->get_len (); \
}
#define DEFINE_INDEX_ARRAY_INTERFACE(name) \
inline unsigned int get_##name##_index (unsigned int i) const { \
return (*this)[i]; \
} \
inline unsigned int get_##name##_count (void) const { \
return this->get_len (); \
}
#define DEFINE_FIND_TAG_INTERFACE(Type, name) \
inline const Type* find_##name (hb_tag_t tag) const { \
for (unsigned int i = 0; i < this->get_len (); i++) \
if (tag == (*this)[i].tag) \
return &(*this)[i]; \
return NULL; \
} \
inline const Type& get_##name_by_tag (hb_tag_t tag) const { \
for (unsigned int i = 0; i < this->get_len (); i++) \
if (tag == (*this)[i].tag) \
return (*this)[i]; \
return Null##Type; \
}
/*
* List types
*/
...
...
@@ -144,13 +177,15 @@
/* get_for_data() is a static class method returning a reference to an
* instance of Type located at the input data location. It's just a
* fancy cast! */
#define STATIC_DEFINE_GET_FOR_DATA
0(const,
Type) \
#define STATIC_DEFINE_GET_FOR_DATA
(
Type) \
static inline const Type& get_for_data (const char *data) { \
extern const Type &Null##Type; \
if (HB_UNLIKELY (data == NULL)) return Null##Type; \
return *(const Type*)data; \
} \
static inline Type& get_for_data (char *data) { \
return *(Type*)data; \
}
#define STATIC_DEFINE_GET_FOR_DATA(Type) \
STATIC_DEFINE_GET_FOR_DATA0(const, Type) \
STATIC_DEFINE_GET_FOR_DATA0( , Type)
#define DEFINE_ACCESSOR(Type, name, Name) \
...
...
@@ -297,8 +332,9 @@ struct TTCHeader;
typedef
struct
TableDirectory
{
friend
struct
O
penTypeFontFi
le
;
friend
struct
O
ffsetTab
le
;
inline
bool
is_null
(
void
)
const
{
return
length
==
0
;
}
inline
const
Tag
&
get_tag
(
void
)
const
{
return
tag
;
}
inline
unsigned
long
get_checksum
(
void
)
const
{
return
checkSum
;
}
inline
unsigned
long
get_offset
(
void
)
const
{
return
offset
;
}
...
...
@@ -312,17 +348,19 @@ typedef struct TableDirectory {
ULONG
length
;
/* Length of this table. */
}
OpenTypeTable
;
DEFINE_NULL_ASSERT_SIZE
(
TableDirectory
,
16
);
DEFINE_NULL_ALIAS
(
OpenTypeTable
,
TableDirectory
);
typedef
struct
OffsetTable
{
friend
struct
OpenTypeFontFile
;
friend
struct
TTCHeader
;
// XXX private:
// Add get_num_tables and get_table...
DEFINE_ARRAY_INTERFACE
(
OpenTypeTable
,
table
);
DEFINE_FIND_TAG_INTERFACE
(
OpenTypeTable
,
table
);
private:
/* OpenTypeTables, in no particular order */
DEFINE_ARRAY_TYPE
(
TableDirectory
,
tableDir
,
numTables
);
// TODO: Implement find_table
private:
Tag
sfnt_version
;
/* '\0\001\0\00' if TrueType / 'OTTO' if CFF */
...
...
@@ -427,9 +465,9 @@ typedef struct Record {
DEFINE_NULL_ASSERT_SIZE
(
Record
,
6
);
struct
LangSys
{
/* Feature indices, in no particular order */
DEFINE_
ARRAY_TYPE
(
USHORT
,
featureIndex
,
featureCount
);
DEFINE_
INDEX_ARRAY_INTERFACE
(
feature
);
/* Returns -1 if none */
inline
int
get_required_feature_index
(
void
)
const
{
if
(
reqFeatureIndex
==
0xffff
)
...
...
@@ -437,7 +475,9 @@ struct LangSys {
return
reqFeatureIndex
;;
}
/* TODO implement find_feature */
private:
/* Feature indices, in no particular order */
DEFINE_ARRAY_TYPE
(
USHORT
,
featureIndex
,
featureCount
);
private:
Offset
lookupOrder
;
/* = Null (reserved for an offset to a
...
...
@@ -490,6 +530,10 @@ private:
DEFINE_NULL_ASSERT_SIZE
(
ScriptList
,
2
);
struct
Feature
{
DEFINE_INDEX_ARRAY_INTERFACE
(
lookup
);
private:
/* LookupList indices, in no particular order */
DEFINE_ARRAY_TYPE
(
USHORT
,
lookupIndex
,
lookupCount
);
...
...
@@ -583,7 +627,7 @@ struct CoverageFormat1 {
/* GlyphIDs, in sorted numerical order */
DEFINE_ARRAY_TYPE
(
GlyphID
,
glyphArray
,
glyphCount
);
inline
int
get_coverage
(
uint16
_t
glyph_id
)
const
{
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
GlyphID
gid
;
gid
=
glyph_id
;
// TODO: bsearch
...
...
@@ -605,7 +649,7 @@ struct CoverageRangeRecord {
friend
struct
CoverageFormat2
;
private:
inline
int
get_coverage
(
uint16
_t
glyph_id
)
const
{
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
if
(
glyph_id
>=
start
&&
glyph_id
<=
end
)
return
startCoverageIndex
+
(
glyph_id
-
start
);
return
-
1
;
...
...
@@ -627,7 +671,7 @@ struct CoverageFormat2 {
/* CoverageRangeRecords, in sorted numerical start order */
DEFINE_ARRAY_TYPE
(
CoverageRangeRecord
,
rangeRecord
,
rangeCount
);
inline
int
get_coverage
(
uint16
_t
glyph_id
)
const
{
inline
hb_ot_layout_coverage_t
get_coverage
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
// TODO: bsearch
for
(
unsigned
int
i
=
0
;
i
<
rangeCount
;
i
++
)
{
int
coverage
=
rangeRecord
[
i
].
get_coverage
(
glyph_id
);
...
...
@@ -657,8 +701,7 @@ struct Coverage {
}
}
/* Returns -1 if not covered. */
int
get_coverage
(
uint16_t
glyph_id
)
const
{
hb_ot_layout_coverage_t
get_coverage
(
hb_ot_layout_glyph_t
glyph_id
)
const
{
switch
(
u
.
coverageFormat
)
{
case
1
:
return
u
.
format1
.
get_coverage
(
glyph_id
);
case
2
:
return
u
.
format2
.
get_coverage
(
glyph_id
);
...
...
@@ -687,7 +730,7 @@ struct ClassDefFormat1 {
/* GlyphIDs, in sorted numerical order */
DEFINE_ARRAY_TYPE
(
USHORT
,
classValueArray
,
glyphCount
);
inline
int
get_class
(
uint16
_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_class
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
if
(
glyph_id
>=
startGlyph
&&
glyph_id
<
startGlyph
+
glyphCount
)
return
classValueArray
[
glyph_id
-
startGlyph
];
return
0
;
...
...
@@ -706,7 +749,7 @@ struct ClassRangeRecord {
friend
struct
ClassDefFormat2
;
private:
inline
int
get_class
(
uint16
_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_class
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
if
(
glyph_id
>=
start
&&
glyph_id
<=
end
)
return
classValue
;
return
0
;
...
...
@@ -727,7 +770,7 @@ struct ClassDefFormat2 {
/* ClassRangeRecords, in sorted numerical start order */
DEFINE_ARRAY_TYPE
(
ClassRangeRecord
,
rangeRecord
,
rangeCount
);
inline
int
get_class
(
uint16
_t
glyph_id
)
const
{
inline
hb_ot_layout_class_t
get_class
(
hb_ot_layout_glyph
_t
glyph_id
)
const
{
// TODO: bsearch
for
(
int
i
=
0
;
i
<
rangeCount
;
i
++
)
{
int
classValue
=
rangeRecord
[
i
].
get_class
(
glyph_id
);
...
...
@@ -756,8 +799,7 @@ struct ClassDef {
}
}
/* Returns 0 if not found. */
int
get_class
(
uint16_t
glyph_id
)
const
{
hb_ot_layout_class_t
get_class
(
hb_ot_layout_glyph_t
glyph_id
)
const
{
switch
(
u
.
classFormat
)
{
case
1
:
return
u
.
format1
.
get_class
(
glyph_id
);
case
2
:
return
u
.
format2
.
get_class
(
glyph_id
);
...
...
@@ -835,8 +877,6 @@ typedef struct GSUBGPOS {
DEFINE_LIST_ACCESSOR
(
Feature
,
feature
);
/* get_feature_list, get_feature(i) */
DEFINE_LIST_ACCESSOR
(
Lookup
,
lookup
);
/* get_lookup_list, get_lookup(i) */
/* TODO implement find_script */
private:
Fixed_Version
version
;
/* Version of the GSUB/GPOS table--initially set
* to 0x00010000 */
...
...
src/hb-ot-layout-private.h
0 → 100644
浏览文件 @
fd92a3dd
/*
* Copyright (C) 2007,2008 Red Hat, Inc.
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Red Hat Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_LAYOUT_PRIVATE_H
#define HB_OT_LAYOUT_PRIVATE_H
#ifndef HB_OT_LAYOUT_CC
#error "This file should only be included from hb-ot-layout.c"
#endif
#include "hb-private.h"
#include "hb-ot-layout.h"
struct
GDEF
;
struct
GSUB
;
struct
GPOS
;
HB_BEGIN_DECLS
();
struct
_HB_OT_Layout
{
GDEF
*
gdef
;
GSUB
*
gsub
;
GPOS
*
gpos
;
};
HB_END_DECLS
();
#endif
/* HB_OT_LAYOUT_PRIVATE_H */
src/hb-ot-layout.cc
0 → 100644
浏览文件 @
fd92a3dd
/*
* Copyright (C) 2007,2008 Red Hat, Inc.
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Red Hat Author(s): Behdad Esfahbod
*/
#define HB_OT_LAYOUT_CC
#include "hb-ot-layout.h"
#include "hb-ot-layout-private.h"
#include "hb-ot-layout-open-private.h"
#include "hb-ot-layout-gdef-private.h"
#include "hb-ot-layout-gsub-private.h"
#include <stdlib.h>
HB_OT_Layout
*
hb_ot_layout_create
(
const
char
*
font_data
,
int
face_index
)
{
HB_OT_Layout
*
layout
=
(
HB_OT_Layout
*
)
calloc
(
1
,
sizeof
(
HB_OT_Layout
));
const
OpenTypeFontFile
&
ot
=
OpenTypeFontFile
::
get_for_data
(
font_data
);
const
OpenTypeFontFace
&
font
=
ot
[
face_index
];
layout
->
gdef
=
font
.
find_table
(
GDEF
::
Tag
);
layout
->
gsub
=
font
.
find_table
(
GSUB
::
Tag
);
layout
->
gpos
=
font
.
find_table
(
GPOS
::
Tag
);
return
layout
;
}
void
hb_ot_layout_destroy
(
HB_OT_Layout
*
layout
)
{
free
(
layout
);
}
hb_ot_layout_glyph_properties_t
hb_ot_layout_get_glyph_properties
(
HB_OT_Layout
*
layout
,
hb_ot_layout_glyph_t
glyph
);
void
hb_ot_layout_set_glyph_properties
(
HB_OT_Layout
*
layout
,
hb_ot_layout_glyph_t
glyph
,
hb_ot_layout_glyph_properties_t
properties
);
src/hb-ot-layout.h
浏览文件 @
fd92a3dd
...
...
@@ -24,8 +24,8 @@
* Red Hat Author(s): Behdad Esfahbod
*/
#ifndef HB_OT_LAYOUT_
OPEN_
H
#define HB_OT_LAYOUT_
OPEN_
H
#ifndef HB_OT_LAYOUT_H
#define HB_OT_LAYOUT_H
#include "hb-common.h"
...
...
@@ -38,6 +38,35 @@ typedef uint32_t hb_tag_t;
((const char *) s)[2], \
((const char *) s)[3]))
typedef
uint16_t
hb_ot_layout_glyph_properties_t
;
typedef
uint16_t
hb_ot_layout_glyph_t
;
typedef
uint16_t
hb_ot_layout_class_t
;
typedef
int
hb_ot_layout_coverage_t
;
/* -1 is not covered, >= 0 otherwise */
typedef
struct
_HB_OT_Layout
HB_OT_Layout
;
HB_OT_Layout
*
hb_ot_layout_create
(
const
char
*
font_data
,
int
face_index
);
void
hb_ot_layout_destroy
(
HB_OT_Layout
*
layout
);
/* TODO
HB_OT_Layout *
hb_ot_layout_create_sanitize (char *data,
make_writable_func);
*/
hb_ot_layout_glyph_properties_t
hb_ot_layout_get_glyph_properties
(
HB_OT_Layout
*
layout
,
hb_ot_layout_glyph_t
glyph
);
void
hb_ot_layout_set_glyph_properties
(
HB_OT_Layout
*
layout
,
hb_ot_layout_glyph_t
glyph
,
hb_ot_layout_glyph_properties_t
properties
);
HB_END_DECLS
();
#endif
/* HB_OT_LAYOUT_
OPEN_
H */
#endif
/* HB_OT_LAYOUT_H */
src/main.cc
浏览文件 @
fd92a3dd
...
...
@@ -24,6 +24,7 @@
* Red Hat Author(s): Behdad Esfahbod
*/
#define HB_OT_LAYOUT_CC
#include "hb-ot-layout-open-private.h"
#include "hb-ot-layout-gdef-private.h"
#include "hb-ot-layout-gsub-private.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录