Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
4451168e
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看板
提交
4451168e
编写于
9月 16, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix binary stdin/stdout io in Windows
Make --font-file accept "-" to mean stdin, and have it work in Windows too!
上级
639b5957
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
14 deletion
+67
-14
configure.ac
configure.ac
+1
-1
util/common.hh
util/common.hh
+5
-0
util/options.cc
util/options.cc
+53
-11
util/options.hh
util/options.hh
+8
-2
未找到文件。
configure.ac
浏览文件 @
4451168e
...
...
@@ -53,7 +53,7 @@ GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
# Functions and headers
AC_CHECK_FUNCS(mprotect sysconf getpagesize mmap)
AC_CHECK_HEADERS(unistd.h sys/mman.h)
AC_CHECK_HEADERS(unistd.h sys/mman.h
io.h
)
# Compiler flags
AC_CANONICAL_HOST
...
...
util/common.hh
浏览文件 @
4451168e
...
...
@@ -40,6 +40,11 @@
#include <math.h>
#include <locale.h>
#include <errno.h>
#include <fcntl.h>
#if HAVE_IO_H
#include <io.h>
/* for _setmode() under Windows */
#endif
#include <hb.h>
#include <glib.h>
...
...
util/options.cc
浏览文件 @
4451168e
...
...
@@ -424,23 +424,66 @@ font_options_t::get_font (void) const
/* Create the blob */
{
c
onst
c
har
*
font_data
;
unsigned
int
len
;
char
*
font_data
;
unsigned
int
len
=
0
;
hb_destroy_func_t
destroy
;
void
*
user_data
;
hb_memory_mode_t
mm
;
/* This is a hell of a lot of code for just reading a file! */
if
(
!
font_file
)
fail
(
TRUE
,
"No font file set"
);
GMappedFile
*
mf
=
g_mapped_file_new
(
font_file
,
FALSE
,
NULL
);
if
(
!
mf
)
fail
(
FALSE
,
"Failed opening font file `%s'"
,
g_filename_display_name
(
font_file
));
font_data
=
g_mapped_file_get_contents
(
mf
);
len
=
g_mapped_file_get_length
(
mf
);
destroy
=
(
hb_destroy_func_t
)
g_mapped_file_unref
;
user_data
=
(
void
*
)
mf
;
mm
=
HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE
;
if
(
0
==
strcmp
(
font_file
,
"-"
))
{
/* read it */
GString
*
gs
=
g_string_new
(
NULL
);
char
buf
[
BUFSIZ
];
#if HAVE_IO_H
_setmode
(
fileno
(
stdin
),
O_BINARY
);
#endif
while
(
!
feof
(
stdin
))
{
size_t
ret
=
fread
(
buf
,
1
,
sizeof
(
buf
),
stdin
);
if
(
ferror
(
stdin
))
fail
(
FALSE
,
"Failed reading font from standard input: %s"
,
strerror
(
errno
));
g_string_append_len
(
gs
,
buf
,
ret
);
}
len
=
gs
->
len
;
font_data
=
g_string_free
(
gs
,
FALSE
);
user_data
=
font_data
;
destroy
=
(
hb_destroy_func_t
)
g_free
;
mm
=
HB_MEMORY_MODE_WRITABLE
;
}
else
{
GMappedFile
*
mf
=
g_mapped_file_new
(
font_file
,
FALSE
,
NULL
);
if
(
mf
)
{
font_data
=
g_mapped_file_get_contents
(
mf
);
len
=
g_mapped_file_get_length
(
mf
);
if
(
len
)
{
destroy
=
(
hb_destroy_func_t
)
g_mapped_file_unref
;
user_data
=
(
void
*
)
mf
;
mm
=
HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE
;
}
else
g_mapped_file_unref
(
mf
);
}
if
(
!
len
)
{
/* GMappedFile is buggy, it doesn't fail if file isn't regular.
* Try reading.
* https://bugzilla.gnome.org/show_bug.cgi?id=659212 */
GError
*
error
=
NULL
;
gsize
l
;
if
(
g_file_get_contents
(
font_file
,
&
font_data
,
&
l
,
&
error
))
{
len
=
l
;
destroy
=
(
hb_destroy_func_t
)
g_free
;
user_data
=
(
void
*
)
font_data
;
mm
=
HB_MEMORY_MODE_WRITABLE
;
}
else
{
fail
(
FALSE
,
"Failed reading font file `%s': %s"
,
g_filename_display_name
(
font_file
),
error
->
message
);
//g_error_free (error);
}
}
}
blob
=
hb_blob_create
(
font_data
,
len
,
mm
,
user_data
,
destroy
);
}
...
...
@@ -476,7 +519,6 @@ text_options_t::get_line (unsigned int *len)
fail
(
FALSE
,
"Failed opening text file `%s'"
,
g_filename_display_name
(
text_file
));
text
=
g_mapped_file_get_contents
(
mf
);
text_len
=
g_mapped_file_get_length
(
mf
);
printf
(
"%d
\n
"
,
text_len
);
}
if
(
text_len
==
(
unsigned
int
)
-
1
)
...
...
util/options.hh
浏览文件 @
4451168e
...
...
@@ -208,7 +208,6 @@ struct text_options_t : option_group_t
mutable
unsigned
int
text_len
;
};
struct
output_options_t
:
option_group_t
{
output_options_t
(
option_parser_t
*
parser
)
{
...
...
@@ -243,7 +242,14 @@ struct output_options_t : option_group_t
if
(
fp
)
return
fp
;
fp
=
output_file
?
fopen
(
output_file
,
"wb"
)
:
stdout
;
if
(
output_file
)
fp
=
fopen
(
output_file
,
"wb"
);
else
{
#if HAVE_IO_H
_setmode
(
fileno
(
stdout
),
O_BINARY
);
#endif
fp
=
stdout
;
}
if
(
!
fp
)
fail
(
FALSE
,
"Cannot open output file `%s': %s"
,
g_filename_display_name
(
output_file
),
strerror
(
errno
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录