Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
d1298971
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看板
提交
d1298971
编写于
3月 31, 2016
作者:
E
Ebrahim Byagowi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor and remove dupe getglyphs call
上级
5f1a8961
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
55 deletion
+51
-55
src/hb-directwrite.cc
src/hb-directwrite.cc
+51
-55
未找到文件。
src/hb-directwrite.cc
浏览文件 @
d1298971
...
...
@@ -677,14 +677,6 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
UINT32
maxGlyphs
=
3
*
length
/
2
+
16
;
#define INITIAL_GLYPH_SIZE 400
UINT16
*
clusters
=
(
UINT16
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
UINT16
));
UINT16
*
glyphs
=
(
UINT16
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
UINT16
));
DWRITE_SHAPING_TEXT_PROPERTIES
*
textProperties
=
(
DWRITE_SHAPING_TEXT_PROPERTIES
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
DWRITE_SHAPING_TEXT_PROPERTIES
));
DWRITE_SHAPING_GLYPH_PROPERTIES
*
glyphProperties
=
(
DWRITE_SHAPING_GLYPH_PROPERTIES
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
DWRITE_SHAPING_GLYPH_PROPERTIES
));
UINT32
actualGlyphs
;
bool
backward
=
HB_DIRECTION_IS_BACKWARD
(
buffer
->
props
.
direction
);
...
...
@@ -694,6 +686,20 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
mbstowcs
((
wchar_t
*
)
lang
,
hb_language_to_string
(
buffer
->
props
.
language
),
4
);
}
#define FAIL(...) \
HB_STMT_START { \
DEBUG_MSG (DIRECTWRITE, NULL, __VA_ARGS__); \
return false; \
} HB_STMT_END;
retry_getglyphs:
UINT16
*
clusters
=
(
UINT16
*
)
malloc
(
maxGlyphs
*
sizeof
(
UINT16
));
UINT16
*
glyphs
=
(
UINT16
*
)
malloc
(
maxGlyphs
*
sizeof
(
UINT16
));
DWRITE_SHAPING_TEXT_PROPERTIES
*
textProperties
=
(
DWRITE_SHAPING_TEXT_PROPERTIES
*
)
malloc
(
maxGlyphs
*
sizeof
(
DWRITE_SHAPING_TEXT_PROPERTIES
));
DWRITE_SHAPING_GLYPH_PROPERTIES
*
glyphProperties
=
(
DWRITE_SHAPING_GLYPH_PROPERTIES
*
)
malloc
(
maxGlyphs
*
sizeof
(
DWRITE_SHAPING_GLYPH_PROPERTIES
));
hr
=
analyzer
->
GetGlyphs
(
pchars
,
length
,
fontFace
,
FALSE
,
backward
,
...
...
@@ -701,34 +707,24 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
maxGlyphs
,
clusters
,
textProperties
,
glyphs
,
glyphProperties
,
&
actualGlyphs
);
if
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
))
{
free
(
clusters
);
free
(
glyphs
);
free
(
textProperties
);
free
(
glyphProperties
);
clusters
=
(
UINT16
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
UINT16
));
glyphs
=
(
UINT16
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
UINT16
));
textProperties
=
(
DWRITE_SHAPING_TEXT_PROPERTIES
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
DWRITE_SHAPING_TEXT_PROPERTIES
));
glyphProperties
=
(
DWRITE_SHAPING_GLYPH_PROPERTIES
*
)
malloc
(
INITIAL_GLYPH_SIZE
*
sizeof
(
DWRITE_SHAPING_GLYPH_PROPERTIES
));
hr
=
analyzer
->
GetGlyphs
(
pchars
,
length
,
fontFace
,
FALSE
,
backward
,
&
runHead
->
mScript
,
lang
,
NULL
,
NULL
,
NULL
,
0
,
maxGlyphs
,
clusters
,
textProperties
,
glyphs
,
glyphProperties
,
&
actualGlyphs
);
if
(
unlikely
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
)))
{
free
(
clusters
);
free
(
glyphs
);
free
(
textProperties
);
free
(
glyphProperties
);
maxGlyphs
*=
2
;
goto
retry_getglyphs
;
}
if
(
FAILED
(
hr
))
{
//NS_WARNING
("Analyzer failed to get glyphs.");
if
(
FAILED
(
hr
))
{
FAIL
(
"Analyzer failed to get glyphs."
);
return
false
;
}
FLOAT
advances
[
400
]
;
DWRITE_GLYPH_OFFSET
offsets
[
400
];
FLOAT
*
advances
=
(
FLOAT
*
)
malloc
(
actualGlyphs
*
sizeof
(
FLOAT
))
;
DWRITE_GLYPH_OFFSET
*
offsets
=
(
DWRITE_GLYPH_OFFSET
*
)
malloc
(
actualGlyphs
*
sizeof
(
DWRITE_GLYPH_OFFSET
));
/* The -2 in the following is to compensate for possible
* alignment needed after the WORD array. sizeof(WORD) == 2. */
...
...
@@ -742,16 +738,16 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
#undef ALLOCATE_ARRAY
int
font
_s
ize
=
font
->
face
->
get_upem
();
if
(
font
_s
ize
<
0
)
font
_size
=
-
font_s
ize
;
int
font
S
ize
=
font
->
face
->
get_upem
();
if
(
font
S
ize
<
0
)
font
Size
=
-
fontS
ize
;
if
(
font
_s
ize
<
0
)
font_size
=
-
font_s
ize
;
double
x_mult
=
(
double
)
font
->
x_scale
/
font
_s
ize
;
double
y_mult
=
(
double
)
font
->
y_scale
/
font
_s
ize
;
if
(
font
S
ize
<
0
)
fontSize
=
-
fontS
ize
;
double
x_mult
=
(
double
)
font
->
x_scale
/
font
S
ize
;
double
y_mult
=
(
double
)
font
->
y_scale
/
font
S
ize
;
hr
=
analyzer
->
GetGlyphPlacements
(
pchars
,
hr
=
analyzer
->
GetGlyphPlacements
(
pchars
,
clusters
,
textProperties
,
length
,
...
...
@@ -759,7 +755,7 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
glyphProperties
,
actualGlyphs
,
fontFace
,
font
_s
ize
,
font
S
ize
,
FALSE
,
backward
,
&
runHead
->
mScript
,
...
...
@@ -770,37 +766,35 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
advances
,
offsets
);
if
(
FAILED
(
hr
))
{
//NS_WARNING
("Analyzer failed to get glyph placements.");
if
(
FAILED
(
hr
))
{
FAIL
(
"Analyzer failed to get glyph placements."
);
return
false
;
}
unsigned
int
glyphs_len
=
actualGlyphs
;
/* Ok, we've got everything we need, now compose output buffer,
* very, *very*, carefully! */
/* Calculate visual-clusters. That's what we ship. */
for
(
unsigned
int
i
=
0
;
i
<
glyphs_len
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
actualGlyphs
;
i
++
)
vis_clusters
[
i
]
=
-
1
;
for
(
unsigned
int
i
=
0
;
i
<
buffer
->
len
;
i
++
)
{
uint32_t
*
p
=
&
vis_clusters
[
log_clusters
[
buffer
->
info
[
i
].
utf16_index
()]];
//*p = MIN (*p, buffer->info[i].cluster);
}
for
(
unsigned
int
i
=
1
;
i
<
glyphs_len
;
i
++
)
for
(
unsigned
int
i
=
1
;
i
<
actualGlyphs
;
i
++
)
if
(
vis_clusters
[
i
]
==
-
1
)
vis_clusters
[
i
]
=
vis_clusters
[
i
-
1
];
#undef utf16_index
//if (unlikely (!buffer->ensure (glyphs_len
)))
//
FAIL ("Buffer in error");
if
(
unlikely
(
!
buffer
->
ensure
(
actualGlyphs
)))
FAIL
(
"Buffer in error"
);
#undef FAIL
/* Set glyph infos */
buffer
->
len
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
glyphs_len
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
actualGlyphs
;
i
++
)
{
hb_glyph_info_t
*
info
=
&
buffer
->
info
[
buffer
->
len
++
];
...
...
@@ -815,7 +809,7 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
/* Set glyph positions */
buffer
->
clear_positions
();
for
(
unsigned
int
i
=
0
;
i
<
glyphs_len
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
actualGlyphs
;
i
++
)
{
hb_glyph_info_t
*
info
=
&
buffer
->
info
[
i
];
hb_glyph_position_t
*
pos
=
&
buffer
->
pos
[
i
];
...
...
@@ -829,10 +823,12 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
if
(
backward
)
hb_buffer_reverse
(
buffer
);
free
(
clusters
);
free
(
glyphs
);
free
(
textProperties
);
free
(
glyphProperties
);
free
(
clusters
);
free
(
glyphs
);
free
(
textProperties
);
free
(
glyphProperties
);
free
(
advances
);
free
(
offsets
);
/* Wow, done! */
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录