Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
d41b809e
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d41b809e
编写于
9月 25, 2014
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ot-font] Start adding vertical support
上级
22f0de50
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
100 addition
and
55 deletion
+100
-55
src/hb-ot-font.cc
src/hb-ot-font.cc
+45
-12
src/hb-ot-hhea-table.hh
src/hb-ot-hhea-table.hh
+33
-30
src/hb-ot-hmtx-table.hh
src/hb-ot-hmtx-table.hh
+22
-13
未找到文件。
src/hb-ot-font.cc
浏览文件 @
d41b809e
...
...
@@ -39,10 +39,15 @@
struct
hb_ot_font_t
{
unsigned
int
num_glyphs
;
unsigned
int
num_hmetrics
;
const
OT
::
hmtx
*
hmtx
;
hb_blob_t
*
hmtx_blob
;
unsigned
int
num_vmetrics
;
const
OT
::
vmtx
*
vmtx
;
hb_blob_t
*
vmtx_blob
;
const
OT
::
CmapSubtable
*
cmap
;
const
OT
::
CmapSubtable
*
cmap_uvs
;
hb_blob_t
*
cmap_blob
;
...
...
@@ -59,21 +64,41 @@ _hb_ot_font_create (hb_font_t *font)
ot_font
->
num_glyphs
=
font
->
face
->
get_num_glyphs
();
/* Setup horizontal metrics. */
{
hb_blob_t
*
hhea_blob
=
OT
::
Sanitizer
<
OT
::
hhea
>::
sanitize
(
font
->
face
->
reference_table
(
HB_OT_TAG_hhea
));
const
OT
::
hhea
*
hhea
=
OT
::
Sanitizer
<
OT
::
hhea
>::
lock_instance
(
hhea_blob
);
ot_font
->
num_hmetrics
=
hhea
->
numberOf
H
Metrics
;
ot_font
->
num_hmetrics
=
hhea
->
numberOfMetrics
;
hb_blob_destroy
(
hhea_blob
);
ot_font
->
hmtx_blob
=
OT
::
Sanitizer
<
OT
::
hmtx
>::
sanitize
(
font
->
face
->
reference_table
(
HB_OT_TAG_hmtx
));
if
(
unlikely
(
!
ot_font
->
num_hmetrics
||
2
*
(
ot_font
->
num_hmetrics
+
ot_font
->
num_glyphs
)
<
hb_blob_get_length
(
ot_font
->
hmtx_blob
)))
{
hb_blob_destroy
(
ot_font
->
hmtx_blob
);
free
(
ot_font
);
return
NULL
;
}
ot_font
->
hmtx
=
OT
::
Sanitizer
<
OT
::
hmtx
>::
lock_instance
(
ot_font
->
hmtx_blob
);
}
ot_font
->
hmtx_blob
=
OT
::
Sanitizer
<
OT
::
hmtx
>::
sanitize
(
font
->
face
->
reference_table
(
HB_OT_TAG_hmtx
));
if
(
unlikely
(
!
ot_font
->
num_hmetrics
||
2
*
(
ot_font
->
num_hmetrics
+
ot_font
->
num_glyphs
)
<
hb_blob_get_length
(
ot_font
->
hmtx_blob
)))
/* Setup vertical metrics. */
{
hb_blob_destroy
(
ot_font
->
hmtx_blob
);
free
(
ot_font
);
return
NULL
;
hb_blob_t
*
vhea_blob
=
OT
::
Sanitizer
<
OT
::
vhea
>::
sanitize
(
font
->
face
->
reference_table
(
HB_OT_TAG_vhea
));
const
OT
::
vhea
*
vhea
=
OT
::
Sanitizer
<
OT
::
vhea
>::
lock_instance
(
vhea_blob
);
ot_font
->
num_vmetrics
=
vhea
->
numberOfMetrics
;
hb_blob_destroy
(
vhea_blob
);
ot_font
->
vmtx_blob
=
OT
::
Sanitizer
<
OT
::
vmtx
>::
sanitize
(
font
->
face
->
reference_table
(
HB_TAG
(
'v'
,
'm'
,
't'
,
'x'
)));
if
(
unlikely
(
!
ot_font
->
num_vmetrics
||
2
*
(
ot_font
->
num_vmetrics
+
ot_font
->
num_glyphs
)
<
hb_blob_get_length
(
ot_font
->
vmtx_blob
)))
{
hb_blob_destroy
(
ot_font
->
vmtx_blob
);
free
(
ot_font
);
return
NULL
;
}
ot_font
->
vmtx
=
OT
::
Sanitizer
<
OT
::
vmtx
>::
lock_instance
(
ot_font
->
vmtx_blob
);
}
ot_font
->
hmtx
=
OT
::
Sanitizer
<
OT
::
hmtx
>::
lock_instance
(
ot_font
->
hmtx_blob
);
ot_font
->
cmap_blob
=
OT
::
Sanitizer
<
OT
::
cmap
>::
sanitize
(
font
->
face
->
reference_table
(
HB_OT_TAG_cmap
));
const
OT
::
cmap
*
cmap
=
OT
::
Sanitizer
<
OT
::
cmap
>::
lock_instance
(
ot_font
->
cmap_blob
);
...
...
@@ -109,6 +134,7 @@ _hb_ot_font_destroy (hb_ot_font_t *ot_font)
{
hb_blob_destroy
(
ot_font
->
cmap_blob
);
hb_blob_destroy
(
ot_font
->
hmtx_blob
);
hb_blob_destroy
(
ot_font
->
vmtx_blob
);
free
(
ot_font
);
}
...
...
@@ -149,12 +175,12 @@ hb_ot_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
const
hb_ot_font_t
*
ot_font
=
(
const
hb_ot_font_t
*
)
font_data
;
if
(
unlikely
(
glyph
>=
ot_font
->
num_glyphs
))
return
0
;
/* Maybe better to return notdef's advance instead? */
return
0
;
if
(
glyph
>=
ot_font
->
num_hmetrics
)
glyph
=
ot_font
->
num_hmetrics
-
1
;
return
font
->
em_scale_x
(
ot_font
->
hmtx
->
longHorMetric
[
glyph
].
advance
Width
);
return
font
->
em_scale_x
(
ot_font
->
hmtx
->
longHorMetric
[
glyph
].
advance
);
}
static
hb_position_t
...
...
@@ -163,8 +189,15 @@ hb_ot_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
hb_codepoint_t
glyph
,
void
*
user_data
HB_UNUSED
)
{
/* TODO */
return
0
;
const
hb_ot_font_t
*
ot_font
=
(
const
hb_ot_font_t
*
)
font_data
;
if
(
unlikely
(
glyph
>=
ot_font
->
num_glyphs
))
return
0
;
if
(
glyph
>=
ot_font
->
num_vmetrics
)
glyph
=
ot_font
->
num_vmetrics
-
1
;
return
font
->
em_scale_y
(
-
ot_font
->
vmtx
->
longHorMetric
[
glyph
].
advance
);
}
static
hb_bool_t
...
...
src/hb-ot-hhea-table.hh
浏览文件 @
d41b809e
...
...
@@ -35,14 +35,17 @@ namespace OT {
/*
* hhea -- The Horizontal Header Table
* vhea -- The Vertical Header Table
*/
#define HB_OT_TAG_hhea HB_TAG('h','h','e','a')
#define HB_OT_TAG_vhea HB_TAG('v','h','e','a')
struct
h
hea
struct
_
hea
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_hhea
;
static
const
hb_tag_t
hheaTag
=
HB_OT_TAG_hhea
;
static
const
hb_tag_t
vheaTag
=
HB_OT_TAG_vhea
;
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
TRACE_SANITIZE
(
this
);
...
...
@@ -51,45 +54,45 @@ struct hhea
public:
FixedVersion
version
;
/* 0x00010000u for version 1.0. */
FWORD
ascender
;
/* Typographic ascent. <a
* href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6hhea.html">
* (Distance from baseline of highest
* ascender)</a> */
FWORD
descender
;
/* Typographic descent. <a
* href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6hhea.html">
* (Distance from baseline of lowest
* descender)</a> */
FWORD
lineGap
;
/* Typographic line gap. Negative
* LineGap values are treated as zero
* in Windows 3.1, System 6, and
* System 7. */
UFWORD
advanceWidthMax
;
/* Maximum advance width value in
* 'hmtx' table. */
FWORD
minLeftSideBearing
;
/* Minimum left sidebearing value in
* 'hmtx' table. */
FWORD
minRightSideBearing
;
/* Minimum right sidebearing value;
FWORD
ascender
;
/* Typographic ascent. */
FWORD
descender
;
/* Typographic descent. */
FWORD
lineGap
;
/* Typographic line gap. */
UFWORD
advanceMax
;
/* Maximum advance width/height value in
* metrics table. */
FWORD
minLeadingBearing
;
/* Minimum left/top sidebearing value in
* metrics table. */
FWORD
minTrailingBearing
;
/* Minimum right/bottom sidebearing value;
* calculated as Min(aw - lsb -
* (xMax - xMin)). */
FWORD
xMaxExtent
;
/* Max(lsb + (xMax - xMin)). */
* (xMax - xMin)) for horizontal. */
FWORD
maxExtent
;
/* horizontal: Max(lsb + (xMax - xMin)),
* vertical: minLeadingBearing+(yMax-yMin). */
SHORT
caretSlopeRise
;
/* Used to calculate the slope of the
* cursor (rise/run); 1 for vertical. */
SHORT
caretSlopeRun
;
/* 0 for vertical. */
* cursor (rise/run); 1 for vertical caret,
* 0 for horizontal.*/
SHORT
caretSlopeRun
;
/* 0 for vertical caret, 1 for horizontal. */
SHORT
caretOffset
;
/* The amount by which a slanted
* highlight on a glyph needs
* to be shifted to produce the
* best appearance. Set to 0 for
* non-
-slanted fonts
*/
SHORT
reserved1
;
/*
set to 0
*/
SHORT
reserved2
;
/*
set to 0
*/
SHORT
reserved3
;
/*
set to 0
*/
SHORT
reserved4
;
/*
set to 0
*/
* non-
slanted fonts.
*/
SHORT
reserved1
;
/*
Set to 0.
*/
SHORT
reserved2
;
/*
Set to 0.
*/
SHORT
reserved3
;
/*
Set to 0.
*/
SHORT
reserved4
;
/*
Set to 0.
*/
SHORT
metricDataFormat
;
/* 0 for current format. */
USHORT
numberOf
HMetrics
;
/* Number of hMetric entries in 'hmtx'
* table */
USHORT
numberOf
Metrics
;
/* Number of LongMetric entries in metric
* table
.
*/
public:
DEFINE_SIZE_STATIC
(
36
);
};
struct
hhea
:
_hea
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_hhea
;
};
struct
vhea
:
_hea
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_vhea
;
};
}
/* namespace OT */
...
...
src/hb-ot-hmtx-table.hh
浏览文件 @
d41b809e
...
...
@@ -35,22 +35,25 @@ namespace OT {
/*
* hmtx -- The Horizontal Metrics Table
* vmtx -- The Vertical Metrics Table
*/
#define HB_OT_TAG_hmtx HB_TAG('h','m','t','x')
#define HB_OT_TAG_vmtx HB_TAG('v','m','t','x')
struct
Long
Hor
Metric
struct
LongMetric
{
USHORT
advance
Width
;
SHORT
lsb
;
USHORT
advance
;
/* Advance width/height. */
SHORT
lsb
;
/* Leading (left/top) side bearing. */
public:
DEFINE_SIZE_STATIC
(
4
);
};
struct
h
mtx
struct
_
mtx
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_hmtx
;
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
)
{
TRACE_SANITIZE
(
this
);
...
...
@@ -60,7 +63,7 @@ struct hmtx
}
public:
Long
HorMetric
longHorMetric
[
VAR
];
/* Paired advance width and left side
Long
Metric
longHorMetric
[
VAR
];
/* Paired advance width and leading
* bearing values for each glyph. The
* value numOfHMetrics comes from
* the 'hhea' table. If the font is
...
...
@@ -68,23 +71,29 @@ struct hmtx
* be in the array, but that entry is
* required. The last entry applies to
* all subsequent glyphs. */
SHORT
le
ftSideBearingX
[
VAR
];
/* Here the advanceWidth
is assumed
* to be the same as the advance
Width
SHORT
le
adingBearingX
[
VAR
];
/* Here the advance
is assumed
* to be the same as the advance
* for the last entry above. The
* number of entries in this array is
* derived from numGlyphs (from 'maxp'
* table) minus numberOf
HMetrics. This
*
generally is used with a run of
* monospaced glyphs (e.g., Kanji
* table) minus numberOf
LongMetrics.
*
This generally is used with a run
*
of
monospaced glyphs (e.g., Kanji
* fonts or Courier fonts). Only one
* run is allowed and it must be at
* the end. This allows a monospaced
* font to vary the
left
side bearing
* font to vary the side bearing
* values for each glyph. */
public:
DEFINE_SIZE_ARRAY2
(
0
,
longHorMetric
,
le
ftSide
BearingX
);
DEFINE_SIZE_ARRAY2
(
0
,
longHorMetric
,
le
ading
BearingX
);
};
struct
hmtx
:
_mtx
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_hmtx
;
};
struct
vmtx
:
_mtx
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_vmtx
;
};
}
/* namespace OT */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录