diff --git a/examples/codeeditor/codeeditor.cpp b/examples/codeeditor/codeeditor.cpp --- a/examples/codeeditor/codeeditor.cpp +++ b/examples/codeeditor/codeeditor.cpp @@ -192,7 +192,6 @@ auto pal = qApp->palette(); if (theme.isValid()) { pal.setColor(QPalette::Base, theme.editorColor(KSyntaxHighlighting::Theme::BackgroundColor)); - pal.setColor(QPalette::Text, theme.textColor(KSyntaxHighlighting::Theme::Normal)); pal.setColor(QPalette::Highlight, theme.editorColor(KSyntaxHighlighting::Theme::TextSelection)); } setPalette(pal); diff --git a/src/lib/syntaxhighlighter.cpp b/src/lib/syntaxhighlighter.cpp --- a/src/lib/syntaxhighlighter.cpp +++ b/src/lib/syntaxhighlighter.cpp @@ -156,15 +156,15 @@ void SyntaxHighlighter::applyFormat(int offset, int length, const KSyntaxHighlighting::Format& format) { - if (format.isDefaultTextStyle(theme()) || length == 0) + if (length == 0) return; QTextCharFormat tf; - if (format.hasTextColor(theme())) - tf.setForeground(format.textColor(theme())); + // always set the foreground color to avoid palette issues + tf.setForeground(format.textColor(theme())); + if (format.hasBackgroundColor(theme())) tf.setBackground(format.backgroundColor(theme())); - if (format.isBold(theme())) tf.setFontWeight(QFont::Bold); if (format.isItalic(theme()))