Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
850a7af3
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看板
未验证
提交
850a7af3
编写于
10月 31, 2018
作者:
E
Ebrahim Byagowi
提交者:
GitHub
10月 31, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ot-color-test] Remove the non-working exact strike size storing (#1339)
上级
2e639c47
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
73 deletion
+62
-73
src/test-ot-color.cc
src/test-ot-color.cc
+62
-73
未找到文件。
src/test-ot-color.cc
浏览文件 @
850a7af3
...
...
@@ -23,7 +23,7 @@
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#include "hb.h
h
"
#include "hb.h"
#include "hb-ot.h"
#include "hb-ft.h"
...
...
@@ -39,74 +39,6 @@
#include <stdlib.h>
#include <stdio.h>
static
void
png_dump
(
hb_face_t
*
face
,
unsigned
int
face_index
)
{
unsigned
glyph_count
=
hb_face_get_glyph_count
(
face
);
hb_font_t
*
font
=
hb_font_create
(
face
);
/* ugly hack, scans the font for strikes, not needed for regular clients */
#define STRIKES_MAX 20
unsigned
int
strikes_count
=
0
;
unsigned
int
strikes
[
STRIKES_MAX
]
=
{
0
};
{
/* find a sample glyph */
unsigned
int
sample_glyph_id
;
/* we don't care much about different strikes for different glyphs */
for
(
sample_glyph_id
=
0
;
sample_glyph_id
<
glyph_count
;
sample_glyph_id
++
)
{
hb_blob_t
*
blob
=
hb_ot_color_glyph_reference_png
(
font
,
sample_glyph_id
);
unsigned
int
blob_length
=
hb_blob_get_length
(
blob
);
hb_blob_destroy
(
blob
);
if
(
blob_length
!=
0
)
break
;
}
/* find strikes it has */
unsigned
int
upem
=
hb_face_get_upem
(
face
);
unsigned
int
blob_length
=
0
;
for
(
unsigned
int
ppem
=
1
;
ppem
<=
upem
&&
strikes_count
<
STRIKES_MAX
;
ppem
++
)
{
hb_font_set_ppem
(
font
,
ppem
,
ppem
);
hb_blob_t
*
blob
=
hb_ot_color_glyph_reference_png
(
font
,
sample_glyph_id
);
unsigned
int
new_blob_length
=
hb_blob_get_length
(
blob
);
if
(
blob_length
!=
new_blob_length
)
{
strikes_count
++
;
blob_length
=
new_blob_length
;
}
if
(
strikes_count
!=
0
)
strikes
[
strikes_count
-
1
]
=
ppem
;
hb_blob_destroy
(
blob
);
}
/* can't report the biggest strike correctly, and, we can't do anything about it */
}
#undef STRIKES_MAX
for
(
unsigned
int
strike
=
0
;
strike
<
strikes_count
;
strike
++
)
for
(
unsigned
int
glyph_id
=
0
;
glyph_id
<
glyph_count
;
glyph_id
++
)
{
unsigned
int
ppem
=
strikes
[
strike
];
hb_font_set_ppem
(
font
,
ppem
,
ppem
);
hb_blob_t
*
blob
=
hb_ot_color_glyph_reference_png
(
font
,
glyph_id
);
if
(
hb_blob_get_length
(
blob
)
==
0
)
continue
;
unsigned
int
length
;
const
char
*
data
=
hb_blob_get_data
(
blob
,
&
length
);
char
output_path
[
255
];
sprintf
(
output_path
,
"out/png-%d-%d-%d.png"
,
glyph_id
,
strike
,
face_index
);
FILE
*
f
=
fopen
(
output_path
,
"wb"
);
fwrite
(
data
,
1
,
length
,
f
);
fclose
(
f
);
hb_blob_destroy
(
blob
);
}
hb_font_destroy
(
font
);
}
static
void
svg_dump
(
hb_face_t
*
face
,
unsigned
int
face_index
)
{
...
...
@@ -136,6 +68,63 @@ svg_dump (hb_face_t *face, unsigned int face_index)
}
}
/* _png API is so easy to use unlike the below code, don't get confused */
static
void
png_dump
(
hb_face_t
*
face
,
unsigned
int
face_index
)
{
unsigned
glyph_count
=
hb_face_get_glyph_count
(
face
);
hb_font_t
*
font
=
hb_font_create
(
face
);
/* scans the font for strikes */
unsigned
int
sample_glyph_id
;
/* we don't care about different strikes for different glyphs at this point */
for
(
sample_glyph_id
=
0
;
sample_glyph_id
<
glyph_count
;
sample_glyph_id
++
)
{
hb_blob_t
*
blob
=
hb_ot_color_glyph_reference_png
(
font
,
sample_glyph_id
);
unsigned
int
blob_length
=
hb_blob_get_length
(
blob
);
hb_blob_destroy
(
blob
);
if
(
blob_length
!=
0
)
break
;
}
unsigned
int
upem
=
hb_face_get_upem
(
face
);
unsigned
int
blob_length
=
0
;
unsigned
int
strike
=
0
;
for
(
unsigned
int
ppem
=
1
;
ppem
<=
upem
;
ppem
++
)
{
hb_font_set_ppem
(
font
,
ppem
,
ppem
);
hb_blob_t
*
blob
=
hb_ot_color_glyph_reference_png
(
font
,
sample_glyph_id
);
unsigned
int
new_blob_length
=
hb_blob_get_length
(
blob
);
hb_blob_destroy
(
blob
);
if
(
new_blob_length
!=
blob_length
)
{
for
(
unsigned
int
glyph_id
=
0
;
glyph_id
<
glyph_count
;
glyph_id
++
)
{
hb_blob_t
*
blob
=
hb_ot_color_glyph_reference_png
(
font
,
glyph_id
);
if
(
hb_blob_get_length
(
blob
)
==
0
)
continue
;
unsigned
int
length
;
const
char
*
data
=
hb_blob_get_data
(
blob
,
&
length
);
char
output_path
[
255
];
sprintf
(
output_path
,
"out/png-%d-%d-%d.png"
,
glyph_id
,
strike
,
face_index
);
FILE
*
f
=
fopen
(
output_path
,
"wb"
);
fwrite
(
data
,
1
,
length
,
f
);
fclose
(
f
);
hb_blob_destroy
(
blob
);
}
strike
++
;
blob_length
=
new_blob_length
;
}
}
hb_font_destroy
(
font
);
}
static
void
layered_glyph_dump
(
hb_face_t
*
face
,
cairo_font_face_t
*
cairo_face
,
unsigned
int
face_index
)
{
...
...
@@ -144,7 +133,7 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int
unsigned
glyph_count
=
hb_face_get_glyph_count
(
face
);
for
(
hb_codepoint_t
gid
=
0
;
gid
<
glyph_count
;
++
gid
)
{
unsigned
int
num_layers
=
hb_ot_color_glyph_get_layers
(
face
,
gid
,
0
,
nullptr
,
nullptr
);
unsigned
int
num_layers
=
hb_ot_color_glyph_get_layers
(
face
,
gid
,
0
,
NULL
,
NULL
);
if
(
!
num_layers
)
continue
;
...
...
@@ -181,7 +170,7 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int
for
(
unsigned
int
palette
=
0
;
palette
<
palette_count
;
palette
++
)
{
char
output_path
[
255
];
unsigned
int
num_colors
=
hb_ot_color_palette_get_colors
(
face
,
palette
,
0
,
nullptr
,
nullptr
);
unsigned
int
num_colors
=
hb_ot_color_palette_get_colors
(
face
,
palette
,
0
,
NULL
,
NULL
);
if
(
!
num_colors
)
continue
;
...
...
@@ -282,14 +271,14 @@ main (int argc, char **argv)
FILE
*
font_name_file
=
fopen
(
"out/.dumped_font_name"
,
"r"
);
if
(
font_name_file
!=
nullptr
)
if
(
font_name_file
!=
NULL
)
{
fprintf
(
stderr
,
"Purge or move ./out folder in order to run a new dump
\n
"
);
exit
(
1
);
}
font_name_file
=
fopen
(
"out/.dumped_font_name"
,
"w"
);
if
(
font_name_file
==
nullptr
)
if
(
font_name_file
==
NULL
)
{
fprintf
(
stderr
,
"./out is not accessible as a folder, create it please
\n
"
);
exit
(
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录