Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c8ac09a5
Commit
c8ac09a5
authored
Jan 04, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1042 from Hixie/wordSpacing
Hook up wordSpacing and inline height.
parents
dcd34f47
4588524c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
10 deletions
+40
-10
baseline.dart
examples/rendering/baseline.dart
+19
-6
text_style.dart
packages/flutter/lib/src/painting/text_style.dart
+21
-4
No files found.
examples/rendering/baseline.dart
View file @
c8ac09a5
...
...
@@ -17,17 +17,30 @@ class _BaselinePainter extends CustomPainter {
double
baseline
=
paragraph
.
getDistanceToBaseline
(
TextBaseline
.
alphabetic
);
double
w
=
paragraph
.
getMaxIntrinsicWidth
(
new
BoxConstraints
.
loose
(
size
));
double
h
=
paragraph
.
getMaxIntrinsicHeight
(
new
BoxConstraints
.
loose
(
size
));
Path
path
=
new
Path
();
Path
path
;
Paint
paint
;
// top and bottom
path
=
new
Path
();
path
.
moveTo
(
0.0
,
0.0
);
path
.
lineTo
(
w
,
0.0
);
path
.
moveTo
(
0.0
,
baseline
);
path
.
lineTo
(
w
,
baseline
);
path
.
moveTo
(
0.0
,
h
);
path
.
lineTo
(
w
,
h
);
Paint
paint
=
new
Paint
()
paint
=
new
Paint
()
..
color
=
const
Color
(
0xFFFF9000
)
..
style
=
ui
.
PaintingStyle
.
stroke
..
strokeWidth
=
3.0
;
..
strokeWidth
=
1.5
;
canvas
.
drawPath
(
path
,
paint
);
// baseline
path
=
new
Path
();
path
.
moveTo
(
0.0
,
baseline
);
path
.
lineTo
(
w
,
baseline
);
paint
=
new
Paint
()
..
color
=
const
Color
(
0xFF00FF90
)
..
style
=
ui
.
PaintingStyle
.
stroke
..
strokeWidth
=
1.5
;
canvas
.
drawPath
(
path
,
paint
);
}
...
...
@@ -81,8 +94,8 @@ void main() {
new
RenderConstrainedBox
(
additionalConstraints:
new
BoxConstraints
.
tightFor
(
height:
50.0
)
),
getBox
(
1.0
),
getBox
(
null
),
getBox
(
1.2
),
],
direction:
FlexDirection
.
vertical
,
alignItems:
FlexAlignItems
.
stretch
...
...
packages/flutter/lib/src/painting/text_style.dart
View file @
c8ac09a5
...
...
@@ -16,6 +16,7 @@ class TextStyle {
this
.
fontWeight
,
this
.
fontStyle
,
this
.
letterSpacing
,
this
.
wordSpacing
,
this
.
textAlign
,
this
.
textBaseline
,
this
.
height
,
...
...
@@ -45,6 +46,9 @@ class TextStyle {
/// The amount of space to add between each letter.
final
double
letterSpacing
;
/// The amount of space to add at each sequence of white-space (i.e. between each word).
final
double
wordSpacing
;
/// How the text should be aligned (applies only to the outermost
/// StyledTextSpan, which establishes the container for the text).
final
TextAlign
textAlign
;
...
...
@@ -73,6 +77,7 @@ class TextStyle {
FontWeight
fontWeight
,
FontStyle
fontStyle
,
double
letterSpacing
,
double
wordSpacing
,
TextAlign
textAlign
,
TextBaseline
textBaseline
,
double
height
,
...
...
@@ -88,6 +93,7 @@ class TextStyle {
fontWeight:
fontWeight
!=
null
?
fontWeight
:
this
.
fontWeight
,
fontStyle:
fontStyle
!=
null
?
fontStyle
:
this
.
fontStyle
,
letterSpacing:
letterSpacing
!=
null
?
letterSpacing
:
this
.
letterSpacing
,
wordSpacing:
wordSpacing
!=
null
?
wordSpacing
:
this
.
wordSpacing
,
textAlign:
textAlign
!=
null
?
textAlign
:
this
.
textAlign
,
textBaseline:
textBaseline
!=
null
?
textBaseline
:
this
.
textBaseline
,
height:
height
!=
null
?
height
:
this
.
height
,
...
...
@@ -111,6 +117,7 @@ class TextStyle {
fontWeight:
other
.
fontWeight
,
fontStyle:
other
.
fontStyle
,
letterSpacing:
other
.
letterSpacing
,
wordSpacing:
other
.
wordSpacing
,
textAlign:
other
.
textAlign
,
textBaseline:
other
.
textBaseline
,
height:
other
.
height
,
...
...
@@ -130,7 +137,9 @@ class TextStyle {
fontStyle:
fontStyle
,
fontFamily:
fontFamily
,
fontSize:
fontSize
,
letterSpacing:
letterSpacing
letterSpacing:
letterSpacing
,
wordSpacing:
wordSpacing
,
lineHeight:
height
);
}
...
...
@@ -155,8 +164,10 @@ class TextStyle {
fontWeight
==
typedOther
.
fontWeight
&&
fontStyle
==
typedOther
.
fontStyle
&&
letterSpacing
==
typedOther
.
letterSpacing
&&
wordSpacing
==
typedOther
.
wordSpacing
&&
textAlign
==
typedOther
.
textAlign
&&
textBaseline
==
typedOther
.
textBaseline
&&
height
==
typedOther
.
height
&&
decoration
==
typedOther
.
decoration
&&
decorationColor
==
typedOther
.
decorationColor
&&
decorationStyle
==
typedOther
.
decorationStyle
;
...
...
@@ -164,15 +175,17 @@ class TextStyle {
int
get
hashCode
{
return
hashValues
(
super
.
hashCode
,
inherit
,
color
,
fontFamily
,
fontSize
,
fontWeight
,
fontStyle
,
letterSpacing
,
wordSpacing
,
textAlign
,
textBaseline
,
height
,
decoration
,
decorationColor
,
decorationStyle
...
...
@@ -181,7 +194,7 @@ class TextStyle {
String
toString
([
String
prefix
=
''
])
{
List
<
String
>
result
=
<
String
>[];
result
.
add
(
'
${prefix}
inhert:
$inherit
'
);
result
.
add
(
'
${prefix}
inher
i
t:
$inherit
'
);
if
(
color
!=
null
)
result
.
add
(
'
${prefix}
color:
$color
'
);
if
(
fontFamily
!=
null
)
...
...
@@ -230,7 +243,9 @@ class TextStyle {
}
}
if
(
letterSpacing
!=
null
)
result
.
add
(
'
${prefix}
letterSpacing:
$letterSpacing
'
);
result
.
add
(
'
${prefix}
letterSpacing:
${letterSpacing}
x'
);
if
(
wordSpacing
!=
null
)
result
.
add
(
'
${prefix}
wordSpacing:
${wordSpacing}
x'
);
if
(
textAlign
!=
null
)
{
switch
(
textAlign
)
{
case
TextAlign
.
left
:
...
...
@@ -254,6 +269,8 @@ class TextStyle {
break
;
}
}
if
(
height
!=
null
)
result
.
add
(
'
${prefix}
height:
${height}
x'
);
if
(
decoration
!=
null
||
decorationColor
!=
null
||
decorationStyle
!=
null
)
{
String
decorationDescription
=
'
${prefix}
decoration: '
;
bool
haveDecorationDescription
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment