Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ Int32List _encodeTextStyle(
double letterSpacing,
double wordSpacing,
double height,
double leading,
Locale locale,
Paint background,
Paint foreground,
Expand Down Expand Up @@ -311,24 +310,20 @@ Int32List _encodeTextStyle(
result[0] |= 1 << 12;
// Passed separately to native.
}
if (leading != null) {
result[0] |= 1 << 13;
// Passed separately to native.
}
if (locale != null) {
result[0] |= 1 << 14;
result[0] |= 1 << 13;
// Passed separately to native.
}
if (background != null) {
result[0] |= 1 << 15;
result[0] |= 1 << 14;
// Passed separately to native.
}
if (foreground != null) {
result[0] |= 1 << 16;
result[0] |= 1 << 15;
// Passed separately to native.
}
if (shadows != null) {
result[0] |= 1 << 17;
result[0] |= 1 << 16;
// Passed separately to native.
}
return result;
Expand All @@ -349,8 +344,7 @@ class TextStyle {
/// * `letterSpacing`: The amount of space (in logical pixels) to add between each letter.
/// * `wordSpacing`: The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
/// * `textBaseline`: The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.
/// * `height`: The height of this text span, as a multiple of the sum of font size and leading.
/// * `leading`: Custom leading to use instead of the font-provided leading as a multiple of font size. When null, default font leading will be used. Leading is the additional spacing between lines.
/// * `height`: The height of this text span, as a multiple of the font size.
/// * `locale`: The locale used to select region-specific glyphs.
/// * `background`: The paint drawn as a background for the text.
/// * `foreground`: The paint used to draw the text. If this is specified, `color` must be null.
Expand All @@ -367,7 +361,6 @@ class TextStyle {
double letterSpacing,
double wordSpacing,
double height,
double leading,
Locale locale,
Paint background,
Paint foreground,
Expand All @@ -389,7 +382,6 @@ class TextStyle {
letterSpacing,
wordSpacing,
height,
leading,
locale,
background,
foreground,
Expand All @@ -400,7 +392,6 @@ class TextStyle {
_letterSpacing = letterSpacing,
_wordSpacing = wordSpacing,
_height = height,
_leading = leading,
_locale = locale,
_background = background,
_foreground = foreground,
Expand All @@ -412,7 +403,6 @@ class TextStyle {
final double _letterSpacing;
final double _wordSpacing;
final double _height;
final double _leading;
final Locale _locale;
final Paint _background;
final Paint _foreground;
Expand All @@ -430,7 +420,6 @@ class TextStyle {
_letterSpacing != typedOther._letterSpacing ||
_wordSpacing != typedOther._wordSpacing ||
_height != typedOther._height ||
_leading != typedOther._leading ||
_locale != typedOther._locale ||
_background != typedOther._background ||
_foreground != typedOther._foreground)
Expand All @@ -445,7 +434,7 @@ class TextStyle {
}

@override
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _letterSpacing, _wordSpacing, _height, _leading, _locale, _background, _foreground);
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground);

@override
String toString() {
Expand All @@ -462,11 +451,10 @@ class TextStyle {
'letterSpacing: ${ _encoded[0] & 0x00400 == 0x00400 ? "${_letterSpacing}x" : "unspecified"}, '
'wordSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_wordSpacing}x" : "unspecified"}, '
'height: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_height}x" : "unspecified"}, '
'leading: ${ _encoded[0] & 0x02000 == 0x02000 ? "${_leading}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"}'
'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"}'
')';
}
}
Expand Down Expand Up @@ -1147,8 +1135,8 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
/// Applies the given style to the added text until [pop] is called.
///
/// See [pop] for details.
void pushStyle(TextStyle style) => _pushStyle(style._encoded, style._fontFamily, style._fontSize, style._letterSpacing, style._wordSpacing, style._height, style._leading, _encodeLocale(style._locale), style._background?._objects, style._background?._data, style._foreground?._objects, style._foreground?._data, Shadow._encodeShadows(style._shadows));
void _pushStyle(Int32List encoded, String fontFamily, double fontSize, double letterSpacing, double wordSpacing, double height, double leading, String locale, List<dynamic> backgroundObjects, ByteData backgroundData, List<dynamic> foregroundObjects, ByteData foregroundData, ByteData shadowsData) native 'ParagraphBuilder_pushStyle';
void pushStyle(TextStyle style) => _pushStyle(style._encoded, style._fontFamily, 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));
void _pushStyle(Int32List encoded, String fontFamily, 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';

static String _encodeLocale(Locale locale) => locale?.toString() ?? '';

Expand Down
16 changes: 4 additions & 12 deletions lib/ui/text/paragraph_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ const int tsFontSizeIndex = 9;
const int tsLetterSpacingIndex = 10;
const int tsWordSpacingIndex = 11;
const int tsHeightIndex = 12;
const int tsLeadingIndex = 13;
const int tsLocaleIndex = 14;
const int tsBackgroundIndex = 15;
const int tsForegroundIndex = 16;
const int tsTextShadowsIndex = 17;
const int tsLocaleIndex = 13;
const int tsBackgroundIndex = 14;
const int tsForegroundIndex = 15;
const int tsTextShadowsIndex = 16;

const int tsColorMask = 1 << tsColorIndex;
const int tsTextDecorationMask = 1 << tsTextDecorationIndex;
Expand All @@ -59,7 +58,6 @@ const int tsFontSizeMask = 1 << tsFontSizeIndex;
const int tsLetterSpacingMask = 1 << tsLetterSpacingIndex;
const int tsWordSpacingMask = 1 << tsWordSpacingIndex;
const int tsHeightMask = 1 << tsHeightIndex;
const int tsLeadingMask = 1 << tsLeadingIndex;
const int tsLocaleMask = 1 << tsLocaleIndex;
const int tsBackgroundMask = 1 << tsBackgroundIndex;
const int tsForegroundMask = 1 << tsForegroundIndex;
Expand Down Expand Up @@ -209,7 +207,6 @@ void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
double letterSpacing,
double wordSpacing,
double height,
double leading,
const std::string& locale,
Dart_Handle background_objects,
Dart_Handle background_data,
Expand Down Expand Up @@ -272,11 +269,6 @@ void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
style.height = height;
}

if (mask & tsLeadingMask) {
style.use_custom_leading = true;
style.leading = leading;
}

if (mask & tsLocaleMask) {
style.locale = locale;
}
Expand Down
1 change: 0 additions & 1 deletion lib/ui/text/paragraph_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
double letterSpacing,
double wordSpacing,
double height,
double leading,
const std::string& locale,
Dart_Handle background_objects,
Dart_Handle background_data,
Expand Down
11 changes: 4 additions & 7 deletions third_party/txt/src/txt/paragraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -761,13 +761,10 @@ void Paragraph::Layout(double width, bool force) {
// TODO(garyq): Multipling in the style.height on the first line is
// probably wrong. Figure out how paragraph and line heights are supposed
// to work and fix it.
double leading =
style.use_custom_leading
? (metrics.fDescent - metrics.fAscent) * style.leading
: metrics.fLeading;
double line_spacing = (line_number == 0)
? -metrics.fAscent * style.height
: (-metrics.fAscent + leading) * style.height;
double line_spacing =
(line_number == 0)
? -metrics.fAscent * style.height
: (-metrics.fAscent + metrics.fLeading) * style.height;
if (line_spacing > max_line_spacing) {
max_line_spacing = line_spacing;
if (line_number == 0) {
Expand Down
5 changes: 1 addition & 4 deletions third_party/txt/src/txt/paragraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ class Paragraph {
FRIEND_TEST(ParagraphTest, DecorationsParagraph);
FRIEND_TEST(ParagraphTest, ItalicsParagraph);
FRIEND_TEST(ParagraphTest, ChineseParagraph);
FRIEND_TEST(ParagraphTest, ArabicParagraph);
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideParagraph);
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideTallParagraph);
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideNegativeParagraph);
FRIEND_TEST(ParagraphTest, DISABLED_ArabicParagraph);
FRIEND_TEST(ParagraphTest, SpacingParagraph);
FRIEND_TEST(ParagraphTest, LongWordParagraph);
FRIEND_TEST(ParagraphTest, KernScaleParagraph);
Expand Down
5 changes: 1 addition & 4 deletions third_party/txt/src/txt/styled_runs.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ class StyledRuns {
FRIEND_TEST(ParagraphTest, DecorationsParagraph);
FRIEND_TEST(ParagraphTest, ItalicsParagraph);
FRIEND_TEST(ParagraphTest, ChineseParagraph);
FRIEND_TEST(ParagraphTest, ArabicParagraph);
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideParagraph);
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideTallParagraph);
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideNegativeParagraph);
FRIEND_TEST(ParagraphTest, DISABLED_ArabicParagraph);
FRIEND_TEST(ParagraphTest, LongWordParagraph);
FRIEND_TEST(ParagraphTest, KernParagraph);
FRIEND_TEST(ParagraphTest, HyphenBreakParagraph);
Expand Down
4 changes: 0 additions & 4 deletions third_party/txt/src/txt/text_style.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ bool TextStyle::equals(const TextStyle& other) const {
return false;
if (height != other.height)
return false;
if (use_custom_leading != other.use_custom_leading)
return false;
if (use_custom_leading && leading != other.leading)
return false;
if (locale != other.locale)
return false;
if (foreground != other.foreground)
Expand Down
2 changes: 0 additions & 2 deletions third_party/txt/src/txt/text_style.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class TextStyle {
double letter_spacing = 0.0;
double word_spacing = 0.0;
double height = 1.0;
double leading = 0;
bool use_custom_leading = false;
std::string locale;
bool has_background = false;
SkPaint background;
Expand Down
Loading