Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
c7a4e3df
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
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看板
提交
c7a4e3df
编写于
10月 23, 2018
作者:
E
Ebrahim Byagowi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[svg] Add public API
* hb_ot_color_has_svg * hb_ot_color_glyph_svg_create_blob
上级
e98af6d1
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
199 addition
and
60 deletion
+199
-60
src/dump-emoji.cc
src/dump-emoji.cc
+32
-19
src/hb-open-type.hh
src/hb-open-type.hh
+0
-1
src/hb-ot-color-sbix-table.hh
src/hb-ot-color-sbix-table.hh
+2
-0
src/hb-ot-color-svg-table.hh
src/hb-ot-color-svg-table.hh
+64
-22
src/hb-ot-color.cc
src/hb-ot-color.cc
+46
-7
src/hb-ot-color.h
src/hb-ot-color.h
+13
-0
src/hb-ot-face.cc
src/hb-ot-face.cc
+2
-0
src/hb-ot-face.hh
src/hb-ot-face.hh
+2
-2
src/hb-ot-layout.cc
src/hb-ot-layout.cc
+0
-4
test/api/test-ot-color.c
test/api/test-ot-color.c
+38
-5
未找到文件。
src/dump-emoji.cc
浏览文件 @
c7a4e3df
...
@@ -69,26 +69,40 @@ sbix_callback (const uint8_t* data, unsigned int length,
...
@@ -69,26 +69,40 @@ sbix_callback (const uint8_t* data, unsigned int length,
}
}
static
void
static
void
svg_callback
(
const
uint8_t
*
data
,
unsigned
int
length
,
svg_dump
(
hb_face_t
*
face
)
unsigned
int
start_glyph
,
unsigned
int
end_glyph
)
{
{
char
output_path
[
255
];
unsigned
glyph_count
=
hb_face_get_glyph_count
(
face
);
if
(
start_glyph
==
end_glyph
)
sprintf
(
output_path
,
"out/svg-%d.svg"
,
start_glyph
);
else
sprintf
(
output_path
,
"out/svg-%d-%d.svg"
,
start_glyph
,
end_glyph
);
// append "z" if the content is gzipped
for
(
unsigned
int
glyph_id
=
0
;
glyph_id
<
glyph_count
;
glyph_id
++
)
if
((
data
[
0
]
==
0x1F
)
&&
(
data
[
1
]
==
0x8B
))
{
strcat
(
output_path
,
"z"
);
hb_codepoint_t
start_glyph_id
,
end_glyph_id
;
hb_blob_t
*
blob
=
hb_ot_color_glyph_svg_create_blob
(
face
,
glyph_id
,
&
start_glyph_id
,
&
end_glyph_id
);
FILE
*
f
=
fopen
(
output_path
,
"wb"
);
if
(
hb_blob_get_length
(
blob
)
==
0
)
continue
;
fwrite
(
data
,
1
,
length
,
f
);
fclose
(
f
);
char
output_path
[
255
];
if
(
start_glyph_id
==
end_glyph_id
)
sprintf
(
output_path
,
"out/svg-%d.svg"
,
start_glyph_id
);
else
sprintf
(
output_path
,
"out/svg-%d-%d.svg"
,
start_glyph_id
,
end_glyph_id
);
unsigned
int
length
;
const
char
*
data
=
hb_blob_get_data
(
blob
,
&
length
);
// append "z" if the content is gzipped, https://stackoverflow.com/a/6059405
if
(
length
>
2
&&
(
data
[
0
]
==
'\x1F'
)
&&
(
data
[
1
]
==
'\x8B'
))
strcat
(
output_path
,
"z"
);
FILE
*
f
=
fopen
(
output_path
,
"wb"
);
fwrite
(
data
,
1
,
length
,
f
);
fclose
(
f
);
if
(
glyph_id
<
end_glyph_id
)
glyph_id
=
end_glyph_id
;
}
}
}
static
void
static
void
colr_cpal_
rendering
(
hb_face_t
*
face
,
cairo_font_face_t
*
cairo_face
)
colr_cpal_
dump
(
hb_face_t
*
face
,
cairo_font_face_t
*
cairo_face
)
{
{
unsigned
int
upem
=
hb_face_get_upem
(
face
);
unsigned
int
upem
=
hb_face_get_upem
(
face
);
...
@@ -268,10 +282,8 @@ main (int argc, char **argv)
...
@@ -268,10 +282,8 @@ main (int argc, char **argv)
sbix
.
dump
(
sbix_callback
);
sbix
.
dump
(
sbix_callback
);
sbix
.
fini
();
sbix
.
fini
();
OT
::
SVG
::
accelerator_t
svg
;
if
(
hb_ot_color_has_svg
(
face
))
svg
.
init
(
face
);
svg_dump
(
face
);
svg
.
dump
(
svg_callback
);
svg
.
fini
();
cairo_font_face_t
*
cairo_face
;
cairo_font_face_t
*
cairo_face
;
{
{
...
@@ -281,7 +293,8 @@ main (int argc, char **argv)
...
@@ -281,7 +293,8 @@ main (int argc, char **argv)
FT_New_Face
(
library
,
argv
[
1
],
0
,
&
ftface
);
FT_New_Face
(
library
,
argv
[
1
],
0
,
&
ftface
);
cairo_face
=
cairo_ft_font_face_create_for_ft_face
(
ftface
,
0
);
cairo_face
=
cairo_ft_font_face_create_for_ft_face
(
ftface
,
0
);
}
}
colr_cpal_rendering
(
face
,
cairo_face
);
if
(
hb_ot_color_has_layers
(
face
)
&&
hb_ot_color_has_palettes
(
face
))
colr_cpal_dump
(
face
,
cairo_face
);
unsigned
int
num_glyphs
=
hb_face_get_glyph_count
(
face
);
unsigned
int
num_glyphs
=
hb_face_get_glyph_count
(
face
);
unsigned
int
upem
=
hb_face_get_upem
(
face
);
unsigned
int
upem
=
hb_face_get_upem
(
face
);
...
...
src/hb-open-type.hh
浏览文件 @
c7a4e3df
...
@@ -523,7 +523,6 @@ struct ArrayOf
...
@@ -523,7 +523,6 @@ struct ArrayOf
::
qsort
(
arrayZ
,
len
,
sizeof
(
Type
),
Type
::
cmp
);
::
qsort
(
arrayZ
,
len
,
sizeof
(
Type
),
Type
::
cmp
);
}
}
private:
inline
bool
sanitize_shallow
(
hb_sanitize_context_t
*
c
)
const
inline
bool
sanitize_shallow
(
hb_sanitize_context_t
*
c
)
const
{
{
TRACE_SANITIZE
(
this
);
TRACE_SANITIZE
(
this
);
...
...
src/hb-ot-color-sbix-table.hh
浏览文件 @
c7a4e3df
...
@@ -142,6 +142,8 @@ struct sbix
...
@@ -142,6 +142,8 @@ struct sbix
DEFINE_SIZE_ARRAY
(
8
,
strikes
);
DEFINE_SIZE_ARRAY
(
8
,
strikes
);
};
};
struct
sbix_accelerator_t
:
sbix
::
accelerator_t
{};
}
/* namespace OT */
}
/* namespace OT */
#endif
/* HB_OT_COLOR_SBIX_TABLE_HH */
#endif
/* HB_OT_COLOR_SBIX_TABLE_HH */
src/hb-ot-color-svg-table.hh
浏览文件 @
c7a4e3df
...
@@ -41,12 +41,22 @@ namespace OT {
...
@@ -41,12 +41,22 @@ namespace OT {
struct
SVGDocumentIndexEntry
struct
SVGDocumentIndexEntry
{
{
friend
struct
SVG
;
friend
struct
SVG
;
friend
struct
SVGDocumentIndex
;
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
,
const
void
*
base
)
const
inline
int
cmp
(
hb_codepoint_t
g
)
const
{
return
g
<
startGlyphID
?
-
1
:
g
>
endGlyphID
?
1
:
0
;
}
static
int
cmp
(
const
void
*
pa
,
const
void
*
pb
)
{
const
hb_codepoint_t
*
a
=
(
const
hb_codepoint_t
*
)
pa
;
const
SVGDocumentIndexEntry
*
b
=
(
const
SVGDocumentIndexEntry
*
)
pb
;
return
b
->
cmp
(
*
a
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
{
TRACE_SANITIZE
(
this
);
TRACE_SANITIZE
(
this
);
return_trace
(
c
->
check_struct
(
this
)
&&
return_trace
(
c
->
check_struct
(
this
));
(
base
+
svgDoc
).
sanitize
(
c
,
svgDocLength
));
}
}
protected:
protected:
...
@@ -57,7 +67,7 @@ struct SVGDocumentIndexEntry
...
@@ -57,7 +67,7 @@ struct SVGDocumentIndexEntry
LOffsetTo
<
UnsizedArrayOf
<
HBUINT8
>
,
false
>
LOffsetTo
<
UnsizedArrayOf
<
HBUINT8
>
,
false
>
svgDoc
;
/* Offset from the beginning of the SVG Document Index
svgDoc
;
/* Offset from the beginning of the SVG Document Index
* to an SVG document. Must be non-zero. */
* to an SVG document. Must be non-zero. */
HBUINT32
svgDocLength
;
/* Length of the SVG document.
HBUINT32
svgDocLength
;
/* Length of the SVG document.
* Must be non-zero. */
* Must be non-zero. */
public:
public:
DEFINE_SIZE_STATIC
(
12
);
DEFINE_SIZE_STATIC
(
12
);
...
@@ -67,11 +77,22 @@ struct SVGDocumentIndex
...
@@ -67,11 +77,22 @@ struct SVGDocumentIndex
{
{
friend
struct
SVG
;
friend
struct
SVG
;
inline
const
SVGDocumentIndexEntry
&
get_glyph_entry
(
hb_codepoint_t
glyph_id
)
const
{
const
SVGDocumentIndexEntry
*
rec
;
rec
=
(
SVGDocumentIndexEntry
*
)
bsearch
(
&
glyph_id
,
&
entries
.
arrayZ
,
entries
.
len
,
sizeof
(
SVGDocumentIndexEntry
),
SVGDocumentIndexEntry
::
cmp
);
return
likely
(
rec
&&
glyph_id
<=
rec
->
endGlyphID
)
?
*
rec
:
Null
(
SVGDocumentIndexEntry
);
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
{
TRACE_SANITIZE
(
this
);
TRACE_SANITIZE
(
this
);
return_trace
(
c
->
check_struct
(
this
)
&&
return_trace
(
c
->
check_struct
(
this
)
&&
entries
.
sanitize
(
c
,
this
));
entries
.
sanitize
_shallow
(
c
));
}
}
protected:
protected:
...
@@ -85,13 +106,6 @@ struct SVG
...
@@ -85,13 +106,6 @@ struct SVG
{
{
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_SVG
;
static
const
hb_tag_t
tableTag
=
HB_OT_TAG_SVG
;
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)
&&
(
this
+
svgDocIndex
).
sanitize
(
c
)));
}
struct
accelerator_t
struct
accelerator_t
{
{
inline
void
init
(
hb_face_t
*
face
)
inline
void
init
(
hb_face_t
*
face
)
...
@@ -106,20 +120,39 @@ struct SVG
...
@@ -106,20 +120,39 @@ struct SVG
hb_blob_destroy
(
svg_blob
);
hb_blob_destroy
(
svg_blob
);
}
}
inline
void
inline
hb_blob_t
*
dump
(
void
(
*
callback
)
(
const
uint8_t
*
data
,
unsigned
int
length
,
failed_create_blob
(
hb_codepoint_t
glyph_id
,
unsigned
int
start_glyph
,
unsigned
int
end_glyph
))
const
hb_codepoint_t
*
start_glyph_id
,
hb_codepoint_t
*
end_glyph_id
)
const
{
{
if
(
start_glyph_id
)
*
start_glyph_id
=
0
;
if
(
end_glyph_id
)
*
end_glyph_id
=
0
;
return
hb_blob_get_empty
();
}
inline
hb_blob_t
*
create_blob
(
hb_codepoint_t
glyph_id
,
hb_codepoint_t
*
start_glyph_id
,
hb_codepoint_t
*
end_glyph_id
)
const
{
if
(
unlikely
(
svg_len
==
0
))
return
failed_create_blob
(
glyph_id
,
start_glyph_id
,
end_glyph_id
);
const
SVGDocumentIndex
&
index
=
svg
+
svg
->
svgDocIndex
;
const
SVGDocumentIndex
&
index
=
svg
+
svg
->
svgDocIndex
;
const
ArrayOf
<
SVGDocumentIndexEntry
>
&
entries
=
index
.
entries
;
const
SVGDocumentIndexEntry
&
entry
=
index
.
get_glyph_entry
(
glyph_id
);
for
(
unsigned
int
i
=
0
;
i
<
entries
.
len
;
++
i
)
if
(
unlikely
(
entry
.
svgDocLength
==
0
))
{
return
failed_create_blob
(
glyph_id
,
start_glyph_id
,
end_glyph_id
);
const
SVGDocumentIndexEntry
&
entry
=
entries
[
i
];
unsigned
int
blob_offset
=
entry
.
svgDoc
;
callback
((
const
uint8_t
*
)
&
entry
.
svgDoc
(
&
index
),
entry
.
svgDocLength
,
blob_offset
+=
svg
->
svgDocIndex
;
entry
.
startGlyphID
,
entry
.
endGlyphID
);
if
(
unlikely
(
blob_offset
>
svg_len
||
blob_offset
+
entry
.
svgDocLength
>
svg_len
))
}
return
failed_create_blob
(
glyph_id
,
start_glyph_id
,
end_glyph_id
);
if
(
start_glyph_id
)
*
start_glyph_id
=
entry
.
startGlyphID
;
if
(
end_glyph_id
)
*
end_glyph_id
=
entry
.
endGlyphID
;
return
hb_blob_create_sub_blob
(
svg_blob
,
blob_offset
,
entry
.
svgDocLength
);
}
}
inline
bool
has_data
()
const
{
return
svg_len
;
}
private:
private:
hb_blob_t
*
svg_blob
;
hb_blob_t
*
svg_blob
;
const
SVG
*
svg
;
const
SVG
*
svg
;
...
@@ -127,6 +160,13 @@ struct SVG
...
@@ -127,6 +160,13 @@ struct SVG
unsigned
int
svg_len
;
unsigned
int
svg_len
;
};
};
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
TRACE_SANITIZE
(
this
);
return_trace
(
likely
(
c
->
check_struct
(
this
)
&&
(
this
+
svgDocIndex
).
sanitize
(
c
)));
}
protected:
protected:
HBUINT16
version
;
/* Table version (starting at 0). */
HBUINT16
version
;
/* Table version (starting at 0). */
LOffsetTo
<
SVGDocumentIndex
>
LOffsetTo
<
SVGDocumentIndex
>
...
@@ -137,6 +177,8 @@ struct SVG
...
@@ -137,6 +177,8 @@ struct SVG
DEFINE_SIZE_STATIC
(
10
);
DEFINE_SIZE_STATIC
(
10
);
};
};
struct
SVG_accelerator_t
:
SVG
::
accelerator_t
{};
}
/* namespace OT */
}
/* namespace OT */
...
...
src/hb-ot-color.cc
浏览文件 @
c7a4e3df
...
@@ -54,6 +54,13 @@ _get_cpal (hb_face_t *face)
...
@@ -54,6 +54,13 @@ _get_cpal (hb_face_t *face)
return
*
(
hb_ot_face_data
(
face
)
->
CPAL
.
get
());
return
*
(
hb_ot_face_data
(
face
)
->
CPAL
.
get
());
}
}
static
inline
const
OT
::
SVG_accelerator_t
&
_get_svg
(
hb_face_t
*
face
)
{
if
(
unlikely
(
!
hb_ot_shaper_face_data_ensure
(
face
)))
return
Null
(
OT
::
SVG_accelerator_t
);
return
*
(
hb_ot_face_data
(
face
)
->
SVG
.
get
());
}
#if 0
#if 0
static inline const OT::CBDT_accelerator_t&
static inline const OT::CBDT_accelerator_t&
_get_cbdt (hb_face_t *face)
_get_cbdt (hb_face_t *face)
...
@@ -68,13 +75,6 @@ _get_sbix (hb_face_t *face)
...
@@ -68,13 +75,6 @@ _get_sbix (hb_face_t *face)
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::sbix);
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::sbix);
return *(hb_ot_face_data (face)->sbix.get ());
return *(hb_ot_face_data (face)->sbix.get ());
}
}
static inline const OT::SVG&
_get_svg (hb_face_t *face)
{
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::SVG);
return *(hb_ot_face_data (face)->SVG.get ());
}
#endif
#endif
...
@@ -238,3 +238,42 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
...
@@ -238,3 +238,42 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
{
{
return
_get_colr
(
face
).
get_glyph_layers
(
glyph
,
start_offset
,
count
,
layers
);
return
_get_colr
(
face
).
get_glyph_layers
(
glyph
,
start_offset
,
count
,
layers
);
}
}
/*
* SVG
*/
/**
* hb_ot_color_has_svg:
* @face: a font face.
*
* Returns: whether SVG table is available.
*
* Since: REPLACEME
*/
hb_bool_t
hb_ot_color_has_svg
(
hb_face_t
*
face
)
{
return
_get_svg
(
face
).
has_data
();
}
/**
* hb_ot_color_glyph_svg_create_blob:
* @face:
* @glyph:
* @start_glyph: (out) (optional): Start of range this SVG supports
* @end_glyph: (out) (optional): End of range this SVG supports
*
* Returns:
*
* Since: REPLACEME
*/
hb_blob_t
*
hb_ot_color_glyph_svg_create_blob
(
hb_face_t
*
face
,
hb_codepoint_t
glyph
,
hb_codepoint_t
*
start_glyph
,
/* OUT. May be NULL. */
hb_codepoint_t
*
end_glyph
/* OUT. May be NULL. */
)
{
return
_get_svg
(
face
).
create_blob
(
glyph
,
start_glyph
,
end_glyph
);
}
src/hb-ot-color.h
浏览文件 @
c7a4e3df
...
@@ -111,6 +111,19 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
...
@@ -111,6 +111,19 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
unsigned
int
*
count
,
/* IN/OUT. May be NULL. */
unsigned
int
*
count
,
/* IN/OUT. May be NULL. */
hb_ot_color_layer_t
*
layers
/* OUT. May be NULL. */
);
hb_ot_color_layer_t
*
layers
/* OUT. May be NULL. */
);
/*
* SVG
*/
HB_EXTERN
hb_bool_t
hb_ot_color_has_svg
(
hb_face_t
*
face
);
HB_EXTERN
hb_blob_t
*
hb_ot_color_glyph_svg_create_blob
(
hb_face_t
*
face
,
hb_codepoint_t
glyph
,
hb_codepoint_t
*
start_glyph
,
/* OUT. May be NULL. */
hb_codepoint_t
*
end_glyph
/* OUT. May be NULL. */
);
HB_END_DECLS
HB_END_DECLS
...
...
src/hb-ot-face.cc
浏览文件 @
c7a4e3df
...
@@ -32,6 +32,8 @@
...
@@ -32,6 +32,8 @@
#include "hb-ot-kern-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-post-table.hh"
#include "hb-ot-post-table.hh"
#include "hb-ot-color-cbdt-table.hh"
#include "hb-ot-color-cbdt-table.hh"
#include "hb-ot-color-sbix-table.hh"
#include "hb-ot-color-svg-table.hh"
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
#include "hb-ot-layout-gpos-table.hh"
...
...
src/hb-ot-face.hh
浏览文件 @
c7a4e3df
...
@@ -73,8 +73,8 @@
...
@@ -73,8 +73,8 @@
HB_OT_TABLE(OT, COLR) \
HB_OT_TABLE(OT, COLR) \
HB_OT_TABLE(OT, CPAL) \
HB_OT_TABLE(OT, CPAL) \
HB_OT_ACCELERATOR(OT, CBDT) \
HB_OT_ACCELERATOR(OT, CBDT) \
HB_OT_
TABLE
(OT, sbix) \
HB_OT_
ACCELERATOR
(OT, sbix) \
HB_OT_
TABLE
(OT, SVG) \
HB_OT_
ACCELERATOR
(OT, SVG) \
/* */
/* */
/* Declare tables. */
/* Declare tables. */
...
...
src/hb-ot-layout.cc
浏览文件 @
c7a4e3df
...
@@ -41,10 +41,6 @@
...
@@ -41,10 +41,6 @@
// Just so we compile them; unused otherwise:
// Just so we compile them; unused otherwise:
#include "hb-ot-layout-base-table.hh"
#include "hb-ot-layout-base-table.hh"
#include "hb-ot-layout-jstf-table.hh"
#include "hb-ot-layout-jstf-table.hh"
#include "hb-ot-color-colr-table.hh"
#include "hb-ot-color-cpal-table.hh"
#include "hb-ot-color-sbix-table.hh"
#include "hb-ot-color-svg-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-name-table.hh"
#include "hb-ot-name-table.hh"
...
...
test/api/test-ot-color.c
浏览文件 @
c7a4e3df
...
@@ -103,6 +103,7 @@ static hb_face_t *cpal = NULL;
...
@@ -103,6 +103,7 @@ static hb_face_t *cpal = NULL;
static
hb_face_t
*
cbdt
=
NULL
;
static
hb_face_t
*
cbdt
=
NULL
;
static
hb_face_t
*
sbix
=
NULL
;
static
hb_face_t
*
sbix
=
NULL
;
static
hb_face_t
*
svg
=
NULL
;
static
hb_face_t
*
svg
=
NULL
;
static
hb_face_t
*
empty
=
NULL
;
#define assert_color_rgba(colors, i, r, g, b, a) G_STMT_START { \
#define assert_color_rgba(colors, i, r, g, b, a) G_STMT_START { \
const hb_color_t *_colors = (colors); \
const hb_color_t *_colors = (colors); \
...
@@ -203,7 +204,6 @@ test_hb_ot_color_palette_get_flags_v1 (void)
...
@@ -203,7 +204,6 @@ test_hb_ot_color_palette_get_flags_v1 (void)
static
void
static
void
test_hb_ot_color_palette_get_colors_empty
(
void
)
test_hb_ot_color_palette_get_colors_empty
(
void
)
{
{
hb_face_t
*
empty
=
hb_face_get_empty
();
g_assert_cmpint
(
hb_ot_color_palette_get_colors
(
empty
,
0
,
0
,
NULL
,
NULL
),
==
,
0
);
g_assert_cmpint
(
hb_ot_color_palette_get_colors
(
empty
,
0
,
0
,
NULL
,
NULL
),
==
,
0
);
}
}
...
@@ -302,8 +302,6 @@ test_hb_ot_color_palette_get_colors_v1 (void)
...
@@ -302,8 +302,6 @@ test_hb_ot_color_palette_get_colors_v1 (void)
static
void
static
void
test_hb_ot_color_palette_color_get_name_id
(
void
)
test_hb_ot_color_palette_color_get_name_id
(
void
)
{
{
hb_face_t
*
empty
=
hb_face_get_empty
();
g_assert_cmpuint
(
hb_ot_color_palette_color_get_name_id
(
empty
,
0
),
==
,
HB_NAME_ID_INVALID
);
g_assert_cmpuint
(
hb_ot_color_palette_color_get_name_id
(
empty
,
0
),
==
,
HB_NAME_ID_INVALID
);
g_assert_cmpuint
(
hb_ot_color_palette_color_get_name_id
(
empty
,
1
),
==
,
HB_NAME_ID_INVALID
);
g_assert_cmpuint
(
hb_ot_color_palette_color_get_name_id
(
empty
,
1
),
==
,
HB_NAME_ID_INVALID
);
g_assert_cmpuint
(
hb_ot_color_palette_color_get_name_id
(
empty
,
2
),
==
,
HB_NAME_ID_INVALID
);
g_assert_cmpuint
(
hb_ot_color_palette_color_get_name_id
(
empty
,
2
),
==
,
HB_NAME_ID_INVALID
);
...
@@ -349,8 +347,6 @@ test_hb_ot_color_glyph_get_layers (void)
...
@@ -349,8 +347,6 @@ test_hb_ot_color_glyph_get_layers (void)
static
void
static
void
test_hb_ot_color_has_data
(
void
)
test_hb_ot_color_has_data
(
void
)
{
{
hb_face_t
*
empty
=
hb_face_get_empty
();
g_assert
(
hb_ot_color_has_layers
(
empty
)
==
FALSE
);
g_assert
(
hb_ot_color_has_layers
(
empty
)
==
FALSE
);
g_assert
(
hb_ot_color_has_layers
(
cpal_v0
)
==
TRUE
);
g_assert
(
hb_ot_color_has_layers
(
cpal_v0
)
==
TRUE
);
g_assert
(
hb_ot_color_has_layers
(
cpal_v1
)
==
TRUE
);
g_assert
(
hb_ot_color_has_layers
(
cpal_v1
)
==
TRUE
);
...
@@ -366,6 +362,41 @@ test_hb_ot_color_has_data (void)
...
@@ -366,6 +362,41 @@ test_hb_ot_color_has_data (void)
g_assert
(
hb_ot_color_has_palettes
(
cbdt
)
==
FALSE
);
g_assert
(
hb_ot_color_has_palettes
(
cbdt
)
==
FALSE
);
g_assert
(
hb_ot_color_has_palettes
(
sbix
)
==
FALSE
);
g_assert
(
hb_ot_color_has_palettes
(
sbix
)
==
FALSE
);
g_assert
(
hb_ot_color_has_palettes
(
svg
)
==
FALSE
);
g_assert
(
hb_ot_color_has_palettes
(
svg
)
==
FALSE
);
g_assert
(
hb_ot_color_has_svg
(
empty
)
==
FALSE
);
g_assert
(
hb_ot_color_has_svg
(
cpal_v0
)
==
FALSE
);
g_assert
(
hb_ot_color_has_svg
(
cpal_v1
)
==
FALSE
);
g_assert
(
hb_ot_color_has_svg
(
cpal
)
==
FALSE
);
g_assert
(
hb_ot_color_has_svg
(
cbdt
)
==
FALSE
);
g_assert
(
hb_ot_color_has_svg
(
sbix
)
==
FALSE
);
g_assert
(
hb_ot_color_has_svg
(
svg
)
==
TRUE
);
}
static
void
test_hb_ot_color_svg
(
void
)
{
hb_codepoint_t
start_glyph
,
end_glyph
;
hb_blob_t
*
blob
;
blob
=
hb_ot_color_glyph_svg_create_blob
(
svg
,
0
,
&
start_glyph
,
&
end_glyph
);
g_assert
(
hb_blob_get_length
(
blob
)
==
0
);
g_assert
(
start_glyph
==
0
);
g_assert
(
end_glyph
==
0
);
blob
=
hb_ot_color_glyph_svg_create_blob
(
svg
,
1
,
&
start_glyph
,
&
end_glyph
);
unsigned
int
length
;
const
char
*
data
=
hb_blob_get_data
(
blob
,
&
length
);
g_assert_cmpuint
(
length
,
==
,
146
);
g_assert_cmpuint
(
start_glyph
,
==
,
1
);
g_assert_cmpuint
(
end_glyph
,
==
,
1
);
g_assert
(
strncmp
(
data
,
"<?xml"
,
4
)
==
0
);
g_assert
(
strncmp
(
data
+
140
,
"</svg>"
,
5
)
==
0
);
hb_blob_destroy
(
blob
);
blob
=
hb_ot_color_glyph_svg_create_blob
(
empty
,
0
,
&
start_glyph
,
&
end_glyph
);
g_assert
(
hb_blob_get_length
(
blob
)
==
0
);
g_assert
(
start_glyph
==
0
);
g_assert
(
end_glyph
==
0
);
}
}
int
int
...
@@ -380,6 +411,7 @@ main (int argc, char **argv)
...
@@ -380,6 +411,7 @@ main (int argc, char **argv)
cbdt
=
hb_test_open_font_file
(
"fonts/chromacheck-cbdt.ttf"
);
cbdt
=
hb_test_open_font_file
(
"fonts/chromacheck-cbdt.ttf"
);
sbix
=
hb_test_open_font_file
(
"fonts/chromacheck-sbix.ttf"
);
sbix
=
hb_test_open_font_file
(
"fonts/chromacheck-sbix.ttf"
);
svg
=
hb_test_open_font_file
(
"fonts/chromacheck-svg.ttf"
);
svg
=
hb_test_open_font_file
(
"fonts/chromacheck-svg.ttf"
);
empty
=
hb_face_get_empty
();
hb_test_add
(
test_hb_ot_color_palette_get_count
);
hb_test_add
(
test_hb_ot_color_palette_get_count
);
hb_test_add
(
test_hb_ot_color_palette_get_name_id_empty
);
hb_test_add
(
test_hb_ot_color_palette_get_name_id_empty
);
hb_test_add
(
test_hb_ot_color_palette_get_name_id_v0
);
hb_test_add
(
test_hb_ot_color_palette_get_name_id_v0
);
...
@@ -393,6 +425,7 @@ main (int argc, char **argv)
...
@@ -393,6 +425,7 @@ main (int argc, char **argv)
hb_test_add
(
test_hb_ot_color_palette_color_get_name_id
);
hb_test_add
(
test_hb_ot_color_palette_color_get_name_id
);
hb_test_add
(
test_hb_ot_color_glyph_get_layers
);
hb_test_add
(
test_hb_ot_color_glyph_get_layers
);
hb_test_add
(
test_hb_ot_color_has_data
);
hb_test_add
(
test_hb_ot_color_has_data
);
hb_test_add
(
test_hb_ot_color_svg
);
status
=
hb_test_run
();
status
=
hb_test_run
();
hb_face_destroy
(
cpal_v0
);
hb_face_destroy
(
cpal_v0
);
hb_face_destroy
(
cpal_v1
);
hb_face_destroy
(
cpal_v1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录