Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
45675e58
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看板
提交
45675e58
编写于
5月 15, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[util] Refactor to accommodate for upcoming new tool
上级
1d6846db
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
135 addition
and
70 deletion
+135
-70
util/Makefile.am
util/Makefile.am
+6
-4
util/hb-shape.cc
util/hb-shape.cc
+31
-39
util/hb-view.cc
util/hb-view.cc
+5
-3
util/main-font-text.hh
util/main-font-text.hh
+24
-24
util/shape-consumer.hh
util/shape-consumer.hh
+69
-0
未找到文件。
util/Makefile.am
浏览文件 @
45675e58
...
...
@@ -27,11 +27,12 @@ if HAVE_FREETYPE
if
HAVE_CAIRO_FT
hb_view_SOURCES
=
\
hb-view.cc
\
hb-view.hh
\
ansi-print.cc
\
ansi-print.hh
\
options.cc
\
options.hh
\
main-font-text.hh
\
shape-consumer.hh
\
ansi-print.cc
\
ansi-print.hh
\
helper-cairo.cc
\
helper-cairo.hh
\
helper-cairo-ansi.cc
\
...
...
@@ -53,9 +54,10 @@ if HAVE_GLIB
if
HAVE_FREETYPE
hb_shape_SOURCES
=
\
hb-shape.cc
\
hb-view.hh
\
options.cc
\
options.hh
\
main-font-text.hh
\
shape-consumer.hh
\
$(NULL)
bin_PROGRAMS
+=
hb-shape
endif
...
...
util/hb-shape.cc
浏览文件 @
45675e58
/*
* Copyright © 2010 Behdad Esfahbod
* Copyright © 2011 Google, Inc.
* Copyright © 2011
,2012
Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
...
...
@@ -25,59 +25,51 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-view.hh"
#include "main-font-text.hh"
#include "shape-consumer.hh"
struct
output_buffer_t
:
output_options_t
,
format_options_t
struct
output_buffer_t
:
output_options_t
{
output_buffer_t
(
option_parser_t
*
parser
)
:
output_options_t
(
parser
),
format
_options_t
(
parser
)
{}
format
(
parser
)
{}
void
init
(
const
font_options_t
*
font_opts
);
void
init
(
const
font_options_t
*
font_opts
)
{
get_file_handle
();
gs
=
g_string_new
(
NULL
);
line_no
=
0
;
font
=
hb_font_reference
(
font_opts
->
get_font
());
}
void
consume_line
(
hb_buffer_t
*
buffer
,
const
char
*
text
,
unsigned
int
text_len
,
hb_bool_t
utf8_clusters
);
void
finish
(
const
font_options_t
*
font_opts
);
hb_bool_t
utf8_clusters
)
{
line_no
++
;
g_string_set_size
(
gs
,
0
);
format
.
serialize_line
(
buffer
,
line_no
,
text
,
text_len
,
font
,
utf8_clusters
,
gs
);
fprintf
(
fp
,
"%s"
,
gs
->
str
);
}
void
finish
(
const
font_options_t
*
font_opts
)
{
hb_font_destroy
(
font
);
g_string_free
(
gs
,
TRUE
);
gs
=
NULL
;
font
=
NULL
;
}
protected:
format_options_t
format
;
GString
*
gs
;
hb_font_t
*
font
;
unsigned
int
line_no
;
hb_font_t
*
font
;
};
void
output_buffer_t
::
init
(
const
font_options_t
*
font_opts
)
{
get_file_handle
();
font
=
hb_font_reference
(
font_opts
->
get_font
());
gs
=
g_string_new
(
NULL
);
line_no
=
0
;
}
void
output_buffer_t
::
consume_line
(
hb_buffer_t
*
buffer
,
const
char
*
text
,
unsigned
int
text_len
,
hb_bool_t
utf8_clusters
)
{
line_no
++
;
g_string_set_size
(
gs
,
0
);
serialize_line
(
buffer
,
line_no
,
text
,
text_len
,
font
,
utf8_clusters
,
gs
);
fprintf
(
fp
,
"%s"
,
gs
->
str
);
}
void
output_buffer_t
::
finish
(
const
font_options_t
*
font_opts
)
{
g_string_free
(
gs
,
TRUE
);
gs
=
NULL
;
hb_font_destroy
(
font
);
font
=
NULL
;
}
int
main
(
int
argc
,
char
**
argv
)
{
return
hb_view_t
<
output_buffer_t
>::
main
(
argc
,
argv
);
main_font_text_t
<
shape_consumer_t
<
output_buffer_t
>
>
driver
;
return
driver
.
main
(
argc
,
argv
);
}
util/hb-view.cc
浏览文件 @
45675e58
/*
* Copyright © 2010 Behdad Esfahbod
* Copyright © 2011 Google, Inc.
* Copyright © 2011
,2012
Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
...
...
@@ -25,11 +25,13 @@
* Google Author(s): Behdad Esfahbod
*/
#include "hb-view.hh"
#include "main-font-text.hh"
#include "shape-consumer.hh"
#include "view-cairo.hh"
int
main
(
int
argc
,
char
**
argv
)
{
return
hb_view_t
<
view_cairo_t
>::
main
(
argc
,
argv
);
main_font_text_t
<
shape_consumer_t
<
view_cairo_t
>
>
driver
;
return
driver
.
main
(
argc
,
argv
);
}
util/
hb-view
.hh
→
util/
main-font-text
.hh
浏览文件 @
45675e58
/*
* Copyright © 2011 Google, Inc.
* Copyright © 2011
,2012
Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
...
...
@@ -26,23 +26,23 @@
#include "options.hh"
#ifndef HB_
VIEW
_HH
#define HB_
VIEW
_HH
#ifndef HB_
MAIN_FONT_TEXT
_HH
#define HB_
MAIN_FONT_TEXT
_HH
template
<
typename
output_t
>
struct
hb_view_t
/* main() body for utilities taking font and processing text.*/
template
<
typename
consumer_t
>
struct
main_font_text_t
{
static
int
main_font_text_t
(
void
)
:
options
(
"[FONT-FILE] [TEXT]"
),
font_opts
(
&
options
),
input
(
&
options
),
consumer
(
&
options
)
{}
int
main
(
int
argc
,
char
**
argv
)
{
option_parser_t
options
(
"[FONT-FILE] [TEXT]"
);
shape_options_t
shaper
(
&
options
);
font_options_t
font_opts
(
&
options
);
text_options_t
input
(
&
options
);
output_t
output
(
&
options
);
options
.
parse
(
&
argc
,
&
argv
);
argc
--
,
argv
++
;
...
...
@@ -55,26 +55,26 @@ struct hb_view_t
if
(
!
input
.
text
&&
!
input
.
text_file
)
input
.
text_file
=
"-"
;
output
.
init
(
&
font_opts
);
consumer
.
init
(
&
font_opts
);
hb_buffer_t
*
buffer
=
hb_buffer_create
();
unsigned
int
text_len
;
const
char
*
text
;
while
((
text
=
input
.
get_line
(
&
text_len
)))
{
if
(
!
shaper
.
shape
(
text
,
text_len
,
font_opts
.
get_font
(),
buffer
))
fail
(
FALSE
,
"All shapers failed"
);
output
.
consume_line
(
buffer
,
text
,
text_len
,
shaper
.
utf8_clusters
);
}
consumer
.
consume_line
(
buffer
,
text
,
text_len
);
hb_buffer_destroy
(
buffer
);
output
.
finish
(
&
font_opts
);
consumer
.
finish
(
&
font_opts
);
return
0
;
}
protected:
option_parser_t
options
;
font_options_t
font_opts
;
text_options_t
input
;
consumer_t
consumer
;
};
#endif
util/shape-consumer.hh
0 → 100644
浏览文件 @
45675e58
/*
* Copyright © 2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Behdad Esfahbod
*/
#include "options.hh"
#ifndef HB_SHAPE_CONSUMER_HH
#define HB_SHAPE_CONSUMER_HH
template
<
typename
output_t
>
struct
shape_consumer_t
{
shape_consumer_t
(
option_parser_t
*
parser
)
:
shaper
(
parser
),
output
(
parser
)
{}
void
init
(
const
font_options_t
*
font_opts
)
{
font
=
hb_font_reference
(
font_opts
->
get_font
());
output
.
init
(
font_opts
);
}
void
consume_line
(
hb_buffer_t
*
buffer
,
const
char
*
text
,
unsigned
int
text_len
)
{
if
(
!
shaper
.
shape
(
text
,
text_len
,
font
,
buffer
))
fail
(
FALSE
,
"All shapers failed"
);
output
.
consume_line
(
buffer
,
text
,
text_len
,
shaper
.
utf8_clusters
);
}
void
finish
(
const
font_options_t
*
font_opts
)
{
output
.
finish
(
font_opts
);
hb_font_destroy
(
font
);
font
=
NULL
;
}
protected:
shape_options_t
shaper
;
output_t
output
;
hb_font_t
*
font
;
};
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录