From 5ba7a1c7add51442f96066298b3cad1c697beac2 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 22 Oct 2015 22:56:56 -0700 Subject: [PATCH] Make NewTextPainter actually work The NewTextPainter is still disabled by default. A future patch will flip the flag to enable it. This patch uses a new approach to writing bindings by encoding data into array buffers. This approach is more efficient than the existing IDL based approach. If this works out well, we should convert our other performance-sensitive interfaces to this approach in future patches. --- .../lib/src/painting/text_painter.dart | 2 +- .../flutter/lib/src/painting/text_style.dart | 23 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index b5140f3bbd..ed8cdcf71e 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -309,7 +309,7 @@ class _NewTextPainter implements TextPainter { _text = value; ui.ParagraphBuilder builder = new ui.ParagraphBuilder(); _text.build(builder); - _paragraph = builder.build(_text.paragraphStyle); + _paragraph = builder.build(_text.paragraphStyle ?? new ui.ParagraphStyle()); _needsLayout = true; } diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index 86aa5febd0..28a67bf53e 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -151,8 +151,27 @@ class TextStyle { return toCSS[decorationStyle]; } - ui.TextStyle get textStyle => null; - ui.ParagraphStyle get paragraphStyle => null; + ui.TextStyle get textStyle { + return new ui.TextStyle( + color: color, + decoration: decoration, + decorationColor: decorationColor, + decorationStyle: decorationStyle, + fontWeight: fontWeight, + fontStyle: fontStyle, + fontFamily: fontFamily, + fontSize: fontSize + ); + } + + ui.ParagraphStyle get paragraphStyle { + return new ui.ParagraphStyle( + // TODO(abarth): Restore once the analyzer can see the new dart:ui interface. + // textAlign: textAlign, + textBaseline: textBaseline, + lineHeight: height + ); + } /// Program this text style into the engine ///