Unable to change font family
MrCyjaneK opened this issue · comments
I've created a simple function to change all styles to use RobotoMono font in my app:
Map<String, TextStyle> getRobotoMonoFonts(Map<String, TextStyle> theme) {
final Map<String, TextStyle> ret = {};
for (var key in theme.keys) {
ret[key] = theme[key]!.copyWith(fontFamily: "RobotoMono");
}
return ret;
}
and I call it in the following way:
CodeTheme(
data: CodeThemeData(
styles: getRobotoMonoFonts(monokaiSublimeTheme),
),
child: SingleChildScrollView(
child: CodeField(
controller: codeCtrl,
),
),
),
But not every part of code is being updated to monospace. I've also tried manually editing these fields in CodeThemeData: commentStyle, functionStyle, keywordStyle, paramsStyle, quoteStyle, titleStyle, variableStyle
but also without any success on getting the full code to switch to RobotoMono.
Hello, @MrCyjaneK
Please, try to pass a textStyle
parameter to the CodeField
and specify the fontFamily
there.
CodeField(
textStyle: const TextStyle(
fontFamily: 'RobotoMono',
fontSize: 12,
),
)
The text inside of a CodeField
mainly has the style, passed to its constructor. Styles from CodeThemeData
only override the styles for specific text, like comments, keywords, etc.
that.. that solved all my issues. Thanks.