Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
15063b12
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看板
提交
15063b12
编写于
2月 22, 2016
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[coretext] Move CTFont construction to face_data
上级
ba3d49d9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
36 deletion
+30
-36
src/hb-coretext.cc
src/hb-coretext.cc
+30
-36
未找到文件。
src/hb-coretext.cc
浏览文件 @
15063b12
...
...
@@ -166,6 +166,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
struct
hb_coretext_shaper_face_data_t
{
CGFontRef
cg_font
;
CTFontRef
ct_font
;
};
hb_coretext_shaper_face_data_t
*
...
...
@@ -178,7 +179,23 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
data
->
cg_font
=
create_cg_font
(
face
);
if
(
unlikely
(
!
data
->
cg_font
))
{
DEBUG_MSG
(
CORETEXT
,
face
,
"Failed creating CGFont."
);
DEBUG_MSG
(
CORETEXT
,
face
,
"CGFont creation failed.."
);
free
(
data
);
return
NULL
;
}
/* We use 36pt size instead of UPEM, because CoreText implements the 'trak' table,
* which can make the font too tight at large sizes. 36pt should be a good semi-neutral
* size.
*
* Since we always create CTFont at a fixed size, our CTFont lives in face_data
* instead of font_data. Which is good, because when people change scale on
* hb_font_t, we won't need to update our CTFont. */
data
->
ct_font
=
create_ct_font
(
data
->
cg_font
,
36.
);
if
(
unlikely
(
!
data
->
ct_font
))
{
DEBUG_MSG
(
CORETEXT
,
face
,
"CTFont creation failed."
);
CFRelease
(
data
->
cg_font
);
free
(
data
);
return
NULL
;
}
...
...
@@ -189,6 +206,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
void
_hb_coretext_shaper_face_data_destroy
(
hb_coretext_shaper_face_data_t
*
data
)
{
CFRelease
(
data
->
ct_font
);
CFRelease
(
data
->
cg_font
);
free
(
data
);
}
...
...
@@ -209,41 +227,17 @@ hb_coretext_face_get_cg_font (hb_face_t *face)
* shaper font data
*/
struct
hb_coretext_shaper_font_data_t
{
CTFontRef
ct_font
;
};
struct
hb_coretext_shaper_font_data_t
{};
hb_coretext_shaper_font_data_t
*
_hb_coretext_shaper_font_data_create
(
hb_font_t
*
font
)
{
if
(
unlikely
(
!
hb_coretext_shaper_face_data_ensure
(
font
->
face
)))
return
NULL
;
hb_coretext_shaper_font_data_t
*
data
=
(
hb_coretext_shaper_font_data_t
*
)
calloc
(
1
,
sizeof
(
hb_coretext_shaper_font_data_t
));
if
(
unlikely
(
!
data
))
return
NULL
;
hb_face_t
*
face
=
font
->
face
;
hb_coretext_shaper_face_data_t
*
face_data
=
HB_SHAPER_DATA_GET
(
face
);
/* We use 36pt size instead of UPEM, because CoreText implements the 'trak' table,
* which can make the font too tight at large sizes. 36pt should be a good semi-neutral
* size. */
data
->
ct_font
=
create_ct_font
(
face_data
->
cg_font
,
36.
);
if
(
unlikely
(
!
data
->
ct_font
))
{
DEBUG_MSG
(
CORETEXT
,
font
,
"CTFont creation failed"
);
free
(
data
);
return
NULL
;
}
return
data
;
return
(
hb_coretext_shaper_font_data_t
*
)
HB_SHAPER_DATA_SUCCEEDED
;
}
void
_hb_coretext_shaper_font_data_destroy
(
hb_coretext_shaper_font_data_t
*
data
)
{
CFRelease
(
data
->
ct_font
);
free
(
data
);
}
...
...
@@ -269,9 +263,10 @@ _hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_
CTFontRef
hb_coretext_font_get_ct_font
(
hb_font_t
*
font
)
{
if
(
unlikely
(
!
hb_coretext_shaper_font_data_ensure
(
font
)))
return
NULL
;
hb_coretext_shaper_font_data_t
*
font_data
=
HB_SHAPER_DATA_GET
(
font
);
return
font_data
->
ct_font
;
hb_face_t
*
face
=
font
->
face
;
if
(
unlikely
(
!
hb_coretext_shaper_face_data_ensure
(
face
)))
return
NULL
;
hb_coretext_shaper_face_data_t
*
face_data
=
HB_SHAPER_DATA_GET
(
face
);
return
face_data
->
ct_font
;
}
...
...
@@ -504,9 +499,8 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
{
hb_face_t
*
face
=
font
->
face
;
hb_coretext_shaper_face_data_t
*
face_data
=
HB_SHAPER_DATA_GET
(
face
);
hb_coretext_shaper_font_data_t
*
font_data
=
HB_SHAPER_DATA_GET
(
font
);
CGFloat
ct_font_size
=
CTFontGetSize
(
f
ont
_data
->
ct_font
);
CGFloat
ct_font_size
=
CTFontGetSize
(
f
ace
_data
->
ct_font
);
CGFloat
x_mult
=
(
CGFloat
)
font
->
x_scale
/
ct_font_size
;
CGFloat
y_mult
=
(
CGFloat
)
font
->
y_scale
/
ct_font_size
;
...
...
@@ -640,7 +634,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
CTFontDescriptorRef
font_desc
=
CTFontDescriptorCreateWithAttributes
(
attributes
);
CFRelease
(
attributes
);
range
->
font
=
CTFontCreateCopyWithAttributes
(
f
ont
_data
->
ct_font
,
0.0
,
NULL
,
font_desc
);
range
->
font
=
CTFontCreateCopyWithAttributes
(
f
ace
_data
->
ct_font
,
0.0
,
NULL
,
font_desc
);
CFRelease
(
font_desc
);
}
else
...
...
@@ -797,7 +791,7 @@ resize_and_retry:
CFRelease
(
lang
);
}
CFAttributedStringSetAttribute
(
attr_string
,
CFRangeMake
(
0
,
chars_len
),
kCTFontAttributeName
,
f
ont
_data
->
ct_font
);
kCTFontAttributeName
,
f
ace
_data
->
ct_font
);
if
(
num_features
)
{
...
...
@@ -890,7 +884,7 @@ resize_and_retry:
*/
CFDictionaryRef
attributes
=
CTRunGetAttributes
(
run
);
CTFontRef
run_ct_font
=
static_cast
<
CTFontRef
>
(
CFDictionaryGetValue
(
attributes
,
kCTFontAttributeName
));
if
(
!
CFEqual
(
run_ct_font
,
f
ont
_data
->
ct_font
))
if
(
!
CFEqual
(
run_ct_font
,
f
ace
_data
->
ct_font
))
{
/* The run doesn't use our main font instance. We have to figure out
* whether font fallback happened, or this is just CoreText giving us
...
...
@@ -936,7 +930,7 @@ resize_and_retry:
}
if
(
!
matched
)
{
CFStringRef
font_ps_name
=
CTFontCopyName
(
f
ont
_data
->
ct_font
,
kCTFontPostScriptNameKey
);
CFStringRef
font_ps_name
=
CTFontCopyName
(
f
ace
_data
->
ct_font
,
kCTFontPostScriptNameKey
);
CFStringRef
run_ps_name
=
CTFontCopyName
(
run_ct_font
,
kCTFontPostScriptNameKey
);
CFComparisonResult
result
=
CFStringCompare
(
run_ps_name
,
font_ps_name
,
0
);
CFRelease
(
run_ps_name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录