diff --git a/lib/components/code.dart b/lib/components/code.dart index e72ae16..0f3f02e 100644 --- a/lib/components/code.dart +++ b/lib/components/code.dart @@ -67,10 +67,6 @@ class _CodeEditorState extends State { child: IntrinsicWidth( stepWidth: 100, child: TextField( - style: TextStyle( - fontFamily: 'consolas', - fontFamilyFallback: ['Courier New', 'monospace'], - ), controller: _controller, focusNode: _focusNode, maxLines: null, @@ -124,6 +120,20 @@ class _CodeTextEditingController extends TextEditingController { theme: _theme!, ); var result = highlighter.highlight(text); + style = TextStyle( + fontFamily: 'consolas', + fontFamilyFallback: ['Courier New', 'monospace'], + ); + + return setTextSpanFont(result, style); + } + + TextSpan setTextSpanFont(TextSpan span, TextStyle style) { + var result = TextSpan( + style: style.merge(span.style), + children: span.children?.whereType().map((e) => setTextSpanFont(e, style)).toList(), + text: span.text, + ); return result; } }