Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
e5611228
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看板
提交
e5611228
编写于
2月 22, 2016
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[coretext] Move code around
上级
04c64431
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
47 deletion
+62
-47
src/hb-coretext.cc
src/hb-coretext.cc
+62
-47
未找到文件。
src/hb-coretext.cc
浏览文件 @
e5611228
...
...
@@ -27,7 +27,6 @@
*/
#define HB_SHAPER coretext
#define hb_coretext_shaper_face_data_t CGFont
#include "hb-shaper-impl-private.hh"
#include "hb-coretext.h"
...
...
@@ -78,6 +77,49 @@ HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font)
* shaper face data
*/
static
CTFontRef
create_ct_font
(
CGFontRef
cg_font
,
CGFloat
font_size
)
{
CTFontRef
ct_font
=
CTFontCreateWithGraphicsFont
(
cg_font
,
font_size
,
NULL
,
NULL
);
if
(
unlikely
(
!
ct_font
))
{
DEBUG_MSG
(
CORETEXT
,
cg_font
,
"Font CTFontCreateWithGraphicsFont() failed"
);
return
NULL
;
}
/* Create font copy with cascade list that has LastResort first; this speeds up CoreText
* font fallback which we don't need anyway. */
{
// TODO Handle allocation failures?
CTFontDescriptorRef
last_resort
=
CTFontDescriptorCreateWithNameAndSize
(
CFSTR
(
"LastResort"
),
0
);
CFArrayRef
cascade_list
=
CFArrayCreate
(
kCFAllocatorDefault
,
(
const
void
**
)
&
last_resort
,
1
,
&
kCFTypeArrayCallBacks
);
CFRelease
(
last_resort
);
CFDictionaryRef
attributes
=
CFDictionaryCreate
(
kCFAllocatorDefault
,
(
const
void
**
)
&
kCTFontCascadeListAttribute
,
(
const
void
**
)
&
cascade_list
,
1
,
&
kCFTypeDictionaryKeyCallBacks
,
&
kCFTypeDictionaryValueCallBacks
);
CFRelease
(
cascade_list
);
CTFontDescriptorRef
new_font_desc
=
CTFontDescriptorCreateWithAttributes
(
attributes
);
CFRelease
(
attributes
);
CTFontRef
new_ct_font
=
CTFontCreateCopyWithAttributes
(
ct_font
,
0.0
,
NULL
,
new_font_desc
);
if
(
new_ct_font
)
{
CFRelease
(
ct_font
);
ct_font
=
new_ct_font
;
}
else
DEBUG_MSG
(
CORETEXT
,
ct_font
,
"Font copy with empty cascade list failed"
);
}
return
ct_font
;
}
static
void
release_data
(
void
*
info
,
const
void
*
data
,
size_t
size
)
{
...
...
@@ -87,14 +129,20 @@ release_data (void *info, const void *data, size_t size)
hb_blob_destroy
((
hb_blob_t
*
)
info
);
}
struct
hb_coretext_shaper_face_data_t
{
CGFontRef
cg_font
;
};
hb_coretext_shaper_face_data_t
*
_hb_coretext_shaper_face_data_create
(
hb_face_t
*
face
)
{
hb_coretext_shaper_face_data_t
*
data
=
NULL
;
hb_coretext_shaper_face_data_t
*
data
=
(
hb_coretext_shaper_face_data_t
*
)
calloc
(
1
,
sizeof
(
hb_coretext_shaper_face_data_t
));
if
(
unlikely
(
!
data
))
return
NULL
;
if
(
face
->
destroy
==
(
hb_destroy_func_t
)
CGFontRelease
)
{
data
=
CGFontRetain
((
CGFontRef
)
face
->
user_data
);
data
->
cg_font
=
CGFontRetain
((
CGFontRef
)
face
->
user_data
);
}
else
{
...
...
@@ -107,13 +155,15 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
CGDataProviderRef
provider
=
CGDataProviderCreateWithData
(
blob
,
blob_data
,
blob_length
,
&
release_data
);
if
(
likely
(
provider
))
{
data
=
CGFontCreateWithDataProvider
(
provider
);
data
->
cg_font
=
CGFontCreateWithDataProvider
(
provider
);
CGDataProviderRelease
(
provider
);
}
}
if
(
unlikely
(
!
data
))
{
if
(
unlikely
(
!
data
->
cg_font
))
{
DEBUG_MSG
(
CORETEXT
,
face
,
"Face CGFontCreateWithDataProvider() failed"
);
free
(
data
);
return
NULL
;
}
return
data
;
...
...
@@ -122,7 +172,8 @@ _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
);
CFRelease
(
data
->
cg_font
);
free
(
data
);
}
/*
...
...
@@ -133,7 +184,7 @@ hb_coretext_face_get_cg_font (hb_face_t *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
;
return
face_data
->
cg_font
;
}
...
...
@@ -160,46 +211,10 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
/* 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
=
CTFontCreateWithGraphicsFont
(
face_data
,
36.
,
NULL
,
NULL
);
if
(
unlikely
(
!
data
->
ct_font
))
{
DEBUG_MSG
(
CORETEXT
,
font
,
"Font CTFontCreateWithGraphicsFont() failed"
);
free
(
data
);
return
NULL
;
}
/* Create font copy with cascade list that has LastResort first; this speeds up CoreText
* font fallback which we don't need anyway. */
data
->
ct_font
=
create_ct_font
(
face_data
->
cg_font
,
36.
);
if
(
unlikely
(
!
data
->
ct_font
))
{
// TODO Handle allocation failures?
CTFontDescriptorRef
last_resort
=
CTFontDescriptorCreateWithNameAndSize
(
CFSTR
(
"LastResort"
),
0
);
CFArrayRef
cascade_list
=
CFArrayCreate
(
kCFAllocatorDefault
,
(
const
void
**
)
&
last_resort
,
1
,
&
kCFTypeArrayCallBacks
);
CFRelease
(
last_resort
);
CFDictionaryRef
attributes
=
CFDictionaryCreate
(
kCFAllocatorDefault
,
(
const
void
**
)
&
kCTFontCascadeListAttribute
,
(
const
void
**
)
&
cascade_list
,
1
,
&
kCFTypeDictionaryKeyCallBacks
,
&
kCFTypeDictionaryValueCallBacks
);
CFRelease
(
cascade_list
);
CTFontDescriptorRef
new_font_desc
=
CTFontDescriptorCreateWithAttributes
(
attributes
);
CFRelease
(
attributes
);
CTFontRef
new_ct_font
=
CTFontCreateCopyWithAttributes
(
data
->
ct_font
,
0.0
,
NULL
,
new_font_desc
);
if
(
new_ct_font
)
{
CFRelease
(
data
->
ct_font
);
data
->
ct_font
=
new_ct_font
;
}
else
DEBUG_MSG
(
CORETEXT
,
font
,
"Font copy with empty cascade list failed"
);
}
if
(
unlikely
(
!
data
->
ct_font
))
{
DEBUG_MSG
(
CORETEXT
,
font
,
"Font CTFontCreateWithGraphicsFont() failed"
);
DEBUG_MSG
(
CORETEXT
,
font
,
"CTFont creation failed"
);
free
(
data
);
return
NULL
;
}
...
...
@@ -898,7 +913,7 @@ resize_and_retry:
CGFontRef
run_cg_font
=
CTFontCopyGraphicsFont
(
run_ct_font
,
0
);
if
(
run_cg_font
)
{
matched
=
CFEqual
(
run_cg_font
,
face_data
);
matched
=
CFEqual
(
run_cg_font
,
face_data
->
cg_font
);
CFRelease
(
run_cg_font
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录