@@ -828,30 +828,39 @@ class MathBlock extends StatelessWidget {
828
828
child: SingleChildScrollViewWithScrollbar (
829
829
scrollDirection: Axis .horizontal,
830
830
child: KatexWidget (
831
+ textStyle: ContentTheme .of (context).textStylePlainParagraph,
831
832
nodes: nodes))));
832
833
}
833
834
}
834
835
835
- // Base text style from .katex class in katex.scss :
836
- // https://github.com/KaTeX/KaTeX/blob/613c3da8/src/styles/katex.scss#L13-L15
837
- const kBaseKatexTextStyle = TextStyle (
838
- fontSize: kBaseFontSize * 1.21 ,
839
- fontFamily: 'KaTeX_Main' ,
840
- height: 1.2 ,
841
- fontWeight: FontWeight .normal,
842
- fontStyle: FontStyle .normal,
843
- textBaseline: TextBaseline .alphabetic,
844
- leadingDistribution: TextLeadingDistribution .even,
845
- decoration: TextDecoration .none,
846
- fontFamilyFallback: []);
836
+ /// Creates a base text style for rendering KaTeX content.
837
+ ///
838
+ /// This applies the CSS styles defined in .katex class in katex.scss :
839
+ /// https://github.com/KaTeX/KaTeX/blob/613c3da8/src/styles/katex.scss#L13-L15
840
+ ///
841
+ /// Requires the [style.fontSize] to be non-null.
842
+ TextStyle mkBaseKatexTextStyle (TextStyle style) {
843
+ return style.copyWith (
844
+ fontSize: style.fontSize! * 1.21 ,
845
+ fontFamily: 'KaTeX_Main' ,
846
+ height: 1.2 ,
847
+ fontWeight: FontWeight .normal,
848
+ fontStyle: FontStyle .normal,
849
+ textBaseline: TextBaseline .alphabetic,
850
+ leadingDistribution: TextLeadingDistribution .even,
851
+ decoration: TextDecoration .none,
852
+ fontFamilyFallback: const []);
853
+ }
847
854
848
855
@visibleForTesting
849
856
class KatexWidget extends StatelessWidget {
850
857
const KatexWidget ({
851
858
super .key,
859
+ required this .textStyle,
852
860
required this .nodes,
853
861
});
854
862
863
+ final TextStyle textStyle;
855
864
final List <KatexNode > nodes;
856
865
857
866
@override
@@ -861,7 +870,7 @@ class KatexWidget extends StatelessWidget {
861
870
return Directionality (
862
871
textDirection: TextDirection .ltr,
863
872
child: DefaultTextStyle (
864
- style: kBaseKatexTextStyle .copyWith (
873
+ style: mkBaseKatexTextStyle (textStyle) .copyWith (
865
874
color: ContentTheme .of (context).textStylePlainParagraph.color),
866
875
child: widget));
867
876
}
@@ -1285,7 +1294,7 @@ class _InlineContentBuilder {
1285
1294
: WidgetSpan (
1286
1295
alignment: PlaceholderAlignment .baseline,
1287
1296
baseline: TextBaseline .alphabetic,
1288
- child: KatexWidget (nodes: nodes));
1297
+ child: KatexWidget (textStyle : widget.style, nodes: nodes));
1289
1298
1290
1299
case GlobalTimeNode ():
1291
1300
return WidgetSpan (alignment: PlaceholderAlignment .middle,
0 commit comments