diff --git a/lib/widgets/content.dart b/lib/widgets/content.dart index 9f8b65fef3..9530a03eca 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 f03f692085..056e816feb 100644 --- a/test/widgets/content_test.dart +++ b/test/widgets/content_test.dart @@ -213,6 +213,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', () { @@ -569,6 +588,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);