TextPainter RTL (#11888)

This commit is contained in:
Ian Hickson
2017-09-07 16:57:38 -07:00
committed by GitHub
parent f4ccb4b6a4
commit ca7d2d23cf
144 changed files with 2223 additions and 1019 deletions

View File

@@ -14,24 +14,36 @@ void main() {
void addAlignmentRow(CrossAxisAlignment crossAxisAlignment) {
TextStyle style = const TextStyle(color: const Color(0xFF000000));
final RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$crossAxisAlignment'));
final RenderParagraph paragraph = new RenderParagraph(
new TextSpan(style: style, text: '$crossAxisAlignment'),
textDirection: TextDirection.ltr,
);
table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0)));
final RenderFlex row = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic);
style = const TextStyle(fontSize: 15.0, color: const Color(0xFF000000));
row.add(new RenderDecoratedBox(
decoration: const BoxDecoration(color: const Color(0x7FFFCCCC)),
child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo'))
child: new RenderParagraph(
new TextSpan(style: style, text: 'foo foo foo'),
textDirection: TextDirection.ltr,
),
));
style = const TextStyle(fontSize: 10.0, color: const Color(0xFF000000));
row.add(new RenderDecoratedBox(
decoration: const BoxDecoration(color: const Color(0x7FCCFFCC)),
child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo'))
child: new RenderParagraph(
new TextSpan(style: style, text: 'foo foo foo'),
textDirection: TextDirection.ltr,
),
));
final RenderFlex subrow = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic);
style = const TextStyle(fontSize: 25.0, color: const Color(0xFF000000));
subrow.add(new RenderDecoratedBox(
decoration: const BoxDecoration(color: const Color(0x7FCCCCFF)),
child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo foo'))
child: new RenderParagraph(
new TextSpan(style: style, text: 'foo foo foo foo'),
textDirection: TextDirection.ltr,
),
));
subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0)));
row.add(subrow);
@@ -48,7 +60,10 @@ void main() {
void addJustificationRow(MainAxisAlignment justify) {
const TextStyle style = const TextStyle(color: const Color(0xFF000000));
final RenderParagraph paragraph = new RenderParagraph(new TextSpan(style: style, text: '$justify'));
final RenderParagraph paragraph = new RenderParagraph(
new TextSpan(style: style, text: '$justify'),
textDirection: TextDirection.ltr,
);
table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0)));
final RenderFlex row = new RenderFlex(direction: Axis.horizontal);
row.add(new RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: const Size(80.0, 60.0)));

View File

@@ -16,7 +16,14 @@ void main() {
alignment: FractionalOffset.center,
// We use a RenderParagraph to display the text 'Hello, world.' without
// any explicit styling.
child: new RenderParagraph(const TextSpan(text: 'Hello, world.'))
child: new RenderParagraph(
const TextSpan(text: 'Hello, world.'),
// The text is in English so we specify the text direction as
// left-to-right. If the text had been in Hebrew or Arabic, we would
// have specified right-to-left. The Flutter framework does not assume a
// particular text direction.
textDirection: TextDirection.ltr,
),
)
);
}

View File

@@ -104,8 +104,9 @@ void main() {
final RenderParagraph paragraph = new RenderParagraph(
const TextSpan(
style: const TextStyle(color: Colors.black87),
text: "Touch me!"
)
text: "Touch me!",
),
textDirection: TextDirection.ltr,
);
// A stack is a render object that layers its children on top of each other.
// The bottom later is our RenderDots object, and on top of that we show the
@@ -114,7 +115,7 @@ void main() {
children: <RenderBox>[
new RenderDots(),
paragraph,
]
],
);
// The "parentData" field of a render object is controlled by the render
// object's parent render object. Now that we've added the paragraph as a