Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
892eb2e4
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看板
提交
892eb2e4
编写于
8月 06, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[uniscribe] Make font selection work
Not tested yet.
上级
b492299e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
8 deletion
+60
-8
src/hb-ot-name-private.hh
src/hb-ot-name-private.hh
+37
-0
src/hb-uniscribe-shape.cc
src/hb-uniscribe-shape.cc
+23
-7
src/test.cc
src/test.cc
+0
-1
未找到文件。
src/hb-ot-name-private.hh
浏览文件 @
892eb2e4
...
@@ -39,6 +39,20 @@
...
@@ -39,6 +39,20 @@
struct
NameRecord
struct
NameRecord
{
{
static
int
cmp
(
const
NameRecord
*
a
,
const
NameRecord
*
b
)
{
int
ret
;
ret
=
b
->
platformID
.
cmp
(
a
->
platformID
);
if
(
ret
)
return
ret
;
ret
=
b
->
encodingID
.
cmp
(
a
->
encodingID
);
if
(
ret
)
return
ret
;
ret
=
b
->
languageID
.
cmp
(
a
->
languageID
);
if
(
ret
)
return
ret
;
ret
=
b
->
nameID
.
cmp
(
a
->
nameID
);
if
(
ret
)
return
ret
;
return
0
;
}
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
,
void
*
base
)
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
,
void
*
base
)
{
TRACE_SANITIZE
();
TRACE_SANITIZE
();
/* We can check from base all the way up to the end of string... */
/* We can check from base all the way up to the end of string... */
...
@@ -60,6 +74,28 @@ struct name
...
@@ -60,6 +74,28 @@ struct name
{
{
static
const
hb_tag_t
Tag
=
HB_OT_TAG_name
;
static
const
hb_tag_t
Tag
=
HB_OT_TAG_name
;
inline
unsigned
int
get_name
(
unsigned
int
platform_id
,
unsigned
int
encoding_id
,
unsigned
int
language_id
,
unsigned
int
name_id
,
void
*
buffer
,
unsigned
int
buffer_length
)
const
{
NameRecord
key
;
key
.
platformID
.
set
(
platform_id
);
key
.
encodingID
.
set
(
encoding_id
);
key
.
languageID
.
set
(
language_id
);
key
.
nameID
.
set
(
name_id
);
NameRecord
*
match
=
(
NameRecord
*
)
bsearch
(
&
key
,
nameRecord
,
count
,
sizeof
(
nameRecord
[
0
]),
(
hb_compare_func_t
)
NameRecord
::
cmp
);
if
(
!
match
)
return
0
;
unsigned
int
length
=
MIN
(
buffer_length
,
(
unsigned
int
)
match
->
length
);
memcmp
(
buffer
,
(
this
+
stringOffset
)
+
match
->
offset
,
length
);
return
length
;
}
inline
bool
sanitize_records
(
hb_sanitize_context_t
*
c
)
{
inline
bool
sanitize_records
(
hb_sanitize_context_t
*
c
)
{
TRACE_SANITIZE
();
TRACE_SANITIZE
();
unsigned
int
_count
=
count
;
unsigned
int
_count
=
count
;
...
@@ -70,6 +106,7 @@ struct name
...
@@ -70,6 +106,7 @@ struct name
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
{
TRACE_SANITIZE
();
TRACE_SANITIZE
();
return
true
;
return
c
->
check_struct
(
this
)
&&
return
c
->
check_struct
(
this
)
&&
likely
(
format
==
0
||
format
==
1
)
&&
likely
(
format
==
0
||
format
==
1
)
&&
c
->
check_array
(
nameRecord
,
nameRecord
[
0
].
static_size
,
count
)
&&
c
->
check_array
(
nameRecord
,
nameRecord
[
0
].
static_size
,
count
)
&&
...
...
src/hb-uniscribe-shape.cc
浏览文件 @
892eb2e4
...
@@ -58,19 +58,33 @@ DWORD GetFontData(
...
@@ -58,19 +58,33 @@ DWORD GetFontData(
);
);
*/
*/
static
void
static
bool
populate_log_font
(
LOGFONTW
*
lf
,
populate_log_font
(
LOGFONTW
*
lf
,
HDC
hdc
,
HDC
hdc
,
hb_font_t
*
font
,
hb_font_t
*
font
)
hb_blob_t
*
blob
)
{
{
memset
(
lf
,
0
,
sizeof
(
*
lf
));
memset
(
lf
,
0
,
sizeof
(
*
lf
));
int
dpi
=
GetDeviceCaps
(
hdc
,
LOGPIXELSY
);
int
dpi
=
GetDeviceCaps
(
hdc
,
LOGPIXELSY
);
lf
->
lfHeight
=
MulDiv
(
font
->
x_scale
,
dpi
,
72
);
lf
->
lfHeight
=
MulDiv
(
font
->
x_scale
,
dpi
,
72
);
WCHAR
family_name
[]
=
{
'n'
,
'a'
,
'z'
,
'l'
,
'i'
};
hb_blob_t
*
blob
=
Sanitizer
<
name
>::
sanitize
(
hb_face_reference_table
(
font
->
face
,
HB_TAG
(
'n'
,
'a'
,
'm'
,
'e'
)));
for
(
unsigned
int
i
=
0
;
family_name
[
i
]
&&
i
<
LF_FACESIZE
-
1
;
i
++
)
const
name
*
name_table
=
Sanitizer
<
name
>::
lock_instance
(
blob
);
lf
->
lfFaceName
[
i
]
=
family_name
[
i
];
unsigned
int
len
=
name_table
->
get_name
(
3
,
1
,
0x409
,
4
,
lf
->
lfFaceName
,
sizeof
(
lf
->
lfFaceName
[
0
])
*
LF_FACESIZE
)
/
sizeof
(
lf
->
lfFaceName
[
0
]);
if
(
unlikely
(
!
len
))
{
DEBUG_MSG
(
UNISCRIBE
,
NULL
,
"Didn't find English name table entry"
);
return
FALSE
;
}
if
(
unlikely
(
len
>=
LF_FACESIZE
))
{
DEBUG_MSG
(
UNISCRIBE
,
NULL
,
"Font name too long"
);
return
FALSE
;
}
for
(
unsigned
int
i
=
0
;
i
<
len
;
i
++
)
lf
->
lfFaceName
[
i
]
=
hb_be_uint16
(
lf
->
lfFaceName
[
i
]);
lf
->
lfFaceName
[
len
]
=
0
;
return
TRUE
;
}
}
hb_bool_t
hb_bool_t
...
@@ -179,6 +193,7 @@ retry:
...
@@ -179,6 +193,7 @@ retry:
DWORD
num_fonts_installed
;
DWORD
num_fonts_installed
;
HANDLE
fh
=
AddFontMemResourceEx
((
void
*
)
blob_data
,
blob_length
,
0
,
&
num_fonts_installed
);
HANDLE
fh
=
AddFontMemResourceEx
((
void
*
)
blob_data
,
blob_length
,
0
,
&
num_fonts_installed
);
hb_blob_destroy
(
blob
);
if
(
unlikely
(
!
fh
))
if
(
unlikely
(
!
fh
))
FAIL
(
"AddFontMemResourceEx() failed"
);
FAIL
(
"AddFontMemResourceEx() failed"
);
...
@@ -187,7 +202,8 @@ retry:
...
@@ -187,7 +202,8 @@ retry:
HDC
hdc
=
GetDC
(
NULL
);
/* XXX The DC should be cached on the face I guess? */
HDC
hdc
=
GetDC
(
NULL
);
/* XXX The DC should be cached on the face I guess? */
LOGFONTW
log_font
;
LOGFONTW
log_font
;
populate_log_font
(
&
log_font
,
hdc
,
font
,
blob
);
if
(
unlikely
(
!
populate_log_font
(
&
log_font
,
hdc
,
font
)))
FAIL
(
"populate_log_font() failed"
);
HFONT
hfont
=
CreateFontIndirectW
(
&
log_font
);
HFONT
hfont
=
CreateFontIndirectW
(
&
log_font
);
SelectObject
(
hdc
,
hfont
);
SelectObject
(
hdc
,
hfont
);
...
...
src/test.cc
浏览文件 @
892eb2e4
...
@@ -38,7 +38,6 @@
...
@@ -38,7 +38,6 @@
#include <stdio.h>
#include <stdio.h>
int
int
main
(
int
argc
,
char
**
argv
)
main
(
int
argc
,
char
**
argv
)
{
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录