Skip to content

Commit fb34f00

Browse files
committed
msglist: Handle bold-text setting in code blocks and error-unimplementeds
Code blocks and _errorUnimplemented were setting their own weightVariableTextStyle without passing a BuildContext, which meant the styles didn't condition on the device setting. But weightVariableTextStyle is already applied, in a DefaultTextStyle that wraps the whole message list. (That's because that DefaultTextStyle wants to set a font, kDefaultFontFamily, that's also variable-weight.) So the clobbering ones aren't necessary; remove them. Fixes: #690
1 parent 19ed919 commit fb34f00

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/widgets/content.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -855,15 +855,12 @@ final _kInlineCodeStyle = kMonospaceTextStyle
855855
.merge(TextStyle(
856856
backgroundColor: const HSLColor.fromAHSL(0.04, 0, 0, 0).toColor()));
857857

858+
// Even though [kMonospaceTextStyle] is a variable-weight font,
859+
// it's acceptable to skip [weightVariableTextStyle] here,
860+
// assuming the text gets the effect of [weightVariableTextStyle]
861+
// through inheritance, e.g., from a [DefaultTextStyle].
858862
final _kCodeBlockStyle = kMonospaceTextStyle
859-
.merge(const TextStyle(fontSize: 0.825 * kBaseFontSize))
860-
.merge(
861-
// TODO(a11y) pass a BuildContext, to handle platform request for bold text.
862-
// To get one, the result of this whole computation (to the TextStyle
863-
// we get at the end) could live on one [InheritedWidget], at the
864-
// MessageList or higher, so the computation doesn't get repeated
865-
// frequently. Then consumers can just look it up on the InheritedWidget.
866-
weightVariableTextStyle(null));
863+
.merge(const TextStyle(fontSize: 0.825 * kBaseFontSize));
867864

868865
// const _kInlineCodeLeftBracket = '⸤';
869866
// const _kInlineCodeRightBracket = '⸣';
@@ -1285,6 +1282,9 @@ InlineSpan _errorUnimplemented(UnimplementedNode node) {
12851282
const errorStyle = TextStyle(
12861283
fontSize: kBaseFontSize, fontWeight: FontWeight.bold, color: Colors.red);
12871284

1285+
// Even though [kMonospaceTextStyle] is a variable-weight font,
1286+
// it's acceptable to skip [weightVariableTextStyle] here,
1287+
// assuming the text gets the effect of [weightVariableTextStyle]
1288+
// through inheritance, e.g., from a [DefaultTextStyle].
12881289
final errorCodeStyle = kMonospaceTextStyle
1289-
.merge(const TextStyle(fontSize: kBaseFontSize, color: Colors.red))
1290-
.merge(weightVariableTextStyle(null)); // TODO(a11y) pass a BuildContext
1290+
.merge(const TextStyle(fontSize: kBaseFontSize, color: Colors.red));

0 commit comments

Comments
 (0)