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
eb5cc495
Unverified
Commit
eb5cc495
authored
Sep 23, 2020
by
Gary Qian
Committed by
GitHub
Sep 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide defaulting for textScaleFactor when passing to dart:ui (#66375)
parent
d5b715d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+9
-0
text_style.dart
packages/flutter/lib/src/painting/text_style.dart
+6
-4
text_painter_test.dart
packages/flutter/test/painting/text_painter_test.dart
+12
-0
No files found.
packages/flutter/lib/src/painting/text_painter.dart
View file @
eb5cc495
...
...
@@ -16,6 +16,11 @@ import 'text_span.dart';
export
'package:flutter/services.dart'
show
TextRange
,
TextSelection
;
// The default font size if none is specified. This should be kept in
// sync with the default values in text_style.dart, as well as the
// defaults set in the engine (eg, LibTxt's text_style.h, paragraph_style.h).
const
double
_kDefaultFontSize
=
14.0
;
/// Holds the [Size] and baseline required to represent the dimensions of
/// a placeholder in text.
///
...
...
@@ -420,6 +425,10 @@ class TextPainter {
)
??
ui
.
ParagraphStyle
(
textAlign:
textAlign
,
textDirection:
textDirection
??
defaultTextDirection
,
// Use the default font size to multiply by as RichText does not
// perform inheriting [TextStyle]s and would otherwise
// fail to apply textScaleFactor.
fontSize:
_kDefaultFontSize
*
textScaleFactor
,
maxLines:
maxLines
,
textHeightBehavior:
_textHeightBehavior
,
ellipsis:
ellipsis
,
...
...
packages/flutter/lib/src/painting/text_style.dart
View file @
eb5cc495
...
...
@@ -19,6 +19,11 @@ const String _kColorForegroundWarning = 'Cannot provide both a color and a foreg
const
String
_kColorBackgroundWarning
=
'Cannot provide both a backgroundColor and a background
\n
'
'The backgroundColor argument is just a shorthand for "background: new Paint()..color = color".'
;
// The default font size if none is specified. This should be kept in
// sync with the default values in text_painter.dart, as well as the
// defaults set in the engine (eg, LibTxt's text_style.h, paragraph_style.h).
const
double
_kDefaultFontSize
=
14.0
;
// Examples can assume:
// BuildContext context;
...
...
@@ -512,9 +517,6 @@ class TextStyle with Diagnosticable {
/// isn't specified here.
final
double
?
fontSize
;
// The default font size if none is specified.
static
const
double
_defaultFontSize
=
14.0
;
/// The typeface thickness to use when painting the text (e.g., bold).
final
FontWeight
?
fontWeight
;
...
...
@@ -1092,7 +1094,7 @@ class TextStyle with Diagnosticable {
fontWeight:
fontWeight
??
this
.
fontWeight
,
fontStyle:
fontStyle
??
this
.
fontStyle
,
fontFamily:
fontFamily
??
this
.
fontFamily
,
fontSize:
(
fontSize
??
this
.
fontSize
??
_
d
efaultFontSize
)
*
textScaleFactor
,
fontSize:
(
fontSize
??
this
.
fontSize
??
_
kD
efaultFontSize
)
*
textScaleFactor
,
height:
height
??
this
.
height
,
textHeightBehavior:
textHeightBehavior
,
strutStyle:
strutStyle
==
null
?
null
:
ui
.
StrutStyle
(
...
...
packages/flutter/test/painting/text_painter_test.dart
View file @
eb5cc495
...
...
@@ -192,6 +192,18 @@ void main() {
expect
(
painter
.
size
,
const
Size
(
20.0
,
20.0
));
});
test
(
'TextPainter textScaleFactor null style test'
,
()
{
final
TextPainter
painter
=
TextPainter
(
text:
const
TextSpan
(
text:
'X'
,
),
textDirection:
TextDirection
.
ltr
,
textScaleFactor:
2.0
,
);
painter
.
layout
();
expect
(
painter
.
size
,
const
Size
(
28.0
,
28.0
));
});
test
(
'TextPainter default text height is 14 pixels'
,
()
{
final
TextPainter
painter
=
TextPainter
(
text:
const
TextSpan
(
text:
'x'
),
...
...
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