diff --git a/lib/widgets/content.dart b/lib/widgets/content.dart index 92e04ff9f4..f5cf73b0a7 100644 --- a/lib/widgets/content.dart +++ b/lib/widgets/content.dart @@ -245,14 +245,15 @@ class Heading extends StatelessWidget { HeadingLevel.h5 => 1.05, HeadingLevel.h6 => 1.0, }; + final ambientTextStyle = DefaultTextStyle.of(context).style; return Padding( padding: const EdgeInsets.only(top: 15, bottom: 5), child: _buildBlockInlineContainer( - style: TextStyle( - fontSize: kBaseFontSize * emHeight, - height: 1.4, - ) - .merge(weightVariableTextStyle(context, wght: 600)), + style: bolderWghtTextStyle(ambientTextStyle, by: 200) + .merge(TextStyle( + fontSize: kBaseFontSize * emHeight, + height: 1.4, + )), node: node)); } } diff --git a/test/widgets/content_test.dart b/test/widgets/content_test.dart index c44ae088c4..49b2c6f139 100644 --- a/test/widgets/content_test.dart +++ b/test/widgets/content_test.dart @@ -211,6 +211,25 @@ void main() { plainContent('

one

\n

two

\n

three

\n

four

\n
five
')); check(find.byType(Heading).evaluate()).length.equals(5); }); + + testFontWeight('h1 in spoiler header', + expectedWght: 900, + // ```spoiler # h1 + // content + // ``` + content: plainContent( + '
\n' + '

h1

\n' + '
' + + ), + styleFinder: (tester) { + final root = tester.renderObject(find.textContaining('h1')).text; + return mergedStyleOfSubstring(root, 'h1')!; + }, + ); }); group('Spoiler', () { @@ -567,6 +586,21 @@ void main() { ), styleFinder: findWordBold, ); + + testFontWeight('in h1 in spoiler header', + expectedWght: 1000, + // ```spoiler # h1: regular **bold** + // content + // ``` + content: plainContent( + '
\n' + '

h1: regular bold

\n' + '
' + ), + styleFinder: findWordBold, + ); }); testContentSmoke(ContentExample.emphasis);