Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
589f5147
E
engine
项目概览
weixin_43355755
/
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,发现更多精彩内容 >>
未验证
提交
589f5147
编写于
5月 13, 2021
作者:
L
LongCatIsLooong
提交者:
GitHub
5月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add `TextLeadingDistribution` to webui `TextStyle` (#25777)
上级
e0418d2c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
64 addition
and
4 deletion
+64
-4
lib/web_ui/dev/goldens_lock.yaml
lib/web_ui/dev/goldens_lock.yaml
+1
-1
lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
+2
-0
lib/web_ui/lib/src/engine/canvaskit/text.dart
lib/web_ui/lib/src/engine/canvaskit/text.dart
+33
-2
lib/web_ui/lib/src/engine/text/paragraph.dart
lib/web_ui/lib/src/engine/text/paragraph.dart
+0
-1
lib/web_ui/lib/src/ui/text.dart
lib/web_ui/lib/src/ui/text.dart
+1
-0
lib/web_ui/test/canvaskit/canvas_golden_test.dart
lib/web_ui/test/canvaskit/canvas_golden_test.dart
+23
-0
lib/web_ui/test/canvaskit/canvaskit_api_test.dart
lib/web_ui/test/canvaskit/canvaskit_api_test.dart
+4
-0
未找到文件。
lib/web_ui/dev/goldens_lock.yaml
浏览文件 @
589f5147
repository
:
https://github.com/flutter/goldens.git
revision
:
4
a8da9f65353bda26a73e12838797f20cfdedc40
revision
:
4
d00d1a0f1c0bc123814919a45ef2c2f57ed21ec
lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
浏览文件 @
589f5147
...
...
@@ -1674,6 +1674,7 @@ class SkTextStyleProperties {
external
set
letterSpacing
(
double
?
value
);
external
set
wordSpacing
(
double
?
value
);
external
set
heightMultiplier
(
double
?
value
);
external
set
halfLeading
(
bool
?
value
);
external
set
locale
(
String
?
value
);
external
set
fontFamilies
(
List
<
String
>?
value
);
external
set
fontStyle
(
SkFontStyle
?
value
);
...
...
@@ -1688,6 +1689,7 @@ class SkStrutStyleProperties {
external
set
fontStyle
(
SkFontStyle
?
value
);
external
set
fontSize
(
double
?
value
);
external
set
heightMultiplier
(
double
?
value
);
external
set
halfLeading
(
bool
?
value
);
external
set
leading
(
double
?
value
);
external
set
strutEnabled
(
bool
?
value
);
external
set
forceStrutHeight
(
bool
?
value
);
...
...
lib/web_ui/lib/src/engine/canvaskit/text.dart
浏览文件 @
589f5147
...
...
@@ -37,6 +37,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
_fontFamily
=
fontFamily
,
_fontSize
=
fontSize
,
_height
=
height
,
_leadingDistribution
=
textHeightBehavior
?.
leadingDistribution
,
_fontWeight
=
fontWeight
,
_fontStyle
=
fontStyle
;
...
...
@@ -47,6 +48,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
final
double
?
_height
;
final
ui
.
FontWeight
?
_fontWeight
;
final
ui
.
FontStyle
?
_fontStyle
;
final
ui
.
TextLeadingDistribution
?
_leadingDistribution
;
static
SkTextStyleProperties
toSkTextStyleProperties
(
String
?
fontFamily
,
...
...
@@ -73,7 +75,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
return
skTextStyle
;
}
static
SkStrutStyleProperties
toSkStrutStyleProperties
(
ui
.
StrutStyle
value
)
{
static
SkStrutStyleProperties
toSkStrutStyleProperties
(
ui
.
StrutStyle
value
,
ui
.
TextHeightBehavior
?
paragraphHeightBehavior
)
{
EngineStrutStyle
style
=
value
as
EngineStrutStyle
;
final
SkStrutStyleProperties
skStrutStyle
=
SkStrutStyleProperties
();
skStrutStyle
.
fontFamilies
=
...
...
@@ -87,6 +89,18 @@ class CkParagraphStyle implements ui.ParagraphStyle {
skStrutStyle
.
heightMultiplier
=
style
.
_height
;
}
final
ui
.
TextLeadingDistribution
?
effectiveLeadingDistribution
=
style
.
_leadingDistribution
??
paragraphHeightBehavior
?.
leadingDistribution
;
switch
(
effectiveLeadingDistribution
)
{
case
null
:
break
;
case
ui
.
TextLeadingDistribution
.
even
:
skStrutStyle
.
halfLeading
=
true
;
break
;
case
ui
.
TextLeadingDistribution
.
proportional
:
skStrutStyle
.
halfLeading
=
false
;
break
;
}
if
(
style
.
_leading
!=
null
)
{
skStrutStyle
.
leading
=
style
.
_leading
;
}
...
...
@@ -147,7 +161,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
}
if
(
strutStyle
!=
null
)
{
properties
.
strutStyle
=
toSkStrutStyleProperties
(
strutStyle
);
properties
.
strutStyle
=
toSkStrutStyleProperties
(
strutStyle
,
textHeightBehavior
);
}
properties
.
textStyle
=
toSkTextStyleProperties
(
...
...
@@ -161,6 +175,7 @@ class CkParagraphStyle implements ui.ParagraphStyle {
fontFamily:
_fontFamily
,
fontSize:
_fontSize
,
height:
_height
,
leadingDistribution:
_leadingDistribution
,
fontWeight:
_fontWeight
,
fontStyle:
_fontStyle
,
);
...
...
@@ -184,6 +199,7 @@ class CkTextStyle implements ui.TextStyle {
double
?
letterSpacing
,
double
?
wordSpacing
,
double
?
height
,
ui
.
TextLeadingDistribution
?
leadingDistribution
,
ui
.
Locale
?
locale
,
CkPaint
?
background
,
CkPaint
?
foreground
,
...
...
@@ -205,6 +221,7 @@ class CkTextStyle implements ui.TextStyle {
letterSpacing
,
wordSpacing
,
height
,
leadingDistribution
,
locale
,
background
,
foreground
,
...
...
@@ -228,6 +245,7 @@ class CkTextStyle implements ui.TextStyle {
this
.
letterSpacing
,
this
.
wordSpacing
,
this
.
height
,
this
.
leadingDistribution
,
this
.
locale
,
this
.
background
,
this
.
foreground
,
...
...
@@ -249,6 +267,7 @@ class CkTextStyle implements ui.TextStyle {
final
double
?
letterSpacing
;
final
double
?
wordSpacing
;
final
double
?
height
;
final
ui
.
TextLeadingDistribution
?
leadingDistribution
;
final
ui
.
Locale
?
locale
;
final
CkPaint
?
background
;
final
CkPaint
?
foreground
;
...
...
@@ -275,6 +294,7 @@ class CkTextStyle implements ui.TextStyle {
letterSpacing:
other
.
letterSpacing
??
letterSpacing
,
wordSpacing:
other
.
wordSpacing
??
wordSpacing
,
height:
other
.
height
??
height
,
leadingDistribution:
other
.
leadingDistribution
??
leadingDistribution
,
locale:
other
.
locale
??
locale
,
background:
other
.
background
??
background
,
foreground:
other
.
foreground
??
foreground
,
...
...
@@ -367,6 +387,17 @@ class CkTextStyle implements ui.TextStyle {
properties
.
heightMultiplier
=
height
;
}
switch
(
leadingDistribution
)
{
case
null
:
break
;
case
ui
.
TextLeadingDistribution
.
even
:
properties
.
halfLeading
=
true
;
break
;
case
ui
.
TextLeadingDistribution
.
proportional
:
properties
.
halfLeading
=
false
;
break
;
}
if
(
locale
!=
null
)
{
properties
.
locale
=
locale
.
toLanguageTag
();
}
...
...
lib/web_ui/lib/src/engine/text/paragraph.dart
浏览文件 @
589f5147
...
...
@@ -1210,7 +1210,6 @@ class EngineStrutStyle implements ui.StrutStyle {
List
<
String
>?
fontFamilyFallback
,
double
?
fontSize
,
double
?
height
,
//TODO(LongCatIsLooong): implement leadingDistribution.
ui
.
TextLeadingDistribution
?
leadingDistribution
,
double
?
leading
,
ui
.
FontWeight
?
fontWeight
,
...
...
lib/web_ui/lib/src/ui/text.dart
浏览文件 @
589f5147
...
...
@@ -285,6 +285,7 @@ abstract class TextStyle {
letterSpacing:
letterSpacing
,
wordSpacing:
wordSpacing
,
height:
height
,
leadingDistribution:
leadingDistribution
,
locale:
locale
,
background:
background
as
engine
.
CkPaint
?,
foreground:
foreground
as
engine
.
CkPaint
?,
...
...
lib/web_ui/test/canvaskit/canvas_golden_test.dart
浏览文件 @
589f5147
...
...
@@ -357,6 +357,27 @@ void testMain() {
await
testTextStyle
(
'height'
,
height:
2
);
});
test
(
'text styles - leading distribution'
,
()
async
{
await
testTextStyle
(
'half leading'
,
height:
20
,
fontSize:
10
,
leadingDistribution:
ui
.
TextLeadingDistribution
.
even
);
await
testTextStyle
(
'half leading inherited from paragraph'
,
height:
20
,
fontSize:
10
,
paragraphTextHeightBehavior:
ui
.
TextHeightBehavior
(
leadingDistribution:
ui
.
TextLeadingDistribution
.
even
,
),
);
await
testTextStyle
(
'text style half leading overrides paragraph style half leading'
,
height:
20
,
fontSize:
10
,
leadingDistribution:
ui
.
TextLeadingDistribution
.
proportional
,
paragraphTextHeightBehavior:
ui
.
TextHeightBehavior
(
leadingDistribution:
ui
.
TextLeadingDistribution
.
even
,
),
);
});
// TODO(yjbanov): locales specified in text styles don't work:
// https://github.com/flutter/flutter/issues/74687
// TODO(yjbanov): spaces are not rendered correctly:
...
...
@@ -1118,6 +1139,7 @@ Future<void> testTextStyle(
double
?
letterSpacing
,
double
?
wordSpacing
,
double
?
height
,
ui
.
TextLeadingDistribution
?
leadingDistribution
,
ui
.
Locale
?
locale
,
CkPaint
?
background
,
CkPaint
?
foreground
,
...
...
@@ -1169,6 +1191,7 @@ Future<void> testTextStyle(
letterSpacing:
letterSpacing
,
wordSpacing:
wordSpacing
,
height:
height
,
leadingDistribution:
leadingDistribution
,
locale:
locale
,
background:
background
,
foreground:
foreground
,
...
...
lib/web_ui/test/canvaskit/canvaskit_api_test.dart
浏览文件 @
589f5147
...
...
@@ -1289,6 +1289,7 @@ void _paragraphTests() {
..
letterSpacing
=
5
..
wordSpacing
=
10
..
heightMultiplier
=
2.5
..
halfLeading
=
true
..
locale
=
'en_CA'
..
fontFamilies
=
<
String
>[
'Roboto'
,
'serif'
]
..
fontStyle
=
(
SkFontStyle
()
...
...
@@ -1310,6 +1311,7 @@ void _paragraphTests() {
..
weight
=
canvasKit
.
FontWeight
.
Bold
)
..
fontSize
=
23
..
heightMultiplier
=
5
..
halfLeading
=
true
..
leading
=
6
..
strutEnabled
=
true
..
forceStrutHeight
=
false
;
...
...
@@ -1338,6 +1340,8 @@ void _paragraphTests() {
SkPaint
());
builder
.
addText
(
'!'
);
builder
.
pop
();
builder
.
pushStyle
(
canvasKit
.
TextStyle
(
SkTextStyleProperties
()..
halfLeading
=
true
));
builder
.
pop
();
final
SkParagraph
paragraph
=
builder
.
build
();
paragraph
.
layout
(
55
);
expect
(
paragraph
.
getAlphabeticBaseline
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录