Skip to content

Commit 25b58c0

Browse files
authored
Revert "Support overriding font leading in TextStyle and LibTxt (flutter#6927)" (flutter#7187)
This reverts commit 4b233f0.
1 parent 497c659 commit 25b58c0

File tree

9 files changed

+37
-240
lines changed

9 files changed

+37
-240
lines changed

lib/ui/text.dart

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ Int32List _encodeTextStyle(
256256
double letterSpacing,
257257
double wordSpacing,
258258
double height,
259-
double leading,
260259
Locale locale,
261260
Paint background,
262261
Paint foreground,
@@ -311,24 +310,20 @@ Int32List _encodeTextStyle(
311310
result[0] |= 1 << 12;
312311
// Passed separately to native.
313312
}
314-
if (leading != null) {
315-
result[0] |= 1 << 13;
316-
// Passed separately to native.
317-
}
318313
if (locale != null) {
319-
result[0] |= 1 << 14;
314+
result[0] |= 1 << 13;
320315
// Passed separately to native.
321316
}
322317
if (background != null) {
323-
result[0] |= 1 << 15;
318+
result[0] |= 1 << 14;
324319
// Passed separately to native.
325320
}
326321
if (foreground != null) {
327-
result[0] |= 1 << 16;
322+
result[0] |= 1 << 15;
328323
// Passed separately to native.
329324
}
330325
if (shadows != null) {
331-
result[0] |= 1 << 17;
326+
result[0] |= 1 << 16;
332327
// Passed separately to native.
333328
}
334329
return result;
@@ -349,8 +344,7 @@ class TextStyle {
349344
/// * `letterSpacing`: The amount of space (in logical pixels) to add between each letter.
350345
/// * `wordSpacing`: The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
351346
/// * `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.
352-
/// * `height`: The height of this text span, as a multiple of the sum of font size and leading.
353-
/// * `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.
347+
/// * `height`: The height of this text span, as a multiple of the font size.
354348
/// * `locale`: The locale used to select region-specific glyphs.
355349
/// * `background`: The paint drawn as a background for the text.
356350
/// * `foreground`: The paint used to draw the text. If this is specified, `color` must be null.
@@ -367,7 +361,6 @@ class TextStyle {
367361
double letterSpacing,
368362
double wordSpacing,
369363
double height,
370-
double leading,
371364
Locale locale,
372365
Paint background,
373366
Paint foreground,
@@ -389,7 +382,6 @@ class TextStyle {
389382
letterSpacing,
390383
wordSpacing,
391384
height,
392-
leading,
393385
locale,
394386
background,
395387
foreground,
@@ -400,7 +392,6 @@ class TextStyle {
400392
_letterSpacing = letterSpacing,
401393
_wordSpacing = wordSpacing,
402394
_height = height,
403-
_leading = leading,
404395
_locale = locale,
405396
_background = background,
406397
_foreground = foreground,
@@ -412,7 +403,6 @@ class TextStyle {
412403
final double _letterSpacing;
413404
final double _wordSpacing;
414405
final double _height;
415-
final double _leading;
416406
final Locale _locale;
417407
final Paint _background;
418408
final Paint _foreground;
@@ -430,7 +420,6 @@ class TextStyle {
430420
_letterSpacing != typedOther._letterSpacing ||
431421
_wordSpacing != typedOther._wordSpacing ||
432422
_height != typedOther._height ||
433-
_leading != typedOther._leading ||
434423
_locale != typedOther._locale ||
435424
_background != typedOther._background ||
436425
_foreground != typedOther._foreground)
@@ -445,7 +434,7 @@ class TextStyle {
445434
}
446435

447436
@override
448-
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _letterSpacing, _wordSpacing, _height, _leading, _locale, _background, _foreground);
437+
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground);
449438

450439
@override
451440
String toString() {
@@ -462,11 +451,10 @@ class TextStyle {
462451
'letterSpacing: ${ _encoded[0] & 0x00400 == 0x00400 ? "${_letterSpacing}x" : "unspecified"}, '
463452
'wordSpacing: ${ _encoded[0] & 0x00800 == 0x00800 ? "${_wordSpacing}x" : "unspecified"}, '
464453
'height: ${ _encoded[0] & 0x01000 == 0x01000 ? "${_height}x" : "unspecified"}, '
465-
'leading: ${ _encoded[0] & 0x02000 == 0x02000 ? "${_leading}x" : "unspecified"}, '
466-
'locale: ${ _encoded[0] & 0x04000 == 0x04000 ? _locale : "unspecified"}, '
467-
'background: ${ _encoded[0] & 0x08000 == 0x08000 ? _background : "unspecified"}, '
468-
'foreground: ${ _encoded[0] & 0x10000 == 0x10000 ? _foreground : "unspecified"}, '
469-
'shadows: ${ _encoded[0] & 0x20000 == 0x20000 ? _shadows : "unspecified"}'
454+
'locale: ${ _encoded[0] & 0x02000 == 0x02000 ? _locale : "unspecified"}, '
455+
'background: ${ _encoded[0] & 0x04000 == 0x04000 ? _background : "unspecified"}, '
456+
'foreground: ${ _encoded[0] & 0x08000 == 0x08000 ? _foreground : "unspecified"}, '
457+
'shadows: ${ _encoded[0] & 0x10000 == 0x10000 ? _shadows : "unspecified"}'
470458
')';
471459
}
472460
}
@@ -1147,8 +1135,8 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
11471135
/// Applies the given style to the added text until [pop] is called.
11481136
///
11491137
/// See [pop] for details.
1150-
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));
1151-
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';
1138+
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));
1139+
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';
11521140

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

lib/ui/text/paragraph_builder.cc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ const int tsFontSizeIndex = 9;
4141
const int tsLetterSpacingIndex = 10;
4242
const int tsWordSpacingIndex = 11;
4343
const int tsHeightIndex = 12;
44-
const int tsLeadingIndex = 13;
45-
const int tsLocaleIndex = 14;
46-
const int tsBackgroundIndex = 15;
47-
const int tsForegroundIndex = 16;
48-
const int tsTextShadowsIndex = 17;
44+
const int tsLocaleIndex = 13;
45+
const int tsBackgroundIndex = 14;
46+
const int tsForegroundIndex = 15;
47+
const int tsTextShadowsIndex = 16;
4948

5049
const int tsColorMask = 1 << tsColorIndex;
5150
const int tsTextDecorationMask = 1 << tsTextDecorationIndex;
@@ -59,7 +58,6 @@ const int tsFontSizeMask = 1 << tsFontSizeIndex;
5958
const int tsLetterSpacingMask = 1 << tsLetterSpacingIndex;
6059
const int tsWordSpacingMask = 1 << tsWordSpacingIndex;
6160
const int tsHeightMask = 1 << tsHeightIndex;
62-
const int tsLeadingMask = 1 << tsLeadingIndex;
6361
const int tsLocaleMask = 1 << tsLocaleIndex;
6462
const int tsBackgroundMask = 1 << tsBackgroundIndex;
6563
const int tsForegroundMask = 1 << tsForegroundIndex;
@@ -209,7 +207,6 @@ void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
209207
double letterSpacing,
210208
double wordSpacing,
211209
double height,
212-
double leading,
213210
const std::string& locale,
214211
Dart_Handle background_objects,
215212
Dart_Handle background_data,
@@ -272,11 +269,6 @@ void ParagraphBuilder::pushStyle(tonic::Int32List& encoded,
272269
style.height = height;
273270
}
274271

275-
if (mask & tsLeadingMask) {
276-
style.use_custom_leading = true;
277-
style.leading = leading;
278-
}
279-
280272
if (mask & tsLocaleMask) {
281273
style.locale = locale;
282274
}

lib/ui/text/paragraph_builder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
4040
double letterSpacing,
4141
double wordSpacing,
4242
double height,
43-
double leading,
4443
const std::string& locale,
4544
Dart_Handle background_objects,
4645
Dart_Handle background_data,

third_party/txt/src/txt/paragraph.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,10 @@ void Paragraph::Layout(double width, bool force) {
761761
// TODO(garyq): Multipling in the style.height on the first line is
762762
// probably wrong. Figure out how paragraph and line heights are supposed
763763
// to work and fix it.
764-
double leading =
765-
style.use_custom_leading
766-
? (metrics.fDescent - metrics.fAscent) * style.leading
767-
: metrics.fLeading;
768-
double line_spacing = (line_number == 0)
769-
? -metrics.fAscent * style.height
770-
: (-metrics.fAscent + leading) * style.height;
764+
double line_spacing =
765+
(line_number == 0)
766+
? -metrics.fAscent * style.height
767+
: (-metrics.fAscent + metrics.fLeading) * style.height;
771768
if (line_spacing > max_line_spacing) {
772769
max_line_spacing = line_spacing;
773770
if (line_number == 0) {

third_party/txt/src/txt/paragraph.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,7 @@ class Paragraph {
214214
FRIEND_TEST(ParagraphTest, DecorationsParagraph);
215215
FRIEND_TEST(ParagraphTest, ItalicsParagraph);
216216
FRIEND_TEST(ParagraphTest, ChineseParagraph);
217-
FRIEND_TEST(ParagraphTest, ArabicParagraph);
218-
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideParagraph);
219-
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideTallParagraph);
220-
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideNegativeParagraph);
217+
FRIEND_TEST(ParagraphTest, DISABLED_ArabicParagraph);
221218
FRIEND_TEST(ParagraphTest, SpacingParagraph);
222219
FRIEND_TEST(ParagraphTest, LongWordParagraph);
223220
FRIEND_TEST(ParagraphTest, KernScaleParagraph);

third_party/txt/src/txt/styled_runs.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ class StyledRuns {
7373
FRIEND_TEST(ParagraphTest, DecorationsParagraph);
7474
FRIEND_TEST(ParagraphTest, ItalicsParagraph);
7575
FRIEND_TEST(ParagraphTest, ChineseParagraph);
76-
FRIEND_TEST(ParagraphTest, ArabicParagraph);
77-
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideParagraph);
78-
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideTallParagraph);
79-
FRIEND_TEST(ParagraphTest, ArabicLeadingOverrideNegativeParagraph);
76+
FRIEND_TEST(ParagraphTest, DISABLED_ArabicParagraph);
8077
FRIEND_TEST(ParagraphTest, LongWordParagraph);
8178
FRIEND_TEST(ParagraphTest, KernParagraph);
8279
FRIEND_TEST(ParagraphTest, HyphenBreakParagraph);

third_party/txt/src/txt/text_style.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ bool TextStyle::equals(const TextStyle& other) const {
4747
return false;
4848
if (height != other.height)
4949
return false;
50-
if (use_custom_leading != other.use_custom_leading)
51-
return false;
52-
if (use_custom_leading && leading != other.leading)
53-
return false;
5450
if (locale != other.locale)
5551
return false;
5652
if (foreground != other.foreground)

third_party/txt/src/txt/text_style.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class TextStyle {
4848
double letter_spacing = 0.0;
4949
double word_spacing = 0.0;
5050
double height = 1.0;
51-
double leading = 0;
52-
bool use_custom_leading = false;
5351
std::string locale;
5452
bool has_background = false;
5553
SkPaint background;

0 commit comments

Comments
 (0)