Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
301168da
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看板
提交
301168da
编写于
7月 30, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CoreText] Port to shape_plan infrastructure
上级
6cdfd14b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
81 deletion
+80
-81
src/hb-coretext.cc
src/hb-coretext.cc
+80
-81
未找到文件。
src/hb-coretext.cc
浏览文件 @
301168da
/*
/*
* Copyright © 2012 Mozilla Foundation.
* Copyright © 2012 Mozilla Foundation.
* Copyright © 2012 Google, Inc.
*
*
* This is part of HarfBuzz, a text shaping library.
* This is part of HarfBuzz, a text shaping library.
*
*
...
@@ -22,10 +23,11 @@
...
@@ -22,10 +23,11 @@
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*
* Mozilla Author(s): Jonathan Kew
* Mozilla Author(s): Jonathan Kew
* Google Author(s): Behdad Esfahbod
*/
*/
#define HB_SHAPER coretext
#define HB_SHAPER coretext
#include "hb-shaper-private.hh"
#include "hb-shaper-
impl-
private.hh"
#define GlyphID GlyphID_mac
#define GlyphID GlyphID_mac
#include <ApplicationServices/ApplicationServices.h>
#include <ApplicationServices/ApplicationServices.h>
...
@@ -33,28 +35,23 @@
...
@@ -33,28 +35,23 @@
#include "hb-coretext.h"
#include "hb-coretext.h"
#include "hb-font-private.hh"
#include "hb-buffer-private.hh"
#ifndef HB_DEBUG_CORETEXT
#ifndef HB_DEBUG_CORETEXT
#define HB_DEBUG_CORETEXT (HB_DEBUG+0)
#define HB_DEBUG_CORETEXT (HB_DEBUG+0)
#endif
#endif
static
hb_user_data_key_t
hb_coretext_data_key
;
HB_SHAPER_DATA_ENSURE_DECLARE
(
coretext
,
face
)
HB_SHAPER_DATA_ENSURE_DECLARE
(
coretext
,
font
)
static
struct
hb_coretext_face_data_t
{
CGFontRef
cg_font
;
}
_hb_coretext_face_data_nil
=
{
0
};
static
void
/*
_hb_coretext_face_data_destroy
(
hb_coretext_face_data_t
*
data
)
* shaper face data
{
*/
if
(
data
->
cg_font
)
CFRelease
(
data
->
cg_font
);
struct
hb_coretext_shaper_face_data_t
{
free
(
data
)
;
CGFontRef
cg_font
;
}
}
;
static
void
static
void
release_data
(
void
*
info
,
const
void
*
data
,
size_t
size
)
release_data
(
void
*
info
,
const
void
*
data
,
size_t
size
)
...
@@ -65,16 +62,12 @@ release_data (void *info, const void *data, size_t size)
...
@@ -65,16 +62,12 @@ release_data (void *info, const void *data, size_t size)
hb_blob_destroy
((
hb_blob_t
*
)
info
);
hb_blob_destroy
((
hb_blob_t
*
)
info
);
}
}
static
hb_coretext
_face_data_t
*
hb_coretext_shaper
_face_data_t
*
_hb_coretext_
face_get_data
(
hb_face_t
*
face
)
_hb_coretext_
shaper_face_data_create
(
hb_face_t
*
face
)
{
{
hb_coretext_face_data_t
*
data
=
(
hb_coretext_face_data_t
*
)
hb_face_get_user_data
(
face
,
&
hb_coretext_data_key
);
hb_coretext_shaper_face_data_t
*
data
=
(
hb_coretext_shaper_face_data_t
*
)
calloc
(
1
,
sizeof
(
hb_coretext_shaper_face_data_t
));
if
(
likely
(
data
))
return
data
;
data
=
(
hb_coretext_face_data_t
*
)
calloc
(
1
,
sizeof
(
hb_coretext_face_data_t
));
if
(
unlikely
(
!
data
))
if
(
unlikely
(
!
data
))
return
&
_hb_coretext_face_data_nil
;
return
NULL
;
hb_blob_t
*
blob
=
hb_face_reference_blob
(
face
);
hb_blob_t
*
blob
=
hb_face_reference_blob
(
face
);
unsigned
int
blob_length
;
unsigned
int
blob_length
;
...
@@ -86,86 +79,103 @@ _hb_coretext_face_get_data (hb_face_t *face)
...
@@ -86,86 +79,103 @@ _hb_coretext_face_get_data (hb_face_t *face)
data
->
cg_font
=
CGFontCreateWithDataProvider
(
provider
);
data
->
cg_font
=
CGFontCreateWithDataProvider
(
provider
);
CGDataProviderRelease
(
provider
);
CGDataProviderRelease
(
provider
);
if
(
unlikely
(
!
data
->
cg_font
))
if
(
unlikely
(
!
data
->
cg_font
))
{
DEBUG_MSG
(
CORETEXT
,
face
,
"Face CGFontCreateWithDataProvider() failed"
);
DEBUG_MSG
(
CORETEXT
,
face
,
"Face CGFontCreateWithDataProvider() failed"
);
free
(
data
);
return
NULL
;
if
(
unlikely
(
!
hb_face_set_user_data
(
face
,
&
hb_coretext_data_key
,
data
,
(
hb_destroy_func_t
)
_hb_coretext_face_data_destroy
,
false
)))
{
_hb_coretext_face_data_destroy
(
data
);
data
=
(
hb_coretext_face_data_t
*
)
hb_face_get_user_data
(
face
,
&
hb_coretext_data_key
);
if
(
data
)
return
data
;
else
return
&
_hb_coretext_face_data_nil
;
}
}
return
data
;
return
data
;
}
}
void
static
struct
hb_coretext_font_data_t
{
_hb_coretext_shaper_face_data_destroy
(
hb_coretext_shaper_face_data_t
*
data
)
CTFontRef
ct_font
;
}
_hb_coretext_font_data_nil
=
{
0
};
static
void
_hb_coretext_font_data_destroy
(
hb_coretext_font_data_t
*
data
)
{
{
if
(
data
->
ct_font
)
CFRelease
(
data
->
cg_font
);
CFRelease
(
data
->
ct_font
);
free
(
data
);
free
(
data
);
}
}
static
hb_coretext_font_data_t
*
_hb_coretext_font_get_data
(
hb_font_t
*
font
)
/*
* shaper font data
*/
struct
hb_coretext_shaper_font_data_t
{
CTFontRef
ct_font
;
};
hb_coretext_shaper_font_data_t
*
_hb_coretext_shaper_font_data_create
(
hb_font_t
*
font
)
{
{
hb_coretext_font_data_t
*
data
=
(
hb_coretext_font_data_t
*
)
hb_font_get_user_data
(
font
,
&
hb_coretext_data_key
);
if
(
unlikely
(
!
hb_coretext_shaper_face_data_ensure
(
font
->
face
)))
return
NULL
;
if
(
likely
(
data
))
return
data
;
data
=
(
hb_coretext_font_data_t
*
)
calloc
(
1
,
sizeof
(
hb_coretext
_font_data_t
));
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
))
if
(
unlikely
(
!
data
))
return
&
_hb_coretext_font_data_nil
;
return
NULL
;
hb_coretext_face_data_t
*
face_data
=
_hb_coretext_face_get_data
(
font
->
face
);
hb_face_t
*
face
=
font
->
face
;
hb_coretext_shaper_face_data_t
*
face_data
=
HB_SHAPER_DATA_GET
(
face
);
data
->
ct_font
=
CTFontCreateWithGraphicsFont
(
face_data
->
cg_font
,
font
->
y_scale
,
NULL
,
NULL
);
data
->
ct_font
=
CTFontCreateWithGraphicsFont
(
face_data
->
cg_font
,
font
->
y_scale
,
NULL
,
NULL
);
if
(
unlikely
(
!
data
->
ct_font
))
if
(
unlikely
(
!
data
->
ct_font
))
{
DEBUG_MSG
(
CORETEXT
,
font
,
"Font CTFontCreateWithGraphicsFont() failed"
);
DEBUG_MSG
(
CORETEXT
,
font
,
"Font CTFontCreateWithGraphicsFont() failed"
);
free
(
data
);
if
(
unlikely
(
!
hb_font_set_user_data
(
font
,
&
hb_coretext_data_key
,
data
,
return
NULL
;
(
hb_destroy_func_t
)
_hb_coretext_font_data_destroy
,
false
)))
{
_hb_coretext_font_data_destroy
(
data
);
data
=
(
hb_coretext_font_data_t
*
)
hb_font_get_user_data
(
font
,
&
hb_coretext_data_key
);
if
(
data
)
return
data
;
else
return
&
_hb_coretext_font_data_nil
;
}
}
return
data
;
return
data
;
}
}
void
_hb_coretext_shaper_font_data_destroy
(
hb_coretext_shaper_font_data_t
*
data
)
{
CFRelease
(
data
->
ct_font
);
free
(
data
);
}
/*
* shaper shape_plan data
*/
struct
hb_coretext_shaper_shape_plan_data_t
{};
hb_coretext_shaper_shape_plan_data_t
*
_hb_coretext_shaper_shape_plan_data_create
(
hb_shape_plan_t
*
shape_plan
,
const
hb_feature_t
*
user_features
,
unsigned
int
num_user_features
)
{
return
(
hb_coretext_shaper_shape_plan_data_t
*
)
HB_SHAPER_DATA_SUCCEEDED
;
}
void
_hb_coretext_shaper_shape_plan_data_destroy
(
hb_coretext_shaper_shape_plan_data_t
*
data
)
{
}
/*
* shaper
*/
CTFontRef
CTFontRef
hb_coretext_font_get_ct_font
(
hb_font_t
*
font
)
hb_coretext_font_get_ct_font
(
hb_font_t
*
font
)
{
{
hb_coretext_font_data_t
*
font_data
=
_hb_coretext_font_get_data
(
font
);
if
(
unlikely
(
!
hb_coretext_shaper_font_data_ensure
(
font
)))
return
0
;
if
(
unlikely
(
!
font_data
))
hb_coretext_shaper_font_data_t
*
font_data
=
HB_SHAPER_DATA_GET
(
font
);
return
0
;
return
font_data
->
ct_font
;
return
font_data
->
ct_font
;
}
}
hb_bool_t
hb_bool_t
_hb_coretext_shape
(
hb_font_t
*
font
,
_hb_coretext_shape
(
hb_shape_plan_t
*
shape_plan
,
hb_font_t
*
font
,
hb_buffer_t
*
buffer
,
hb_buffer_t
*
buffer
,
const
hb_feature_t
*
features
,
const
hb_feature_t
*
features
,
unsigned
int
num_features
)
unsigned
int
num_features
)
{
{
buffer
->
guess_properties
();
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
);
#define FAIL(...) \
#define FAIL(...) \
HB_STMT_START { \
HB_STMT_START { \
...
@@ -173,17 +183,6 @@ _hb_coretext_shape (hb_font_t *font,
...
@@ -173,17 +183,6 @@ _hb_coretext_shape (hb_font_t *font,
return false; \
return false; \
} HB_STMT_END;
} HB_STMT_END;
hb_coretext_face_data_t
*
face_data
=
_hb_coretext_face_get_data
(
font
->
face
);
if
(
unlikely
(
!
face_data
->
cg_font
))
FAIL
(
"Couldn't get face data"
);
hb_coretext_font_data_t
*
font_data
=
_hb_coretext_font_get_data
(
font
);
if
(
unlikely
(
!
font_data
->
ct_font
))
FAIL
(
"Couldn't get font font"
);
if
(
unlikely
(
!
buffer
->
len
))
return
true
;
unsigned
int
scratch_size
;
unsigned
int
scratch_size
;
char
*
scratch
=
(
char
*
)
buffer
->
get_scratch_buffer
(
&
scratch_size
);
char
*
scratch
=
(
char
*
)
buffer
->
get_scratch_buffer
(
&
scratch_size
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录