Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
35ce4744
E
engine
项目概览
liujiuri
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
35ce4744
编写于
12月 09, 2015
作者:
A
Adam Barth
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2161 from abarth/text_decoration
Improve FontWeigh and TextDecoration
上级
3b5acbcd
88758d86
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
22 deletion
+86
-22
sky/engine/core/dart/text.dart
sky/engine/core/dart/text.dart
+86
-22
未找到文件。
sky/engine/core/dart/text.dart
浏览文件 @
35ce4744
...
...
@@ -14,33 +14,58 @@ enum FontStyle {
}
/// The thickness of the glyphs used to draw the text
enum
FontWeight
{
class
FontWeight
{
const
FontWeight
.
_
(
this
.
index
);
final
int
index
;
/// Thin, the least thick
w100
,
static
const
w100
=
const
FontWeight
.
_
(
0
);
/// Extra-light
w200
,
static
const
w200
=
const
FontWeight
.
_
(
1
);
/// Light
w300
,
static
const
w300
=
const
FontWeight
.
_
(
2
);
/// Normal / regular / plain
w400
,
static
const
w400
=
const
FontWeight
.
_
(
3
);
/// Medium
w500
,
static
const
w500
=
const
FontWeight
.
_
(
4
);
/// Semi-bold
w600
,
static
const
w600
=
const
FontWeight
.
_
(
5
);
/// Bold
w700
,
static
const
w700
=
const
FontWeight
.
_
(
6
);
/// Extra-bold
w800
,
static
const
w800
=
const
FontWeight
.
_
(
7
);
/// Black, the most thick
w900
static
const
w900
=
const
FontWeight
.
_
(
8
);
static
const
normal
=
w400
;
static
const
bold
=
w700
;
static
const
List
<
FontWeight
>
values
=
const
[
w100
,
w200
,
w300
,
w400
,
w500
,
w600
,
w700
,
w800
,
w900
];
String
toString
()
{
return
const
{
0
:
FontWeight
.
w100
,
1
:
FontWeight
.
w200
,
2
:
FontWeight
.
w300
,
3
:
FontWeight
.
w400
,
4
:
FontWeight
.
w500
,
5
:
FontWeight
.
w600
,
6
:
FontWeight
.
w700
,
7
:
FontWeight
.
w800
,
8
:
FontWeight
.
w900
,
}[
index
];
}
}
/// Whether to align text horizontally
...
...
@@ -65,18 +90,61 @@ enum TextBaseline {
}
/// A linear decoration to draw near the text
enum
TextDecoration
{
class
TextDecoration
{
const
TextDecoration
.
_
(
this
.
_mask
);
/// Constructs a decoration that paints the union of all the given decorations.
factory
TextDecoration
.
combine
(
List
<
TextDecoration
>
decorations
)
{
int
mask
=
0
;
for
(
TextDecoration
decoration
in
decorations
)
mask
|=
decoration
.
_mask
;
return
new
TextDecoration
.
_
(
mask
);
}
final
int
_mask
;
/// Whether this decoration will paint at least as much decoration as the given decoration.
bool
contains
(
TextDecoration
other
)
{
return
(
_mask
|
other
.
_mask
)
==
_mask
;
}
/// Do not draw a decoration
none
,
static
const
TextDecoration
none
=
const
TextDecoration
.
_
(
0x0
);
/// Draw a line underneath each line of text
underline
,
static
const
TextDecoration
underline
=
const
TextDecoration
.
_
(
0x1
);
/// Draw a line above each line of text
overline
,
static
const
TextDecoration
overline
=
const
TextDecoration
.
_
(
0x2
);
/// Draw a line through each line of text
lineThrough
static
const
TextDecoration
lineThrough
=
const
TextDecoration
.
_
(
0x4
);
bool
operator
==(
dynamic
other
)
{
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
is
!
TextDecoration
)
return
false
;
final
TextDecoration
typedOther
=
other
;
return
_mask
==
typedOther
.
_mask
;
}
int
get
hashCode
=>
_mask
.
hashCode
;
String
toString
()
{
if
(
_mask
==
0
)
return
'TextDecoration.none'
;
List
<
String
>
values
=
<
String
>[];
if
(
_mask
&
underline
.
_mask
!=
0
)
values
.
add
(
'underline'
);
if
(
_mask
&
overline
.
_mask
!=
0
)
values
.
add
(
'overline'
);
if
(
_mask
&
lineThrough
.
_mask
!=
0
)
values
.
add
(
'lineThrough'
);
if
(
values
.
length
==
1
)
return
'TextDecoration.
${values[0]}
'
;
return
'TextDecoration.combine([
${values.join(", ")}
])'
;
}
}
/// The style in which to draw a text decoration
...
...
@@ -120,7 +188,7 @@ enum TextDecorationStyle {
// - Element 6: The enum index of the |fontStyle|.
//
Int32List
_encodeTextStyle
(
Color
color
,
List
<
TextDecoration
>
decoration
,
TextDecoration
decoration
,
Color
decorationColor
,
TextDecorationStyle
decorationStyle
,
FontWeight
fontWeight
,
...
...
@@ -135,11 +203,7 @@ Int32List _encodeTextStyle(Color color,
}
if
(
decoration
!=
null
)
{
result
[
0
]
|=
1
<<
2
;
for
(
TextDecoration
value
in
decoration
)
{
int
shift
=
value
.
index
-
1
;
if
(
shift
!=
0
)
result
[
2
]
|=
1
<<
shift
;
}
result
[
2
]
=
decoration
.
_mask
;
}
if
(
decorationColor
!=
null
)
{
result
[
0
]
|=
1
<<
3
;
...
...
@@ -175,7 +239,7 @@ Int32List _encodeTextStyle(Color color,
class
TextStyle
{
TextStyle
({
Color
color
,
List
<
TextDecoration
>
decoration
,
TextDecoration
decoration
,
Color
decorationColor
,
TextDecorationStyle
decorationStyle
,
FontWeight
fontWeight
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录