fix: tab glyphs not correctly displayed.

This commit is contained in:
Roy Qu 2024-02-28 20:02:11 +08:00
parent 85efc86cde
commit ca79bf6648
3 changed files with 4 additions and 4 deletions

View File

@ -1549,7 +1549,7 @@ void Settings::Editor::doLoad()
mFontName = stringValue("font_name",DEFAULT_MONO_FONT); mFontName = stringValue("font_name",DEFAULT_MONO_FONT);
QString defaultCjkFontName = DEFAULT_MONO_FONT; QString defaultCjkFontName = DEFAULT_MONO_FONT;
QString defaultLocaleName = QLocale::system().name(); QString defaultLocaleName = QLocale::system().name();
bool isZhJa = bool isCNJP =
defaultLocaleName.startsWith("zh_") defaultLocaleName.startsWith("zh_")
|| defaultLocaleName.startsWith("ja_") || defaultLocaleName.startsWith("ja_")
|| defaultLocaleName==("zh") || defaultLocaleName==("zh")
@ -1571,7 +1571,7 @@ void Settings::Editor::doLoad()
mFontSize = intValue("font_size",12); mFontSize = intValue("font_size",12);
mFontOnlyMonospaced = boolValue("font_only_monospaced",true); mFontOnlyMonospaced = boolValue("font_only_monospaced",true);
mLineSpacing = doubleValue("line_spacing",1.1); mLineSpacing = doubleValue("line_spacing",1.1);
mForceFixedFontWidth = boolValue("force_fixed_font_width", isZhJa); mForceFixedFontWidth = boolValue("force_fixed_font_width", isCNJP);
// if (mForceFixedFontWidth) // if (mForceFixedFontWidth)
// mEnableLigaturesSupport = false; // mEnableLigaturesSupport = false;
// else // else

View File

@ -22,6 +22,6 @@ const QSet<QChar> WordBreakChars{'.', ',', ';', ':',
'-', '*', '/', '\\', '|'}; '-', '*', '/', '\\', '|'};
const QChar TabGlyph(0x2192); const QChar TabGlyph(0x2192);
const QChar SpaceGlyph('.'); const QChar SpaceGlyph('.');
const QChar LineBreakGlyph(0x2193); const QChar LineBreakGlyph(0x21A9);
const QChar SoftBreakGlyph(0x2193); const QChar SoftBreakGlyph(0x2193);
} }

View File

@ -426,7 +426,7 @@ void QSynEditPainter::paintToken(
switch(glyph.front().unicode()) { switch(glyph.front().unicode()) {
case '\t': case '\t':
textToPaint=TabGlyph; textToPaint=TabGlyph;
padding=(glyphWidth-1)/2*mEdit->mCharWidth; padding=(glyphWidth-mPainter->fontMetrics().horizontalAdvance(TabGlyph))/2;
break; break;
case ' ': case ' ':
textToPaint=SpaceGlyph; textToPaint=SpaceGlyph;