mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Expose decorationThickness to dart:ui (#8008)
This commit is contained in:
parent
5ccee95373
commit
52b67fdd5a
@ -265,6 +265,7 @@ Int32List _encodeTextStyle(
|
||||
TextDecoration decoration,
|
||||
Color decorationColor,
|
||||
TextDecorationStyle decorationStyle,
|
||||
double decorationThickness,
|
||||
FontWeight fontWeight,
|
||||
FontStyle fontStyle,
|
||||
TextBaseline textBaseline,
|
||||
@ -296,20 +297,23 @@ Int32List _encodeTextStyle(
|
||||
result[0] |= 1 << 4;
|
||||
result[4] = decorationStyle.index;
|
||||
}
|
||||
if (fontWeight != null) {
|
||||
if (decorationThickness != null) {
|
||||
result[0] |= 1 << 5;
|
||||
}
|
||||
if (fontWeight != null) {
|
||||
result[0] |= 1 << 6;
|
||||
result[5] = fontWeight.index;
|
||||
}
|
||||
if (fontStyle != null) {
|
||||
result[0] |= 1 << 6;
|
||||
result[0] |= 1 << 7;
|
||||
result[6] = fontStyle.index;
|
||||
}
|
||||
if (textBaseline != null) {
|
||||
result[0] |= 1 << 7;
|
||||
result[0] |= 1 << 8;
|
||||
result[7] = textBaseline.index;
|
||||
}
|
||||
if (fontFamily != null || (fontFamilyFallback != null && fontFamilyFallback.isNotEmpty)) {
|
||||
result[0] |= 1 << 8;
|
||||
result[0] |= 1 << 9;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (fontSize != null) {
|
||||
@ -355,6 +359,7 @@ class TextStyle {
|
||||
/// * `decoration`: The decorations to paint near the text (e.g., an underline).
|
||||
/// * `decorationColor`: The color in which to paint the text decorations.
|
||||
/// * `decorationStyle`: The style in which to paint the text decorations (e.g., dashed).
|
||||
/// * `decorationThickness`: The thickness of the decoration as a muliplier on the thickness specified by the font.
|
||||
/// * `fontWeight`: The typeface thickness to use when painting the text (e.g., bold).
|
||||
/// * `fontStyle`: The typeface variant to use when drawing the letters (e.g., italics).
|
||||
/// * `fontFamily`: The name of the font to use when painting the text (e.g., Roboto). If a `fontFamilyFallback` is
|
||||
@ -379,6 +384,7 @@ class TextStyle {
|
||||
TextDecoration decoration,
|
||||
Color decorationColor,
|
||||
TextDecorationStyle decorationStyle,
|
||||
double decorationThickness,
|
||||
FontWeight fontWeight,
|
||||
FontStyle fontStyle,
|
||||
TextBaseline textBaseline,
|
||||
@ -401,6 +407,7 @@ class TextStyle {
|
||||
decoration,
|
||||
decorationColor,
|
||||
decorationStyle,
|
||||
decorationThickness,
|
||||
fontWeight,
|
||||
fontStyle,
|
||||
textBaseline,
|
||||
@ -421,6 +428,7 @@ class TextStyle {
|
||||
_letterSpacing = letterSpacing,
|
||||
_wordSpacing = wordSpacing,
|
||||
_height = height,
|
||||
_decorationThickness = decorationThickness,
|
||||
_locale = locale,
|
||||
_background = background,
|
||||
_foreground = foreground,
|
||||
@ -433,6 +441,7 @@ class TextStyle {
|
||||
final double _letterSpacing;
|
||||
final double _wordSpacing;
|
||||
final double _height;
|
||||
final double _decorationThickness;
|
||||
final Locale _locale;
|
||||
final Paint _background;
|
||||
final Paint _foreground;
|
||||
@ -450,6 +459,7 @@ class TextStyle {
|
||||
_letterSpacing != typedOther._letterSpacing ||
|
||||
_wordSpacing != typedOther._wordSpacing ||
|
||||
_height != typedOther._height ||
|
||||
_decorationThickness != typedOther._decorationThickness ||
|
||||
_locale != typedOther._locale ||
|
||||
_background != typedOther._background ||
|
||||
_foreground != typedOther._foreground)
|
||||
@ -466,31 +476,32 @@ class TextStyle {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, _shadows);
|
||||
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, _shadows, _decorationThickness);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TextStyle('
|
||||
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, '
|
||||
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, '
|
||||
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, '
|
||||
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
|
||||
'fontWeight: ${ _encoded[0] & 0x00020 == 0x00020 ? FontWeight.values[_encoded[5]] : "unspecified"}, '
|
||||
'fontStyle: ${ _encoded[0] & 0x00040 == 0x00040 ? FontStyle.values[_encoded[6]] : "unspecified"}, '
|
||||
'textBaseline: ${ _encoded[0] & 0x00080 == 0x00080 ? TextBaseline.values[_encoded[7]] : "unspecified"}, '
|
||||
'fontFamily: ${ _encoded[0] & 0x00100 == 0x00100
|
||||
&& _fontFamily != null ? _fontFamily : "unspecified"}, '
|
||||
'fontFamilyFallback: ${_encoded[0] & 0x00100 == 0x00100
|
||||
&& _fontFamilyFallback != null
|
||||
&& _fontFamilyFallback.isNotEmpty ? _fontFamilyFallback : "unspecified"}, '
|
||||
'fontSize: ${ _encoded[0] & 0x00200 == 0x00200 ? _fontSize : "unspecified"}, '
|
||||
'letterSpacing: ${ _encoded[0] & 0x00400 == 0x00400 ? "${_letterSpacing}x" : "unspecified"}, '
|
||||
'wordSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_wordSpacing}x" : "unspecified"}, '
|
||||
'height: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_height}x" : "unspecified"}, '
|
||||
'locale: ${ _encoded[0] & 0x02000 == 0x02000 ? _locale : "unspecified"}, '
|
||||
'background: ${ _encoded[0] & 0x04000 == 0x04000 ? _background : "unspecified"}, '
|
||||
'foreground: ${ _encoded[0] & 0x08000 == 0x08000 ? _foreground : "unspecified"}, '
|
||||
'shadows: ${ _encoded[0] & 0x10000 == 0x10000 ? _shadows : "unspecified"}'
|
||||
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, '
|
||||
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, '
|
||||
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, '
|
||||
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
|
||||
'decorationThickness: ${_encoded[0] & 0x00020 == 0x00020 ? _decorationThickness : "unspecified"}, '
|
||||
'fontWeight: ${ _encoded[0] & 0x00040 == 0x00040 ? FontWeight.values[_encoded[5]] : "unspecified"}, '
|
||||
'fontStyle: ${ _encoded[0] & 0x00080 == 0x00080 ? FontStyle.values[_encoded[6]] : "unspecified"}, '
|
||||
'textBaseline: ${ _encoded[0] & 0x00100 == 0x00100 ? TextBaseline.values[_encoded[7]] : "unspecified"}, '
|
||||
'fontFamily: ${ _encoded[0] & 0x00200 == 0x00200
|
||||
&& _fontFamily != null ? _fontFamily : "unspecified"}, '
|
||||
'fontFamilyFallback: ${ _encoded[0] & 0x00200 == 0x00200
|
||||
&& _fontFamilyFallback != null
|
||||
&& _fontFamilyFallback.isNotEmpty ? _fontFamilyFallback : "unspecified"}, '
|
||||
'fontSize: ${ _encoded[0] & 0x00400 == 0x00400 ? _fontSize : "unspecified"}, '
|
||||
'letterSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_letterSpacing}x" : "unspecified"}, '
|
||||
'wordSpacing: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_wordSpacing}x" : "unspecified"}, '
|
||||
'height: ${ _encoded[0] & 0x02000 == 0x02000 ? "${_height}x" : "unspecified"}, '
|
||||
'locale: ${ _encoded[0] & 0x04000 == 0x04000 ? _locale : "unspecified"}, '
|
||||
'background: ${ _encoded[0] & 0x08000 == 0x08000 ? _background : "unspecified"}, '
|
||||
'foreground: ${ _encoded[0] & 0x10000 == 0x10000 ? _foreground : "unspecified"}, '
|
||||
'shadows: ${ _encoded[0] & 0x20000 == 0x20000 ? _shadows : "unspecified"}'
|
||||
')';
|
||||
}
|
||||
}
|
||||
|
||||
137
lib/ui/text.dart
137
lib/ui/text.dart
@ -265,6 +265,7 @@ Int32List _encodeTextStyle(
|
||||
TextDecoration decoration,
|
||||
Color decorationColor,
|
||||
TextDecorationStyle decorationStyle,
|
||||
double decorationThickness,
|
||||
FontWeight fontWeight,
|
||||
FontStyle fontStyle,
|
||||
TextBaseline textBaseline,
|
||||
@ -296,54 +297,57 @@ Int32List _encodeTextStyle(
|
||||
result[0] |= 1 << 4;
|
||||
result[4] = decorationStyle.index;
|
||||
}
|
||||
if (fontWeight != null) {
|
||||
if (decorationThickness != null) {
|
||||
result[0] |= 1 << 5;
|
||||
}
|
||||
if (fontWeight != null) {
|
||||
result[0] |= 1 << 6;
|
||||
result[5] = fontWeight.index;
|
||||
}
|
||||
if (fontStyle != null) {
|
||||
result[0] |= 1 << 6;
|
||||
result[0] |= 1 << 7;
|
||||
result[6] = fontStyle.index;
|
||||
}
|
||||
if (textBaseline != null) {
|
||||
result[0] |= 1 << 7;
|
||||
result[0] |= 1 << 8;
|
||||
result[7] = textBaseline.index;
|
||||
}
|
||||
if (fontFamily != null || (fontFamilyFallback != null && fontFamilyFallback.isNotEmpty)) {
|
||||
result[0] |= 1 << 8;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (fontSize != null) {
|
||||
result[0] |= 1 << 9;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (letterSpacing != null) {
|
||||
if (fontSize != null) {
|
||||
result[0] |= 1 << 10;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (wordSpacing != null) {
|
||||
if (letterSpacing != null) {
|
||||
result[0] |= 1 << 11;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (height != null) {
|
||||
if (wordSpacing != null) {
|
||||
result[0] |= 1 << 12;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (locale != null) {
|
||||
if (height != null) {
|
||||
result[0] |= 1 << 13;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (background != null) {
|
||||
if (locale != null) {
|
||||
result[0] |= 1 << 14;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (foreground != null) {
|
||||
if (background != null) {
|
||||
result[0] |= 1 << 15;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (shadows != null) {
|
||||
if (foreground != null) {
|
||||
result[0] |= 1 << 16;
|
||||
// Passed separately to native.
|
||||
}
|
||||
if (shadows != null) {
|
||||
result[0] |= 1 << 17;
|
||||
// Passed separately to native.
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -355,6 +359,7 @@ class TextStyle {
|
||||
/// * `decoration`: The decorations to paint near the text (e.g., an underline).
|
||||
/// * `decorationColor`: The color in which to paint the text decorations.
|
||||
/// * `decorationStyle`: The style in which to paint the text decorations (e.g., dashed).
|
||||
/// * `decorationThickness`: The thickness of the decoration as a muliplier on the thickness specified by the font.
|
||||
/// * `fontWeight`: The typeface thickness to use when painting the text (e.g., bold).
|
||||
/// * `fontStyle`: The typeface variant to use when drawing the letters (e.g., italics).
|
||||
/// * `fontFamily`: The name of the font to use when painting the text (e.g., Roboto). If a `fontFamilyFallback` is
|
||||
@ -379,6 +384,7 @@ class TextStyle {
|
||||
TextDecoration decoration,
|
||||
Color decorationColor,
|
||||
TextDecorationStyle decorationStyle,
|
||||
double decorationThickness,
|
||||
FontWeight fontWeight,
|
||||
FontStyle fontStyle,
|
||||
TextBaseline textBaseline,
|
||||
@ -401,6 +407,7 @@ class TextStyle {
|
||||
decoration,
|
||||
decorationColor,
|
||||
decorationStyle,
|
||||
decorationThickness,
|
||||
fontWeight,
|
||||
fontStyle,
|
||||
textBaseline,
|
||||
@ -421,6 +428,7 @@ class TextStyle {
|
||||
_letterSpacing = letterSpacing,
|
||||
_wordSpacing = wordSpacing,
|
||||
_height = height,
|
||||
_decorationThickness = decorationThickness,
|
||||
_locale = locale,
|
||||
_background = background,
|
||||
_foreground = foreground,
|
||||
@ -433,6 +441,7 @@ class TextStyle {
|
||||
final double _letterSpacing;
|
||||
final double _wordSpacing;
|
||||
final double _height;
|
||||
final double _decorationThickness;
|
||||
final Locale _locale;
|
||||
final Paint _background;
|
||||
final Paint _foreground;
|
||||
@ -450,6 +459,7 @@ class TextStyle {
|
||||
_letterSpacing != typedOther._letterSpacing ||
|
||||
_wordSpacing != typedOther._wordSpacing ||
|
||||
_height != typedOther._height ||
|
||||
_decorationThickness != typedOther._decorationThickness ||
|
||||
_locale != typedOther._locale ||
|
||||
_background != typedOther._background ||
|
||||
_foreground != typedOther._foreground)
|
||||
@ -466,31 +476,32 @@ class TextStyle {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, _shadows);
|
||||
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, _shadows, _decorationThickness);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TextStyle('
|
||||
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, '
|
||||
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, '
|
||||
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, '
|
||||
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
|
||||
'fontWeight: ${ _encoded[0] & 0x00020 == 0x00020 ? FontWeight.values[_encoded[5]] : "unspecified"}, '
|
||||
'fontStyle: ${ _encoded[0] & 0x00040 == 0x00040 ? FontStyle.values[_encoded[6]] : "unspecified"}, '
|
||||
'textBaseline: ${ _encoded[0] & 0x00080 == 0x00080 ? TextBaseline.values[_encoded[7]] : "unspecified"}, '
|
||||
'fontFamily: ${ _encoded[0] & 0x00100 == 0x00100
|
||||
&& _fontFamily != null ? _fontFamily : "unspecified"}, '
|
||||
'fontFamilyFallback: ${_encoded[0] & 0x00100 == 0x00100
|
||||
&& _fontFamilyFallback != null
|
||||
&& _fontFamilyFallback.isNotEmpty ? _fontFamilyFallback : "unspecified"}, '
|
||||
'fontSize: ${ _encoded[0] & 0x00200 == 0x00200 ? _fontSize : "unspecified"}, '
|
||||
'letterSpacing: ${ _encoded[0] & 0x00400 == 0x00400 ? "${_letterSpacing}x" : "unspecified"}, '
|
||||
'wordSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_wordSpacing}x" : "unspecified"}, '
|
||||
'height: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_height}x" : "unspecified"}, '
|
||||
'locale: ${ _encoded[0] & 0x02000 == 0x02000 ? _locale : "unspecified"}, '
|
||||
'background: ${ _encoded[0] & 0x04000 == 0x04000 ? _background : "unspecified"}, '
|
||||
'foreground: ${ _encoded[0] & 0x08000 == 0x08000 ? _foreground : "unspecified"}, '
|
||||
'shadows: ${ _encoded[0] & 0x10000 == 0x10000 ? _shadows : "unspecified"}'
|
||||
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, '
|
||||
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, '
|
||||
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, '
|
||||
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
|
||||
'decorationThickness: ${_encoded[0] & 0x00020 == 0x00020 ? _decorationThickness : "unspecified"}, '
|
||||
'fontWeight: ${ _encoded[0] & 0x00040 == 0x00040 ? FontWeight.values[_encoded[5]] : "unspecified"}, '
|
||||
'fontStyle: ${ _encoded[0] & 0x00080 == 0x00080 ? FontStyle.values[_encoded[6]] : "unspecified"}, '
|
||||
'textBaseline: ${ _encoded[0] & 0x00100 == 0x00100 ? TextBaseline.values[_encoded[7]] : "unspecified"}, '
|
||||
'fontFamily: ${ _encoded[0] & 0x00200 == 0x00200
|
||||
&& _fontFamily != null ? _fontFamily : "unspecified"}, '
|
||||
'fontFamilyFallback: ${ _encoded[0] & 0x00200 == 0x00200
|
||||
&& _fontFamilyFallback != null
|
||||
&& _fontFamilyFallback.isNotEmpty ? _fontFamilyFallback : "unspecified"}, '
|
||||
'fontSize: ${ _encoded[0] & 0x00400 == 0x00400 ? _fontSize : "unspecified"}, '
|
||||
'letterSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_letterSpacing}x" : "unspecified"}, '
|
||||
'wordSpacing: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_wordSpacing}x" : "unspecified"}, '
|
||||
'height: ${ _encoded[0] & 0x02000 == 0x02000 ? "${_height}x" : "unspecified"}, '
|
||||
'locale: ${ _encoded[0] & 0x04000 == 0x04000 ? _locale : "unspecified"}, '
|
||||
'background: ${ _encoded[0] & 0x08000 == 0x08000 ? _background : "unspecified"}, '
|
||||
'foreground: ${ _encoded[0] & 0x10000 == 0x10000 ? _foreground : "unspecified"}, '
|
||||
'shadows: ${ _encoded[0] & 0x20000 == 0x20000 ? _shadows : "unspecified"}'
|
||||
')';
|
||||
}
|
||||
}
|
||||
@ -1396,9 +1407,28 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
|
||||
if (style._strutStyle._fontFamilyFallback != null)
|
||||
strutFontFamilies.addAll(style._strutStyle._fontFamilyFallback);
|
||||
}
|
||||
_constructor(style._encoded, style._strutStyle?._encoded, style._fontFamily, strutFontFamilies, style._fontSize, style._height, style._ellipsis, _encodeLocale(style._locale));
|
||||
_constructor(
|
||||
style._encoded,
|
||||
style._strutStyle?._encoded,
|
||||
style._fontFamily,
|
||||
strutFontFamilies,
|
||||
style._fontSize,
|
||||
style._height,
|
||||
style._ellipsis,
|
||||
_encodeLocale(style._locale)
|
||||
);
|
||||
}
|
||||
void _constructor(Int32List encoded, ByteData strutData, String fontFamily, List<dynamic> strutFontFamily, double fontSize, double height, String ellipsis, String locale) native 'ParagraphBuilder_constructor';
|
||||
|
||||
void _constructor(
|
||||
Int32List encoded,
|
||||
ByteData strutData,
|
||||
String fontFamily,
|
||||
List<dynamic> strutFontFamily,
|
||||
double fontSize,
|
||||
double height,
|
||||
String ellipsis,
|
||||
String locale
|
||||
) native 'ParagraphBuilder_constructor';
|
||||
|
||||
/// Applies the given style to the added text until [pop] is called.
|
||||
///
|
||||
@ -1409,9 +1439,38 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
|
||||
fullFontFamilies.add(style._fontFamily);
|
||||
if (style._fontFamilyFallback != null)
|
||||
fullFontFamilies.addAll(style._fontFamilyFallback);
|
||||
_pushStyle(style._encoded, fullFontFamilies, style._fontSize, style._letterSpacing, style._wordSpacing, style._height, _encodeLocale(style._locale), style._background?._objects, style._background?._data, style._foreground?._objects, style._foreground?._data, Shadow._encodeShadows(style._shadows));
|
||||
_pushStyle(
|
||||
style._encoded,
|
||||
fullFontFamilies,
|
||||
style._fontSize,
|
||||
style._letterSpacing,
|
||||
style._wordSpacing,
|
||||
style._height,
|
||||
style._decorationThickness,
|
||||
_encodeLocale(style._locale),
|
||||
style._background?._objects,
|
||||
style._background?._data,
|
||||
style._foreground?._objects,
|
||||
style._foreground?._data,
|
||||
Shadow._encodeShadows(style._shadows)
|
||||
);
|
||||
}
|
||||
void _pushStyle(Int32List encoded, List<dynamic> fontFamilies, double fontSize, double letterSpacing, double wordSpacing, double height, String locale, List<dynamic> backgroundObjects, ByteData backgroundData, List<dynamic> foregroundObjects, ByteData foregroundData, ByteData shadowsData) native 'ParagraphBuilder_pushStyle';
|
||||
|
||||
void _pushStyle(
|
||||
Int32List encoded,
|
||||
List<dynamic> fontFamilies,
|
||||
double fontSize,
|
||||
double letterSpacing,
|
||||
double wordSpacing,
|
||||
double height,
|
||||
double decorationThickness,
|
||||
String locale,
|
||||
List<dynamic> backgroundObjects,
|
||||
ByteData backgroundData,
|
||||
List<dynamic> foregroundObjects,
|
||||
ByteData foregroundData,
|
||||
ByteData shadowsData
|
||||
) native 'ParagraphBuilder_pushStyle';
|
||||
|
||||
static String _encodeLocale(Locale locale) => locale?.toString() ?? '';
|
||||
|
||||
|
||||
@ -33,23 +33,25 @@ const int tsColorIndex = 1;
|
||||
const int tsTextDecorationIndex = 2;
|
||||
const int tsTextDecorationColorIndex = 3;
|
||||
const int tsTextDecorationStyleIndex = 4;
|
||||
const int tsFontWeightIndex = 5;
|
||||
const int tsFontStyleIndex = 6;
|
||||
const int tsTextBaselineIndex = 7;
|
||||
const int tsFontFamilyIndex = 8;
|
||||
const int tsFontSizeIndex = 9;
|
||||
const int tsLetterSpacingIndex = 10;
|
||||
const int tsWordSpacingIndex = 11;
|
||||
const int tsHeightIndex = 12;
|
||||
const int tsLocaleIndex = 13;
|
||||
const int tsBackgroundIndex = 14;
|
||||
const int tsForegroundIndex = 15;
|
||||
const int tsTextShadowsIndex = 16;
|
||||
const int tsTextDecorationThicknessIndex = 5;
|
||||
const int tsFontWeightIndex = 6;
|
||||
const int tsFontStyleIndex = 7;
|
||||
const int tsTextBaselineIndex = 8;
|
||||
const int tsFontFamilyIndex = 9;
|
||||
const int tsFontSizeIndex = 10;
|
||||
const int tsLetterSpacingIndex = 11;
|
||||
const int tsWordSpacingIndex = 12;
|
||||
const int tsHeightIndex = 13;
|
||||
const int tsLocaleIndex = 14;
|
||||
const int tsBackgroundIndex = 15;
|
||||
const int tsForegroundIndex = 16;
|
||||
const int tsTextShadowsIndex = 17;
|
||||
|
||||
const int tsColorMask = 1 << tsColorIndex;
|
||||
const int tsTextDecorationMask = 1 << tsTextDecorationIndex;
|
||||
const int tsTextDecorationColorMask = 1 << tsTextDecorationColorIndex;
|
||||
const int tsTextDecorationStyleMask = 1 << tsTextDecorationStyleIndex;
|
||||
const int tsTextDecorationThicknessMask = 1 << tsTextDecorationThicknessIndex;
|
||||
const int tsFontWeightMask = 1 << tsFontWeightIndex;
|
||||
const int tsFontStyleMask = 1 << tsFontStyleIndex;
|
||||
const int tsTextBaselineMask = 1 << tsTextBaselineIndex;
|
||||
@ -224,11 +226,13 @@ ParagraphBuilder::ParagraphBuilder(
|
||||
int32_t mask = encoded[0];
|
||||
txt::ParagraphStyle style;
|
||||
|
||||
if (mask & psTextAlignMask)
|
||||
if (mask & psTextAlignMask) {
|
||||
style.text_align = txt::TextAlign(encoded[psTextAlignIndex]);
|
||||
}
|
||||
|
||||
if (mask & psTextDirectionMask)
|
||||
if (mask & psTextDirectionMask) {
|
||||
style.text_direction = txt::TextDirection(encoded[psTextDirectionIndex]);
|
||||
}
|
||||
|
||||
if (mask & psFontWeightMask) {
|
||||
style.font_weight =
|
||||
@ -255,14 +259,17 @@ ParagraphBuilder::ParagraphBuilder(
|
||||
decodeStrut(strutData, strutFontFamilies, style);
|
||||
}
|
||||
|
||||
if (mask & psMaxLinesMask)
|
||||
if (mask & psMaxLinesMask) {
|
||||
style.max_lines = encoded[psMaxLinesIndex];
|
||||
}
|
||||
|
||||
if (mask & psEllipsisMask)
|
||||
if (mask & psEllipsisMask) {
|
||||
style.ellipsis = ellipsis;
|
||||
}
|
||||
|
||||
if (mask & psLocaleMask)
|
||||
if (mask & psLocaleMask) {
|
||||
style.locale = locale;
|
||||
}
|
||||
|
||||
FontCollection& font_collection =
|
||||
UIDartState::Current()->window()->client()->GetFontCollection();
|
||||
@ -302,6 +309,7 @@ void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
|
||||
double letterSpacing,
|
||||
double wordSpacing,
|
||||
double height,
|
||||
double decorationThickness,
|
||||
const std::string& locale,
|
||||
Dart_Handle background_objects,
|
||||
Dart_Handle background_data,
|
||||
@ -318,20 +326,27 @@ void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
|
||||
|
||||
// Only change the style property from the previous value if a new explicitly
|
||||
// set value is available
|
||||
if (mask & tsColorMask)
|
||||
if (mask & tsColorMask) {
|
||||
style.color = encoded[tsColorIndex];
|
||||
}
|
||||
|
||||
if (mask & tsTextDecorationMask) {
|
||||
style.decoration =
|
||||
static_cast<txt::TextDecoration>(encoded[tsTextDecorationIndex]);
|
||||
}
|
||||
|
||||
if (mask & tsTextDecorationColorMask)
|
||||
if (mask & tsTextDecorationColorMask) {
|
||||
style.decoration_color = encoded[tsTextDecorationColorIndex];
|
||||
}
|
||||
|
||||
if (mask & tsTextDecorationStyleMask)
|
||||
if (mask & tsTextDecorationStyleMask) {
|
||||
style.decoration_style = static_cast<txt::TextDecorationStyle>(
|
||||
encoded[tsTextDecorationStyleIndex]);
|
||||
}
|
||||
|
||||
if (mask & tsTextDecorationThicknessMask) {
|
||||
style.decoration_thickness_multiplier = decorationThickness;
|
||||
}
|
||||
|
||||
if (mask & tsTextBaselineMask) {
|
||||
// TODO(abarth): Implement TextBaseline. The CSS version of this
|
||||
|
||||
@ -43,6 +43,7 @@ class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
|
||||
double letterSpacing,
|
||||
double wordSpacing,
|
||||
double height,
|
||||
double decorationThickness,
|
||||
const std::string& locale,
|
||||
Dart_Handle background_objects,
|
||||
Dart_Handle background_data,
|
||||
|
||||
17
third_party/txt/tests/paragraph_unittests.cc
vendored
17
third_party/txt/tests/paragraph_unittests.cc
vendored
@ -740,11 +740,13 @@ TEST_F(ParagraphTest, DecorationsParagraph) {
|
||||
TextDecoration::kLineThrough;
|
||||
text_style.decoration_style = txt::TextDecorationStyle::kSolid;
|
||||
text_style.decoration_color = SK_ColorBLACK;
|
||||
text_style.decoration_thickness_multiplier = 2.0;
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText("This text should be");
|
||||
|
||||
text_style.decoration_style = txt::TextDecorationStyle::kDouble;
|
||||
text_style.decoration_color = SK_ColorBLUE;
|
||||
text_style.decoration_thickness_multiplier = 1.0;
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText(" decorated even when");
|
||||
|
||||
@ -755,11 +757,13 @@ TEST_F(ParagraphTest, DecorationsParagraph) {
|
||||
|
||||
text_style.decoration_style = txt::TextDecorationStyle::kDashed;
|
||||
text_style.decoration_color = SK_ColorBLACK;
|
||||
text_style.decoration_thickness_multiplier = 3.0;
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText(" the next line.");
|
||||
|
||||
text_style.decoration_style = txt::TextDecorationStyle::kWavy;
|
||||
text_style.decoration_color = SK_ColorRED;
|
||||
text_style.decoration_thickness_multiplier = 1.0;
|
||||
builder.PushStyle(text_style);
|
||||
|
||||
builder.AddText(" Otherwise, bad things happen.");
|
||||
@ -800,6 +804,19 @@ TEST_F(ParagraphTest, DecorationsParagraph) {
|
||||
ASSERT_EQ(paragraph->records_[3].style().decoration_color, SK_ColorBLACK);
|
||||
ASSERT_EQ(paragraph->records_[4].style().decoration_color, SK_ColorBLACK);
|
||||
ASSERT_EQ(paragraph->records_[5].style().decoration_color, SK_ColorRED);
|
||||
|
||||
ASSERT_EQ(paragraph->records_[0].style().decoration_thickness_multiplier,
|
||||
2.0);
|
||||
ASSERT_EQ(paragraph->records_[1].style().decoration_thickness_multiplier,
|
||||
1.0);
|
||||
ASSERT_EQ(paragraph->records_[2].style().decoration_thickness_multiplier,
|
||||
1.0);
|
||||
ASSERT_EQ(paragraph->records_[3].style().decoration_thickness_multiplier,
|
||||
3.0);
|
||||
ASSERT_EQ(paragraph->records_[4].style().decoration_thickness_multiplier,
|
||||
3.0);
|
||||
ASSERT_EQ(paragraph->records_[5].style().decoration_thickness_multiplier,
|
||||
1.0);
|
||||
}
|
||||
|
||||
TEST_F(ParagraphTest, ItalicsParagraph) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user