Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
eab4feb5
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
eab4feb5
编写于
11月 14, 2017
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[hmtx] Use curiously recurring template pattern
https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
上级
977ddff1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
21 deletion
+19
-21
src/hb-ot-font.cc
src/hb-ot-font.cc
+4
-7
src/hb-ot-hmtx-table.hh
src/hb-ot-hmtx-table.hh
+15
-14
未找到文件。
src/hb-ot-font.cc
浏览文件 @
eab4feb5
...
...
@@ -33,8 +33,6 @@
#include "hb-ot-cmap-table.hh"
#include "hb-ot-cbdt-table.hh"
#include "hb-ot-glyf-table.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-hhea-table.hh"
#include "hb-ot-hmtx-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-post-table.hh"
...
...
@@ -43,8 +41,8 @@
struct
hb_ot_font_t
{
OT
::
cmap
::
accelerator_t
cmap
;
OT
::
hmtx
vmtx
::
accelerator_t
h_metrics
;
OT
::
hmtx
vmtx
::
accelerator_t
v_metrics
;
OT
::
hmtx
::
accelerator_t
h_metrics
;
OT
::
vmtx
::
accelerator_t
v_metrics
;
OT
::
hb_lazy_loader_t
<
OT
::
glyf
::
accelerator_t
>
glyf
;
OT
::
hb_lazy_loader_t
<
OT
::
CBDT
::
accelerator_t
>
cbdt
;
OT
::
hb_lazy_loader_t
<
OT
::
post
::
accelerator_t
>
post
;
...
...
@@ -61,9 +59,8 @@ _hb_ot_font_create (hb_face_t *face)
return
nullptr
;
ot_font
->
cmap
.
init
(
face
);
ot_font
->
h_metrics
.
init
(
face
,
HB_OT_TAG_hhea
,
HB_OT_TAG_hmtx
,
HB_OT_TAG_HVAR
,
HB_OT_TAG_os2
);
ot_font
->
v_metrics
.
init
(
face
,
HB_OT_TAG_vhea
,
HB_OT_TAG_vmtx
,
HB_OT_TAG_VVAR
,
HB_TAG_NONE
,
ot_font
->
h_metrics
.
ascender
-
ot_font
->
h_metrics
.
descender
);
/* TODO Can we do this lazily? */
ot_font
->
h_metrics
.
init
(
face
);
ot_font
->
v_metrics
.
init
(
face
,
ot_font
->
h_metrics
.
ascender
-
ot_font
->
h_metrics
.
descender
);
/* TODO Can we do this lazily? */
ot_font
->
glyf
.
init
(
face
);
ot_font
->
cbdt
.
init
(
face
);
ot_font
->
post
.
init
(
face
);
...
...
src/hb-ot-hmtx-table.hh
浏览文件 @
eab4feb5
...
...
@@ -28,6 +28,7 @@
#define HB_OT_HMTX_TABLE_HH
#include "hb-open-type-private.hh"
#include "hb-ot-hhea-table.hh"
#include "hb-ot-os2-table.hh"
#include "hb-ot-var-hvar-table.hh"
...
...
@@ -52,11 +53,9 @@ struct LongMetric
DEFINE_SIZE_STATIC
(
4
);
};
template
<
typename
T
>
struct
hmtxvmtx
{
static
const
hb_tag_t
hmtxTag
=
HB_OT_TAG_hmtx
;
static
const
hb_tag_t
vmtxTag
=
HB_OT_TAG_vmtx
;
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
...
...
@@ -68,18 +67,14 @@ struct hmtxvmtx
struct
accelerator_t
{
inline
void
init
(
hb_face_t
*
face
,
hb_tag_t
_hea_tag
,
hb_tag_t
_mtx_tag
,
hb_tag_t
_var_tag
,
hb_tag_t
os2_tag
,
unsigned
int
default_advance_
=
0
)
{
default_advance
=
default_advance_
?
default_advance_
:
face
->
get_upem
();
bool
got_font_extents
=
false
;
if
(
os2_t
ag
)
if
(
T
::
os2T
ag
)
{
hb_blob_t
*
os2_blob
=
Sanitizer
<
os2
>::
sanitize
(
face
->
reference_table
(
os2_t
ag
));
hb_blob_t
*
os2_blob
=
Sanitizer
<
os2
>::
sanitize
(
face
->
reference_table
(
T
::
os2T
ag
));
const
os2
*
os2_table
=
Sanitizer
<
os2
>::
lock_instance
(
os2_blob
);
#define USE_TYPO_METRICS (1u<<7)
if
(
0
!=
(
os2_table
->
fsSelection
&
USE_TYPO_METRICS
))
...
...
@@ -92,7 +87,7 @@ struct hmtxvmtx
hb_blob_destroy
(
os2_blob
);
}
hb_blob_t
*
_hea_blob
=
Sanitizer
<
_hea
>::
sanitize
(
face
->
reference_table
(
_hea_t
ag
));
hb_blob_t
*
_hea_blob
=
Sanitizer
<
_hea
>::
sanitize
(
face
->
reference_table
(
T
::
headerT
ag
));
const
_hea
*
_hea_table
=
Sanitizer
<
_hea
>::
lock_instance
(
_hea_blob
);
num_advances
=
_hea_table
->
numberOfLongMetrics
;
if
(
!
got_font_extents
)
...
...
@@ -106,7 +101,7 @@ struct hmtxvmtx
has_font_extents
=
got_font_extents
;
blob
=
Sanitizer
<
hmtxvmtx
>::
sanitize
(
face
->
reference_table
(
_mtx_t
ag
));
blob
=
Sanitizer
<
hmtxvmtx
>::
sanitize
(
face
->
reference_table
(
T
::
tableT
ag
));
/* Cap num_metrics() and num_advances() based on table length. */
unsigned
int
len
=
hb_blob_get_length
(
blob
);
...
...
@@ -124,7 +119,7 @@ struct hmtxvmtx
}
table
=
Sanitizer
<
hmtxvmtx
>::
lock_instance
(
blob
);
var_blob
=
Sanitizer
<
HVARVVAR
>::
sanitize
(
face
->
reference_table
(
_var_t
ag
));
var_blob
=
Sanitizer
<
HVARVVAR
>::
sanitize
(
face
->
reference_table
(
T
::
variationsT
ag
));
var_table
=
Sanitizer
<
HVARVVAR
>::
lock_instance
(
var_blob
);
}
...
...
@@ -195,11 +190,17 @@ struct hmtxvmtx
DEFINE_SIZE_ARRAY2
(
0
,
longMetric
,
leadingBearingX
);
};
struct
hmtx
:
hmtxvmtx
{
struct
hmtx
:
hmtxvmtx
<
hmtx
>
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_hmtx
;
static
const
hb_tag_t
headerTag
=
HB_OT_TAG_hhea
;
static
const
hb_tag_t
variationsTag
=
HB_OT_TAG_HVAR
;
static
const
hb_tag_t
os2Tag
=
HB_OT_TAG_os2
;
};
struct
vmtx
:
hmtxvmtx
{
struct
vmtx
:
hmtxvmtx
<
vmtx
>
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_vmtx
;
static
const
hb_tag_t
headerTag
=
HB_OT_TAG_vhea
;
static
const
hb_tag_t
variationsTag
=
HB_OT_TAG_VVAR
;
static
const
hb_tag_t
os2Tag
=
HB_TAG_NONE
;
};
}
/* namespace OT */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录