Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
7867c2ba
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看板
未验证
提交
7867c2ba
编写于
11月 14, 2018
作者:
E
Ebrahim Byagowi
提交者:
GitHub
11月 14, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[STAT] Add table parsing (#1384)
上级
48d16c2a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
290 addition
and
8 deletion
+290
-8
src/Makefile.sources
src/Makefile.sources
+1
-0
src/hb-ot-face.hh
src/hb-ot-face.hh
+2
-0
src/hb-ot-font.cc
src/hb-ot-font.cc
+3
-1
src/hb-ot-hmtx-table.hh
src/hb-ot-hmtx-table.hh
+4
-7
src/hb-ot-stat-table.hh
src/hb-ot-stat-table.hh
+280
-0
未找到文件。
src/Makefile.sources
浏览文件 @
7867c2ba
...
...
@@ -158,6 +158,7 @@ HB_OT_sources = \
hb-ot-shape-fallback.hh
\
hb-ot-shape-fallback.cc
\
hb-ot-shape.hh
\
hb-ot-stat-table.hh
\
hb-ot-var.cc
\
hb-ot-var-avar-table.hh
\
hb-ot-var-fvar-table.hh
\
...
...
src/hb-ot-face.hh
浏览文件 @
7867c2ba
...
...
@@ -49,6 +49,8 @@
HB_OT_ACCELERATOR(OT, glyf) \
HB_OT_TABLE(OT, VORG) \
HB_OT_ACCELERATOR(OT, name) \
HB_OT_TABLE(OT, OS2) \
HB_OT_TABLE(OT, STAT) \
/* OpenType shaping. */
\
HB_OT_ACCELERATOR(OT, GDEF) \
HB_OT_ACCELERATOR(OT, GSUB) \
...
...
src/hb-ot-font.cc
浏览文件 @
7867c2ba
...
...
@@ -33,10 +33,12 @@
#include "hb-ot-face.hh"
#include "hb-ot-cmap-table.hh"
#include "hb-ot-glyf-table.hh"
#include "hb-ot-hmtx-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-os2-table.hh"
#include "hb-ot-post-table.hh"
#include "hb-ot-
glyf-table.hh"
#include "hb-ot-
stat-table.hh" // Just so we compile it; unused otherwise.
#include "hb-ot-vorg-table.hh"
#include "hb-ot-color-cbdt-table.hh"
#include "hb-ot-color-sbix-table.hh"
...
...
src/hb-ot-hmtx-table.hh
浏览文件 @
7867c2ba
...
...
@@ -194,17 +194,14 @@ struct hmtxvmtx
bool
got_font_extents
=
false
;
if
(
T
::
os2Tag
)
{
hb_blob_t
*
os2_blob
=
hb_sanitize_context_t
().
reference_table
<
OS2
>
(
face
);
const
OS2
*
os2_table
=
os2_blob
->
as
<
OS2
>
();
#define USE_TYPO_METRICS (1u<<7)
if
(
0
!=
(
os2_table
->
fsSelection
&
USE_TYPO_METRICS
))
if
(
0
!=
(
face
->
table
.
OS2
->
fsSelection
&
USE_TYPO_METRICS
))
{
ascender
=
abs
(
os2_table
->
sTypoAscender
);
descender
=
-
abs
(
os2_table
->
sTypoDescender
);
line_gap
=
os2_table
->
sTypoLineGap
;
ascender
=
abs
(
face
->
table
.
OS2
->
sTypoAscender
);
descender
=
-
abs
(
face
->
table
.
OS2
->
sTypoDescender
);
line_gap
=
face
->
table
.
OS2
->
sTypoLineGap
;
got_font_extents
=
(
ascender
|
descender
)
!=
0
;
}
hb_blob_destroy
(
os2_blob
);
}
hb_blob_t
*
_hea_blob
=
hb_sanitize_context_t
().
reference_table
<
H
>
(
face
);
...
...
src/hb-ot-stat-table.hh
0 → 100644
浏览文件 @
7867c2ba
/*
* Copyright © 2018 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping 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.
*/
#ifndef HB_OT_STAT_TABLE_HH
#define HB_OT_STAT_TABLE_HH
#include "hb-open-type.hh"
#include "hb-ot-layout-common.hh"
/*
* STAT -- Style Attributes
* https://docs.microsoft.com/en-us/typography/opentype/spec/stat
*/
#define HB_OT_TAG_STAT HB_TAG('S','T','A','T')
namespace
OT
{
enum
{
OLDER_SIBLING_FONT_ATTRIBUTE
=
0x0001
,
/* If set, this axis value table
* provides axis value information
* that is applicable to other fonts
* within the same font family. This
* is used if the other fonts were
* released earlier and did not include
* information about values for some axis.
* If newer versions of the other
* fonts include the information
* themselves and are present,
* then this record is ignored. */
ELIDABLE_AXIS_VALUE_NAME
=
0x0002
/* If set, it indicates that the axis
* value represents the “normal” value
* for the axis and may be omitted when
* composing name strings. */
// Reserved = 0xFFFC /* Reserved for future use — set to zero. */
};
struct
StatAxisRecord
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)));
}
protected:
Tag
axisTag
;
/* A tag identifying the axis of design variation. */
NameID
axisNameID
;
/* The name ID for entries in the 'name' table that
* provide a display string for this axis. */
HBUINT16
axisOrdering
;
/* A value that applications can use to determine
* primary sorting of face names, or for ordering
* of descriptors when composing family or face names. */
public:
DEFINE_SIZE_STATIC
(
8
);
};
struct
AxisValueFormat1
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)));
}
protected:
HBUINT16
format
;
/* Format identifier — set to 1. */
HBUINT16
axisIndex
;
/* Zero-base index into the axis record array
* identifying the axis of design variation
* to which the axis value record applies.
* Must be less than designAxisCount. */
HBUINT16
flags
;
/* Flags — see below for details. */
NameID
valueNameID
;
/* The name ID for entries in the 'name' table
* that provide a display string for this
* attribute value. */
Fixed
value
;
/* A numeric value for this attribute value. */
public:
DEFINE_SIZE_STATIC
(
12
);
};
struct
AxisValueFormat2
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)));
}
protected:
HBUINT16
format
;
/* Format identifier — set to 2. */
HBUINT16
axisIndex
;
/* Zero-base index into the axis record array
* identifying the axis of design variation
* to which the axis value record applies.
* Must be less than designAxisCount. */
HBUINT16
flags
;
/* Flags — see below for details. */
NameID
valueNameID
;
/* The name ID for entries in the 'name' table
* that provide a display string for this
* attribute value. */
Fixed
nominalValue
;
/* A numeric value for this attribute value. */
Fixed
rangeMinValue
;
/* The minimum value for a range associated
* with the specified name ID. */
Fixed
rangeMaxValue
;
/* The maximum value for a range associated
* with the specified name ID. */
public:
DEFINE_SIZE_STATIC
(
20
);
};
struct
AxisValueFormat3
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)));
}
protected:
HBUINT16
format
;
/* Format identifier — set to 3. */
HBUINT16
axisIndex
;
/* Zero-base index into the axis record array
* identifying the axis of design variation
* to which the axis value record applies.
* Must be less than designAxisCount. */
HBUINT16
flags
;
/* Flags — see below for details. */
NameID
valueNameID
;
/* The name ID for entries in the 'name' table
* that provide a display string for this
* attribute value. */
Fixed
value
;
/* A numeric value for this attribute value. */
Fixed
linkedValue
;
/* The numeric value for a style-linked mapping
* from this value. */
public:
DEFINE_SIZE_STATIC
(
16
);
};
struct
AxisValueRecord
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)));
}
protected:
HBUINT16
axisIndex
;
/* Zero-base index into the axis record array
* identifying the axis to which this value
* applies. Must be less than designAxisCount. */
Fixed
value
;
/* A numeric value for this attribute value. */
public:
DEFINE_SIZE_STATIC
(
6
);
};
struct
AxisValueFormat4
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)));
}
protected:
HBUINT16
format
;
/* Format identifier — set to 4. */
HBUINT16
axisCount
;
/* The total number of axes contributing to
* this axis-values combination. */
HBUINT16
flags
;
/* Flags — see below for details. */
NameID
valueNameID
;
/* The name ID for entries in the 'name' table
* that provide a display string for this
* attribute value. */
UnsizedArrayOf
<
AxisValueRecord
>
axisValues
;
/* Array of AxisValue records that provide the
* combination of axis values, one for each
* contributing axis. */
public:
DEFINE_SIZE_ARRAY
(
8
,
axisValues
);
};
struct
AxisValue
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
if
(
unlikely
(
c
->
check_struct
(
this
)))
return_trace
(
false
);
switch
(
u
.
format
)
{
case
1
:
return_trace
(
likely
(
u
.
format1
.
sanitize
(
c
)));
case
2
:
return_trace
(
likely
(
u
.
format2
.
sanitize
(
c
)));
case
3
:
return_trace
(
likely
(
u
.
format3
.
sanitize
(
c
)));
case
4
:
return_trace
(
likely
(
u
.
format4
.
sanitize
(
c
)));
default:
return_trace
(
true
);
}
}
protected:
union
{
HBUINT16
format
;
AxisValueFormat1
format1
;
AxisValueFormat2
format2
;
AxisValueFormat3
format3
;
AxisValueFormat4
format4
;
}
u
;
public:
DEFINE_SIZE_UNION
(
2
,
format
);
};
struct
STAT
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_STAT
;
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)
&&
majorVersion
==
1
&&
minorVersion
>
0
&&
designAxesOffset
.
sanitize
(
c
,
this
,
designAxisCount
)
&&
offsetToAxisValueOffsets
.
sanitize
(
c
,
this
,
axisValueCount
,
&
(
this
+
offsetToAxisValueOffsets
))));
}
protected:
HBUINT16
majorVersion
;
/* Major version number of the style attributes
* table — set to 1. */
HBUINT16
minorVersion
;
/* Minor version number of the style attributes
* table — set to 2. */
HBUINT16
designAxisSize
;
/* The size in bytes of each axis record. */
HBUINT16
designAxisCount
;
/* The number of design axis records. In a
* font with an 'fvar' table, this value must be
* greater than or equal to the axisCount value
* in the 'fvar' table. In all fonts, must
* be greater than zero if axisValueCount
* is greater than zero. */
LOffsetTo
<
UnsizedArrayOf
<
StatAxisRecord
>
,
false
>
designAxesOffset
;
/* Offset in bytes from the beginning of
* the STAT table to the start of the design
* axes array. If designAxisCount is zero,
* set to zero; if designAxisCount is greater
* than zero, must be greater than zero. */
HBUINT16
axisValueCount
;
/* The number of axis value tables. */
LOffsetTo
<
UnsizedArrayOf
<
OffsetTo
<
AxisValue
>
>
,
false
>
offsetToAxisValueOffsets
;
/* Offset in bytes from the beginning of
* the STAT table to the start of the design
* axes value offsets array. If axisValueCount
* is zero, set to zero; if axisValueCount is
* greater than zero, must be greater than zero. */
NameID
elidedFallbackNameID
;
/* Name ID used as fallback when projection of
* names into a particular font model produces
* a subfamily name containing only elidable
* elements. */
public:
DEFINE_SIZE_STATIC
(
20
);
};
}
/* namespace OT */
#endif
/* HB_OT_STAT_TABLE_HH */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录