Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
70ae332f
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看板
提交
70ae332f
编写于
5月 22, 2010
作者:
M
Martin Hosken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add fontconfig to hbtestfont
上级
72631c9d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
88 addition
and
26 deletion
+88
-26
contrib/python/lib/fontconfig.pyx
contrib/python/lib/fontconfig.pyx
+47
-0
contrib/python/scripts/hbtestfont
contrib/python/scripts/hbtestfont
+39
-25
contrib/python/setup.py
contrib/python/setup.py
+2
-1
未找到文件。
contrib/python/lib/fontconfig.pyx
0 → 100644
浏览文件 @
70ae332f
cdef
extern
from
"fontconfig/fontconfig.h"
:
ctypedef
struct
FcPattern
:
pass
ctypedef
struct
FcConfig
:
pass
cdef
enum
FcResult
'_FcResult'
:
FcResultMatch
=
0
,
FcResultNoMatch
,
FcResultTypeMismatch
,
FcResultNoId
,
FcResultOutOfMemory
ctypedef
char
FcChar8
FcPattern
*
FcNameParse
(
FcChar8
*
name
)
FcPattern
*
FcFontMatch
(
FcConfig
*
config
,
FcPattern
*
match
,
FcResult
*
res
)
FcResult
FcPatternGetInteger
(
FcPattern
*
pattern
,
char
*
typeid
,
int
index
,
int
*
res
)
FcResult
FcPatternGetString
(
FcPattern
*
pattern
,
char
*
typeid
,
int
index
,
FcChar8
**
res
)
void
FcPatternPrint
(
FcPattern
*
pattern
)
void
FcPatternDestroy
(
FcPattern
*
pattern
)
FcConfig
*
FcConfigGetCurrent
()
cdef
class
fcPattern
:
cdef
FcPattern
*
_pattern
def
__init__
(
self
,
char
*
name
)
:
cdef
FcPattern
*
temp
cdef
FcResult
res
temp
=
FcNameParse
(
<
FcChar8
*>
name
)
self
.
_pattern
=
FcFontMatch
(
FcConfigGetCurrent
(),
temp
,
&
res
)
if
res
!=
FcResultMatch
:
print
"Failed to match"
+
str
(
res
)
self
.
_pattern
=
<
FcPattern
*>
0
def
__destroy__
(
self
)
:
FcPatternDestroy
(
self
.
_pattern
)
def
getInteger
(
self
,
char
*
typeid
,
int
index
)
:
cdef
int
res
if
self
.
_pattern
==
<
FcPattern
*>
0
or
FcPatternGetInteger
(
self
.
_pattern
,
typeid
,
index
,
&
res
)
!=
FcResultMatch
:
return
None
return
res
def
getString
(
self
,
char
*
typeid
,
int
index
)
:
cdef
FcChar8
*
res
if
self
.
_pattern
==
<
FcPattern
*>
0
or
FcPatternGetString
(
self
.
_pattern
,
typeid
,
index
,
&
res
)
!=
FcResultMatch
:
return
None
return
<
char
*>
res
def
debugPrint
(
self
)
:
FcPatternPrint
(
self
.
_pattern
)
contrib/python/scripts/hbtestfont
浏览文件 @
70ae332f
#!/usr/bin/python
#!/usr/bin/python
import
harfbuzz
,
optparse
import
harfbuzz
,
optparse
from
fontconfig
import
fcPattern
try
:
try
:
import
gtk
import
gtk
import
gobject
import
gobject
...
@@ -9,16 +11,19 @@ try:
...
@@ -9,16 +11,19 @@ try:
except
:
except
:
raise
SystemExit
raise
SystemExit
import
pygtk
import
pygtk
if
gtk
.
pygtk_version
<
(
2
,
8
)
:
if
gtk
.
pygtk_version
<
(
2
,
8
)
:
print
"PyGtk 2.8 or later required"
print
"PyGtk 2.8 or later required"
raise
SystemExit
raise
SystemExit
class
GlyphsWindow
(
gtk
.
Widget
)
:
class
GlyphsWindow
(
gtk
.
Widget
)
:
def
__init__
(
self
,
fontname
,
size
,
glyphs
)
:
def
__init__
(
self
,
fontname
,
bold
,
italic
,
size
,
glyphs
)
:
gtk
.
Widget
.
__init__
(
self
)
gtk
.
Widget
.
__init__
(
self
)
self
.
fontname
=
fontname
self
.
fontname
=
fontname
self
.
size
=
size
self
.
size
=
size
self
.
glyphs
=
glyphs
self
.
glyphs
=
glyphs
self
.
bold
=
bold
self
.
italic
=
italic
def
do_realize
(
self
)
:
def
do_realize
(
self
)
:
self
.
set_flags
(
gtk
.
REALIZED
)
self
.
set_flags
(
gtk
.
REALIZED
)
...
@@ -40,7 +45,7 @@ class GlyphsWindow (gtk.Widget) :
...
@@ -40,7 +45,7 @@ class GlyphsWindow (gtk.Widget) :
def
do_expose_event
(
self
,
event
)
:
def
do_expose_event
(
self
,
event
)
:
cr
=
self
.
window
.
cairo_create
()
cr
=
self
.
window
.
cairo_create
()
cr
.
set_matrix
(
cairo
.
Matrix
(
1
,
0
,
0
,
1
,
0
,
2
*
self
.
size
))
cr
.
set_matrix
(
cairo
.
Matrix
(
1
,
0
,
0
,
1
,
0
,
2
*
self
.
size
))
cr
.
set_font_face
(
cairo
.
ToyFontFace
(
self
.
fontname
))
cr
.
set_font_face
(
cairo
.
ToyFontFace
(
self
.
fontname
,
cairo
.
FONT_SLANT_ITALIC
if
self
.
italic
else
cairo
.
FONT_SLANT_NORMAL
,
cairo
.
FONT_WEIGHT_BOLD
if
self
.
bold
else
cairo
.
FONT_WEIGHT_NORMAL
))
cr
.
set_font_size
(
self
.
size
)
cr
.
set_font_size
(
self
.
size
)
cr
.
show_glyphs
(
self
.
glyphs
)
# [(gid, originx, originy)]
cr
.
show_glyphs
(
self
.
glyphs
)
# [(gid, originx, originy)]
...
@@ -49,22 +54,31 @@ buffer = None
...
@@ -49,22 +54,31 @@ buffer = None
def
tracefn
(
ft
,
aType
,
index
)
:
def
tracefn
(
ft
,
aType
,
index
)
:
print
aType
+
"("
+
str
(
index
)
+
"): "
+
str
(
buffer
.
get_info
())
print
aType
+
"("
+
str
(
index
)
+
"): "
+
str
(
buffer
.
get_info
())
usage
=
'''usage: %prog [options]
fontfile "codepoints"
usage
=
'''usage: %prog [options]
codepoints
Generates output of glyphs and positions. Each entry is of the form:
Generates output of glyphs and positions. Each entry is of the form:
glyphid>cluster@(offsetx,offsety)+(advancex,advancey)
glyphid>cluster@(offsetx,offsety)+(advancex,advancey)
codepoints is a space separated list of hex values of Unicode codepoints'''
codepoints is a space separated list of hex values of Unicode codepoints'''
p
=
optparse
.
OptionParser
(
usage
=
usage
)
p
=
optparse
.
OptionParser
(
usage
=
usage
)
p
.
add_option
(
'-s'
,
'--size'
,
default
=
1
2
,
type
=
"int"
,
help
=
"point size"
)
p
.
add_option
(
'-s'
,
'--size'
,
default
=
3
2
,
type
=
"int"
,
help
=
"point size"
)
p
.
add_option
(
'-l'
,
'--lang'
,
help
=
"language code"
)
p
.
add_option
(
'-l'
,
'--lang'
,
help
=
"language code"
)
p
.
add_option
(
'-c'
,
'--script'
,
help
=
"script code"
)
p
.
add_option
(
'-c'
,
'--script'
,
help
=
"script code"
)
p
.
add_option
(
'-f'
,
'--feature'
,
action
=
'append'
,
help
=
"define a feature key=val"
)
p
.
add_option
(
'-F'
,
'--feature'
,
action
=
'append'
,
help
=
"define a feature key=val"
)
p
.
add_option
(
'-n'
,
'--fontname'
,
help
=
'Font to use to render glyphs'
)
p
.
add_option
(
'-f'
,
'--font'
,
help
=
'Font to use to render glyphs. My be a font file'
,
default
=
"verdana"
)
p
.
add_option
(
'-b'
,
'--bold'
,
help
=
'Choose bold fonts'
,
action
=
'store_true'
)
p
.
add_option
(
'-i'
,
'--italic'
,
help
=
'Choose italic fonts'
,
action
=
'store_true'
)
p
.
add_option
(
'-d'
,
'--debug'
,
action
=
'store_true'
,
help
=
"Output trace info"
)
p
.
add_option
(
'-d'
,
'--debug'
,
action
=
'store_true'
,
help
=
"Output trace info"
)
(
opts
,
args
)
=
p
.
parse_args
()
(
opts
,
args
)
=
p
.
parse_args
()
ft
=
harfbuzz
.
ft
(
args
[
0
],
opts
.
size
)
fpat
=
opts
.
font
+
":weight="
text
=
""
.
join
(
unichr
(
int
(
c
,
16
))
for
c
in
args
[
1
].
split
(
" "
))
fpat
+=
"bold"
if
opts
.
bold
else
"medium"
fpat
+=
"italic"
if
opts
.
italic
else
"roman"
pat
=
fcPattern
(
fpat
)
fname
=
pat
.
getString
(
"file"
,
0
)
family
=
pat
.
getString
(
"family"
,
0
)
print
"Processing: "
+
fname
ft
=
harfbuzz
.
ft
(
fname
,
opts
.
size
)
text
=
""
.
join
(
unichr
(
int
(
c
,
16
))
for
c
in
args
)
bytes
=
text
.
encode
(
'utf_8'
)
bytes
=
text
.
encode
(
'utf_8'
)
buffer
=
harfbuzz
.
buffer
(
bytes
,
len
(
text
))
buffer
=
harfbuzz
.
buffer
(
bytes
,
len
(
text
))
if
(
opts
.
lang
or
opts
.
script
)
:
buffer
.
set_scriptlang
(
opts
.
script
if
opts
.
script
else
""
,
opts
.
lang
if
opts
.
lang
else
""
)
if
(
opts
.
lang
or
opts
.
script
)
:
buffer
.
set_scriptlang
(
opts
.
script
if
opts
.
script
else
""
,
opts
.
lang
if
opts
.
lang
else
""
)
...
@@ -76,20 +90,20 @@ if opts.feature :
...
@@ -76,20 +90,20 @@ if opts.feature :
ft
.
shape
(
buffer
,
features
=
features
)
ft
.
shape
(
buffer
,
features
=
features
)
res
=
buffer
.
get_info
(
64
)
# scale for 26.6
res
=
buffer
.
get_info
(
64
)
# scale for 26.6
print
res
print
res
if
opts
.
fontname
:
glyphs
=
[]
glyphs
=
[]
org
=
[
0
,
0
]
org
=
[
0
,
0
]
for
g
in
res
:
for
g
in
res
:
glyphs
.
append
((
g
.
gid
,
org
[
0
]
+
g
.
offset
[
0
],
org
[
1
]
+
g
.
offset
[
1
]))
glyphs
.
append
((
g
.
gid
,
org
[
0
]
+
g
.
offset
[
0
],
org
[
1
]
+
g
.
offset
[
1
]))
org
[
0
]
+=
g
.
advance
[
0
]
org
[
0
]
+=
g
.
advance
[
0
]
org
[
1
]
+=
g
.
advance
[
1
]
org
[
1
]
+=
g
.
advance
[
1
]
gobject
.
type_register
(
GlyphsWindow
)
gobject
.
type_register
(
GlyphsWindow
)
win
=
gtk
.
Window
()
win
=
gtk
.
Window
()
win
.
resize
(
org
[
0
]
+
10
,
3
*
opts
.
size
+
40
)
win
.
resize
(
org
[
0
]
+
10
,
3
*
opts
.
size
+
40
)
win
.
connect
(
'delete-event'
,
gtk
.
main_quit
)
win
.
connect
(
'delete-event'
,
gtk
.
main_quit
)
frame
=
gtk
.
Frame
(
"glyphs"
)
frame
=
gtk
.
Frame
(
"glyphs"
)
win
.
add
(
frame
)
win
.
add
(
frame
)
w
=
GlyphsWindow
(
opts
.
fontname
,
opts
.
size
,
glyphs
)
w
=
GlyphsWindow
(
family
,
opts
.
bold
,
opts
.
italic
,
opts
.
size
,
glyphs
)
frame
.
add
(
w
)
frame
.
add
(
w
)
win
.
show_all
()
win
.
show_all
()
gtk
.
main
()
gtk
.
main
()
contrib/python/setup.py
浏览文件 @
70ae332f
...
@@ -13,7 +13,8 @@ setup(name='harfbuzz',
...
@@ -13,7 +13,8 @@ setup(name='harfbuzz',
maintainer_email
=
'martin_hosken@sil.org'
,
maintainer_email
=
'martin_hosken@sil.org'
,
packages
=
[
'harfbuzz'
],
packages
=
[
'harfbuzz'
],
ext_modules
=
[
ext_modules
=
[
Extension
(
"harfbuzz"
,
[
"lib/harfbuzz.pyx"
],
libraries
=
[
"harfbuzz"
],
library_dirs
=
[
"../../src/.libs"
],
include_dirs
=
[
"/usr/include/freetype2"
,
"../../src"
])
Extension
(
"harfbuzz"
,
[
"lib/harfbuzz.pyx"
],
libraries
=
[
"harfbuzz"
],
library_dirs
=
[
"../../src/.libs"
],
include_dirs
=
[
"/usr/include/freetype2"
,
"../../src"
]),
Extension
(
"fontconfig"
,
[
"lib/fontconfig.pyx"
],
libraries
=
[
"fontconfig"
])
],
],
cmdclass
=
{
'build_ext'
:
build_ext
},
cmdclass
=
{
'build_ext'
:
build_ext
},
scripts
=
glob
(
'scripts/*'
),
scripts
=
glob
(
'scripts/*'
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录