Use fallback font instead of non-ascii font

This commit is contained in:
Roy Qu 2024-02-26 15:15:26 +08:00
parent b3b5affeb8
commit b57bbc34f9
17 changed files with 475 additions and 503 deletions

View File

@ -5285,14 +5285,24 @@ void Editor::applySettings()
codeFolding().indentGuidesColor = pSettings->editor().indentLineColor();
codeFolding().fillIndents = pSettings->editor().fillIndents();
QFont f=QFont(pSettings->editor().fontName());
QStringList fontFamilies{
pSettings->editor().fontName(),
pSettings->editor().fallbackFontName()
};
QFont f=QFont();
f.setFamilies(fontFamilies);
f.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
f.setStyleStrategy(QFont::PreferAntialias);
setFont(f);
QFont f2=QFont(pSettings->editor().nonAsciiFontName());
f2.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
f2.setStyleStrategy(QFont::PreferAntialias);
setFontForNonAscii(f2);
// QFont f=QFont(pSettings->editor().fontName());
// f.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
// f.setStyleStrategy(QFont::PreferAntialias);
// setFont(f);
// QFont f2=QFont(pSettings->editor().nonAsciiFontName());
// f2.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
// f2.setStyleStrategy(QFont::PreferAntialias);
// setFontForNonAscii(f2);
setLineSpacingFactor(pSettings->editor().lineSpacing());
// Set gutter properties

View File

@ -1436,16 +1436,18 @@ void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
if (!clear && e!=nullptr) {
QString msg;
if (e->selAvail()) {
msg = tr("Line: %1 Char: %2 Sel:%3 Lines: %4")
.arg(e->caretY())
.arg(e->caretX())
.arg(e->selText().length())
.arg(e->document()->count());
msg = tr("Line: %1/%2 Char: %3/%4 Sel:%5")
.arg(e->caretY())
.arg(e->document()->count())
.arg(e->caretX())
.arg(e->lineText().length())
.arg(e->selText().length());
} else {
msg = tr("Line: %1 Char: %2 Lines: %3")
.arg(e->caretY())
.arg(e->caretX())
.arg(e->document()->count());
msg = tr("Line: %1/%2 Char: %3/%4")
.arg(e->caretY())
.arg(e->document()->count())
.arg(e->caretX())
.arg(e->lineText().length());
}
mFileInfoStatus->setText(msg);
} else {

View File

@ -667,14 +667,14 @@ void Settings::Editor::setEnableLigaturesSupport(bool newEnableLigaturesSupport)
mEnableLigaturesSupport = newEnableLigaturesSupport;
}
const QString &Settings::Editor::nonAsciiFontName() const
const QString &Settings::Editor::fallbackFontName() const
{
return mNonAsciiFontName;
return mFallbackFontName;
}
void Settings::Editor::setNonAsciiFontName(const QString &newNonAsciiFontName)
void Settings::Editor::setFallbackFontName(const QString &newFontName)
{
mNonAsciiFontName = newNonAsciiFontName;
mFallbackFontName = newFontName;
}
int Settings::Editor::mouseSelectionScrollSpeed() const
@ -1348,7 +1348,7 @@ void Settings::Editor::doSave()
//Font
//font
saveValue("font_name", mFontName);
saveValue("non_ascii_font_name", mNonAsciiFontName);
saveValue("fallback_font_name", mFallbackFontName);
saveValue("font_size", mFontSize);
saveValue("font_only_monospaced", mFontOnlyMonospaced);
saveValue("line_spacing",mLineSpacing);
@ -1491,7 +1491,7 @@ void Settings::Editor::doLoad()
defaultCjkFontName = CJK_MONO_FONT_K;
else if (defaultLocaleName == "zh_CN")
defaultCjkFontName = CJK_MONO_FONT_SC;
mNonAsciiFontName = stringValue("non_ascii_font_name",defaultCjkFontName);
mFallbackFontName = stringValue("fallback_font_name",defaultCjkFontName);
mFontSize = intValue("font_size",12);
mFontOnlyMonospaced = boolValue("font_only_monospaced",true);
mLineSpacing = doubleValue("line_spacing",1.1);

View File

@ -355,8 +355,8 @@ public:
bool enableLigaturesSupport() const;
void setEnableLigaturesSupport(bool newEnableLigaturesSupport);
const QString &nonAsciiFontName() const;
void setNonAsciiFontName(const QString &newNonAsciiFontName);
const QString &fallbackFontName() const;
void setFallbackFontName(const QString &newNonAsciiFontName);
int mouseSelectionScrollSpeed() const;
void setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed);

View File

@ -56,7 +56,7 @@ void EditorFontWidget::doLoad()
//font
ui->chkOnlyMonospacedFonts->setChecked(pSettings->editor().fontOnlyMonospaced());
ui->cbFont->setCurrentFont(QFont(pSettings->editor().fontName()));
ui->cbNonAsciiFont->setCurrentFont(QFont(pSettings->editor().nonAsciiFontName()));
ui->cbFallbackFont->setCurrentFont(QFont(pSettings->editor().fallbackFontName()));
ui->spinFontSize->setValue(pSettings->editor().fontSize());
ui->spinLineSpacing->setValue(pSettings->editor().lineSpacing());
ui->chkLigature->setChecked(pSettings->editor().enableLigaturesSupport());
@ -84,7 +84,7 @@ void EditorFontWidget::doSave()
//font
pSettings->editor().setFontOnlyMonospaced(ui->chkOnlyMonospacedFonts->isChecked());
pSettings->editor().setFontName(ui->cbFont->currentFont().family());
pSettings->editor().setNonAsciiFontName(ui->cbNonAsciiFont->currentFont().family());
pSettings->editor().setFallbackFontName(ui->cbFallbackFont->currentFont().family());
pSettings->editor().setFontSize(ui->spinFontSize->value());
pSettings->editor().setLineSpacing(ui->spinLineSpacing->value());

View File

@ -39,7 +39,7 @@
<number>0</number>
</property>
<item>
<widget class="QFontComboBox" name="cbNonAsciiFont">
<widget class="QFontComboBox" name="cbFallbackFont">
<property name="editable">
<bool>false</bool>
</property>
@ -224,7 +224,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Font for non-ascii Text:</string>
<string>Fallback Font:</string>
</property>
</widget>
</item>

View File

@ -1483,7 +1483,7 @@
</message>
<message>
<source>Font for non-ascii Text:</source>
<translation>Fonte para texto não ASCII:</translation>
<translation type="vanished">Fonte para texto não ASCII:</translation>
</message>
<message>
<source>Gutter</source>
@ -1553,6 +1553,10 @@
<source>Line break</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fallback Font:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditorGeneralWidget</name>
@ -5416,11 +5420,11 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Line: %1 Char: %2 Sel:%3 Lines: %4</source>
<source>Line: %1/%2 Char: %3/%4 Sel:%5</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line: %1 Char: %2 Lines: %3</source>
<source>Line: %1/%2 Char: %3/%4</source>
<translation type="unfinished"></translation>
</message>
</context>

File diff suppressed because it is too large Load Diff

View File

@ -1318,10 +1318,6 @@
<source>Size:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Font for non-ascii Text:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gutter</source>
<translation type="unfinished"></translation>
@ -1390,6 +1386,10 @@
<source>Line break</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fallback Font:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditorGeneralWidget</name>
@ -5129,11 +5129,11 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Line: %1 Char: %2 Sel:%3 Lines: %4</source>
<source>Line: %1/%2 Char: %3/%4 Sel:%5</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line: %1 Char: %2 Lines: %3</source>
<source>Line: %1/%2 Char: %3/%4</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -142,14 +142,15 @@ void CPUDialog::setDisassembly(const QString& file, const QString& funcName,cons
void CPUDialog::resetEditorFont(float dpi)
{
QFont f=QFont(pSettings->editor().fontName());
QFont f=QFont();
f.setFamilies(
QStringList{
pSettings->editor().fontName(),
pSettings->editor().fallbackFontName()});
f.setPixelSize(pointToPixel(pSettings->editor().fontSize(),dpi));
f.setStyleStrategy(QFont::PreferAntialias);
ui->txtCode->setFont(f);
QFont f2=QFont(pSettings->editor().nonAsciiFontName());
f2.setPixelSize(pointToPixel(pSettings->editor().fontSize(),dpi));
f2.setStyleStrategy(QFont::PreferAntialias);
ui->txtCode->setFontForNonAscii(f2);
}
void CPUDialog::sendSyntaxCommand()

View File

@ -33,7 +33,6 @@ namespace QSynedit {
Document::Document(const QFont& font, const QFont& nonAsciiFont, QObject *parent):
QObject(parent),
mFontMetrics(font),
mNonAsciiFontMetrics(nonAsciiFont),
mTabSize(4),
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
mMutex()
@ -591,12 +590,11 @@ const QFontMetrics &Document::fontMetrics() const
return mFontMetrics;
}
void Document::setFontMetrics(const QFont &newFont, const QFont& newNonAsciiFont)
void Document::setFont(const QFont &newFont)
{
mFontMetrics = QFontMetrics(newFont);
mCharWidth = mFontMetrics.horizontalAdvance("M");
mSpaceWidth = mFontMetrics.horizontalAdvance(" ");
mNonAsciiFontMetrics = QFontMetrics(newNonAsciiFont);
invalidateAllLineWidth();
}
@ -896,11 +894,11 @@ int Document::stringWidth(const QString &str, int left) const
return right - left;
}
int Document::stringWidth(const QString &str, int left, const QFontMetrics &asciFontMetrics, const QFontMetrics &nonAsciiFontMetrics)
int Document::stringWidth(const QString &str, int left, const QFontMetrics &fontMetrics)
{
QList<int> glyphStartCharList = calcGlyphStartCharList(str);
int right;
calcGlyphPositionList(str, glyphStartCharList, asciFontMetrics, nonAsciiFontMetrics, left, right);
calcGlyphPositionList(str, glyphStartCharList, fontMetrics, left, right);
return right - left;
}
@ -938,7 +936,7 @@ int Document::glyphWidth(int line, int glyphIdx)
int Document::glyphWidth(const QString &glyph, int left) const
{
return glyphWidth(glyph,left,mFontMetrics, mNonAsciiFontMetrics);
return glyphWidth(glyph,left,mFontMetrics);
}
int Document::charToGlyphIndex(int line, int charIdx)
@ -971,7 +969,7 @@ QList<int> Document::calcLineWidth(const QString &lineText, const QList<int> &gl
return calcGlyphPositionList(lineText,glyphStartCharList,0,width);
}
QList<int> Document::calcGlyphPositionList(const QString &lineText, const QList<int> &glyphStartCharList, const QFontMetrics &fontMetrics, const QFontMetrics &nonAsciiFontMetrics, int left, int &right) const
QList<int> Document::calcGlyphPositionList(const QString &lineText, const QList<int> &glyphStartCharList, const QFontMetrics &fontMetrics, int left, int &right) const
{
right = std::max(0,left);
int start,end;
@ -984,7 +982,7 @@ QList<int> Document::calcGlyphPositionList(const QString &lineText, const QList<
end = lineText.length();
}
QString glyph = lineText.mid(start,end-start);
int gWidth = glyphWidth(glyph, right, fontMetrics, nonAsciiFontMetrics);
int gWidth = glyphWidth(glyph, right, fontMetrics);
glyphPostionList.append(right);
right += gWidth;
}
@ -1157,7 +1155,6 @@ QList<int> Document::calcGlyphPositionList(const QString &lineText, const QList<
{
return calcGlyphPositionList(lineText, glyphStartCharList,
mFontMetrics,
mNonAsciiFontMetrics,
left,right);
}
@ -1720,7 +1717,7 @@ int searchForSegmentIdx(const QList<int> &segList, int minVal, int maxVal, int v
int Document::updateGlyphStartPositionList(
const QString &lineText,
const QList<int> &glyphStartCharList, int startChar, int endChar,
const QFontMetrics &fontMetrics, const QFontMetrics &nonAsciiFontMetrics,
const QFontMetrics &fontMetrics,
QList<int> &glyphStartPositionList, int left, int &right, int &startGlyph, int &endGlyph) const
{
right = std::max(0,left);
@ -1735,7 +1732,7 @@ int Document::updateGlyphStartPositionList(
end = lineText.length();
}
QString glyph = lineText.mid(start,end-start);
int gWidth = glyphWidth(glyph, right, fontMetrics, nonAsciiFontMetrics);
int gWidth = glyphWidth(glyph, right, fontMetrics);
glyphStartPositionList[i] = right;
right += gWidth;
}
@ -1744,19 +1741,16 @@ int Document::updateGlyphStartPositionList(
return right-left;
}
int Document::glyphWidth(const QString &glyph, int left, const QFontMetrics &fontMetrics, const QFontMetrics &nonAsciiFontMetrics) const
int Document::glyphWidth(const QString &glyph, int left, const QFontMetrics &fontMetrics) const
{
int glyphWidth;
if (glyph.length()==1 && glyph[0].unicode()<128) {
QChar ch = glyph[0];
if (ch == '\t') {
glyphWidth = tabWidth() - left % tabWidth();
} else {
glyphWidth = fontMetrics.horizontalAdvance(ch);
//qDebug()<<glyph<<glyphCols<<width<<mCharWidth;
}
if (glyph.length()==0)
return 0;
QChar ch = glyph[0];
if (ch == '\t') {
glyphWidth = tabWidth() - left % tabWidth();
} else {
glyphWidth = nonAsciiFontMetrics.horizontalAdvance(glyph);
glyphWidth = fontMetrics.horizontalAdvance(ch);
//qDebug()<<glyph<<glyphCols<<width<<mCharWidth;
}
return glyphWidth;

View File

@ -443,7 +443,7 @@ public:
*/
int stringWidth(const QString &str, int left) const;
int stringWidth(const QString &str, int left, const QFontMetrics &asciFontMetrics, const QFontMetrics &nonAsciiFontMetrics);
int stringWidth(const QString &str, int left, const QFontMetrics &fontMetrics);
int glyphCount(int line);
/**
@ -523,7 +523,7 @@ public:
const QString& lineText,
const QList<int> &glyphStartCharList,
int startChar, int endChar,
const QFontMetrics &fontMetrics, const QFontMetrics &nonAsciiFontMetrics,
const QFontMetrics &fontMetrics,
QList<int> &glyphStartPositionList,
int left, int &right, int &startGlyph, int &endGlyph) const;
@ -546,7 +546,7 @@ public:
void setTabSize(int newTabSize);
const QFontMetrics &fontMetrics() const;
void setFontMetrics(const QFont &newFont, const QFont& newNonAsciiFont);
void setFont(const QFont &newFont);
public slots:
void invalidateAllLineWidth();
@ -569,14 +569,13 @@ private:
void setLineWidth(int line, const QString& lineText, int newWidth, const QList<int> glyphStartPositionList);
int glyphWidth(const QString& glyph, int left,
const QFontMetrics &fontMetrics, const QFontMetrics &nonAsciiFontMetrics) const;
const QFontMetrics &fontMetrics) const;
int xposToGlyphIndex(int strWidth, QList<int> glyphPositionList, int xpos) const;
int charToGlyphIndex(const QString& str, QList<int> glyphStartCharList, int charPos) const;
QList<int> calcLineWidth(const QString& lineText, const QList<int> &glyphStartCharList, int &width);
QList<int> calcGlyphPositionList(const QString& lineText, const QList<int> &glyphStartCharList,
const QFontMetrics &fontMetrics,
const QFontMetrics &nonAsciiFontMetrics,
int left, int &right) const;
QList<int> calcGlyphPositionList(const QString& lineText, const QList<int> &glyphStartCharList, int left, int &right) const;
QList<int> calcGlyphPositionList(const QString& lineText, int &width) const;
@ -596,7 +595,6 @@ private:
//SynEdit* mEdit;
QFontMetrics mFontMetrics;
QFontMetrics mNonAsciiFontMetrics;
int mTabSize;
int mCharWidth;
int mSpaceWidth;

View File

@ -360,12 +360,11 @@ void QSynEditPainter::paintToken(
int startGlyph,
int endGlyph,
int tokenWidth, int tokenLeft,
int first, int last, bool /*isSelection*/, const QFont& font,
const QFont& fontForNonAscii, bool showGlyphs)
int first, int last,
const QFont& font, bool showGlyphs)
{
bool startPaint;
int nX;
bool lastGlyphAscii = false;
bool fontInited = false;
int tokenRight = tokenWidth+tokenLeft;
@ -401,17 +400,10 @@ void QSynEditPainter::paintToken(
bool drawed = false;
if (mEdit->mOptions.testFlag(eoLigatureSupport)) {
bool tryLigature = false;
bool isAscii = false;
if (glyph.length()==0) {
} else if (glyph.length()==1 && glyph.front().unicode()<=32){
} else if (glyph.length()==1
&& glyph.front().unicode()>32
&& glyph.front().unicode()<128) {
tryLigature = true;
isAscii = true;
} else {
tryLigature = true;
isAscii = false;
}
if (tryLigature) {
QString textToPaint = glyph;
@ -421,32 +413,19 @@ void QSynEditPainter::paintToken(
QString glyph2 = lineText.mid(glyphStart,glyphLen);
// if (!OperatorGlyphs.contains(glyph))
// break;
if (isAscii) {
if ( glyph2.length()!=1
|| glyph2.front().unicode()<=32
|| glyph2.front().unicode()>=128)
break;
} else {
if ( glyph2.length()<1
||
(glyph2.length()==1
&& glyph2.front().unicode()>32
&& glyph2.front().unicode()<128))
break;
}
if ( glyph2.length()<1
||
(glyph2.length()==1
&& glyph2.front().unicode()<32))
break;
i+=1;
glyphWidth += calcSegmentInterval(glyphStartPositionList, tokenRight, i);
textToPaint+=glyph2;
if (tokenWidth + glyphWidth > last )
break;
}
if (!fontInited || lastGlyphAscii!=isAscii) {
if (isAscii) {
mPainter->setFont(font);
} else {
mPainter->setFont(fontForNonAscii);
}
lastGlyphAscii = isAscii;
if (!fontInited) {
mPainter->setFont(font);
fontInited = true;
}
mPainter->drawText(nX,rcToken.bottom()-mPainter->fontMetrics().descent() , textToPaint);
@ -473,19 +452,17 @@ void QSynEditPainter::paintToken(
ch=glyph;
}
if (ch!=" " && ch!="\t") {
if (!fontInited || !lastGlyphAscii) {
if (!fontInited) {
mPainter->setFont(font);
fontInited = true;
lastGlyphAscii = true;
}
mPainter->drawText(nX+padding,rcToken.bottom()-mPainter->fontMetrics().descent() , ch);
}
//qDebug()<<"Drawing"<<glyph<<nX<<glyphWidth;
} else {
if (!fontInited || lastGlyphAscii) {
mPainter->setFont(fontForNonAscii);
if (!fontInited) {
mPainter->setFont(font);
fontInited = true;
lastGlyphAscii = false;
}
mPainter->drawText(nX,rcToken.bottom()-mPainter->fontMetrics().descent() , glyph);
}
@ -606,7 +583,8 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
glyphStartPositionsList,
mTokenAccu.startGlyph,
mTokenAccu.endGlyph,
mTokenAccu.width,mTokenAccu.left,nC1,mLineSelStart,false,mTokenAccu.font,mTokenAccu.nonAsciiFont, mTokenAccu.showSpecialGlyphs);
mTokenAccu.width,mTokenAccu.left,nC1,mLineSelStart,
mTokenAccu.font, mTokenAccu.showSpecialGlyphs);
}
// selected part of the token
setDrawingColors(true);
@ -619,7 +597,8 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
glyphStartPositionsList,
mTokenAccu.startGlyph,
mTokenAccu.endGlyph,
mTokenAccu.width, mTokenAccu.left, nC1Sel, nC2Sel,true,mTokenAccu.font,mTokenAccu.nonAsciiFont, mTokenAccu.showSpecialGlyphs);
mTokenAccu.width, mTokenAccu.left, nC1Sel, nC2Sel,
mTokenAccu.font, mTokenAccu.showSpecialGlyphs);
// second unselected part of the token
if (bU2) {
setDrawingColors(false);
@ -630,7 +609,8 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
glyphStartPositionsList,
mTokenAccu.startGlyph,
mTokenAccu.endGlyph,
mTokenAccu.width, mTokenAccu.left, mLineSelEnd, nC2,false,mTokenAccu.font,mTokenAccu.nonAsciiFont, mTokenAccu.showSpecialGlyphs);
mTokenAccu.width, mTokenAccu.left, mLineSelEnd, nC2,
mTokenAccu.font, mTokenAccu.showSpecialGlyphs);
}
} else {
setDrawingColors(bSel);
@ -641,7 +621,8 @@ void QSynEditPainter::paintHighlightToken(const QString& lineText,
glyphStartPositionsList,
mTokenAccu.startGlyph,
mTokenAccu.endGlyph,
mTokenAccu.width, mTokenAccu.left, nC1, nC2,bSel,mTokenAccu.font,mTokenAccu.nonAsciiFont, mTokenAccu.showSpecialGlyphs);
mTokenAccu.width, mTokenAccu.left, nC1, nC2,
mTokenAccu.font, mTokenAccu.showSpecialGlyphs);
}
}
@ -751,11 +732,6 @@ void QSynEditPainter::addHighlightToken(
mTokenAccu.font.setItalic(style & FontStyle::fsItalic);
mTokenAccu.font.setStrikeOut(style & FontStyle::fsStrikeOut);
mTokenAccu.font.setUnderline(style & FontStyle::fsUnderline);
mTokenAccu.nonAsciiFont = mEdit->fontForNonAscii();
mTokenAccu.nonAsciiFont.setBold(style & FontStyle::fsBold);
mTokenAccu.nonAsciiFont.setItalic(style & FontStyle::fsItalic);
mTokenAccu.nonAsciiFont.setStrikeOut(style & FontStyle::fsStrikeOut);
mTokenAccu.nonAsciiFont.setUnderline(style & FontStyle::fsUnderline);
}
//calculate width of the token ( and update it's glyph start positions )
int tokenRight;
@ -766,7 +742,6 @@ void QSynEditPainter::addHighlightToken(
tokenStartChar,
tokenEndChar,
QFontMetrics(mTokenAccu.font),
QFontMetrics(mTokenAccu.nonAsciiFont),
glyphStartPositionList,
tokenLeft,
tokenRight,
@ -1042,7 +1017,8 @@ void QSynEditPainter::paintLines()
glyphStartPositionsList,
0,
glyphStartCharList.length(),
tokenWidth, 0, mLineSelStart, mLineSelEnd,false,mEdit->font(),mEdit->fontForNonAscii(),false);
tokenWidth, 0, mLineSelStart, mLineSelEnd,
mEdit->font(),false);
setDrawingColors(false);
rcToken.setLeft(std::max(rcLine.left(), fixXValue(mLeft)));
rcToken.setRight(std::min(rcLine.right(), fixXValue(mLineSelStart)));
@ -1052,7 +1028,8 @@ void QSynEditPainter::paintLines()
glyphStartPositionsList,
0,
glyphStartCharList.length(),
tokenWidth, 0, mLeft, mLineSelStart,false,mEdit->font(),mEdit->fontForNonAscii(),false);
tokenWidth, 0, mLeft, mLineSelStart,
mEdit->font(), false);
rcToken.setLeft(std::max(rcLine.left(), fixXValue(mLineSelEnd)));
rcToken.setRight(std::min(rcLine.right(), fixXValue(mRight)));
paintToken(
@ -1061,7 +1038,8 @@ void QSynEditPainter::paintLines()
glyphStartPositionsList,
0,
glyphStartCharList.length(),
tokenWidth, 0, mLineSelEnd, mRight,true, mEdit->font(), mEdit->fontForNonAscii(),false);
tokenWidth, 0, mLineSelEnd, mRight,
mEdit->font(), false);
} else {
setDrawingColors(mIsLineSelected);
paintToken(
@ -1070,7 +1048,8 @@ void QSynEditPainter::paintLines()
glyphStartPositionsList,
0,
glyphStartCharList.length(),
tokenWidth, 0, mLeft, mRight, mIsLineSelected,mEdit->font(),mEdit->fontForNonAscii(),false);
tokenWidth, 0, mLeft, mRight,
mEdit->font(),false);
}
//Paint editingAreaBorders
if (mIsCurrentLine && mEdit->mInputPreeditString.length()>0) {

View File

@ -38,7 +38,6 @@ class QSynEditPainter
QColor background;
FontStyles style;
QFont font;
QFont nonAsciiFont;
bool showSpecialGlyphs;
};
@ -65,7 +64,7 @@ private:
int startGlyph,
int endGlyph,
int tokenWidth, int tokenLeft,
int first, int last, bool isSelection, const QFont& font,
int first, int last,
const QFont& fontForNonAscii, bool showGlyphs);
void paintEditAreas(const EditingAreaList& areaList);
void paintHighlightToken(const QString& lineText,

View File

@ -160,7 +160,6 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent),
setAcceptDrops(true);
setFont(mFontDummy);
setFontForNonAscii(mFontDummy);
}
int QSynEdit::displayLineCount() const
@ -3871,19 +3870,6 @@ void QSynEdit::setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed)
mMouseSelectionScrollSpeed = newMouseSelectionScrollSpeed;
}
const QFont &QSynEdit::fontForNonAscii() const
{
return mFontForNonAscii;
}
void QSynEdit::setFontForNonAscii(const QFont &newFontForNonAscii)
{
mFontForNonAscii = newFontForNonAscii;
mFontForNonAscii.setStyleStrategy(QFont::PreferAntialias);
if (mDocument)
mDocument->setFontMetrics(font(),mFontForNonAscii);
}
const QColor &QSynEdit::backgroundColor() const
{
return mBackgroundColor;
@ -6148,7 +6134,7 @@ bool QSynEdit::event(QEvent *event)
case QEvent::FontChange:
synFontChanged();
if (mDocument)
mDocument->setFontMetrics(font(),mFontForNonAscii);
mDocument->setFont(font());
break;
case QEvent::MouseMove: {
updateMouseCursor();

View File

@ -808,10 +808,6 @@ protected:
public:
QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
// QWidget interface
const QFont &fontForNonAscii() const;
void setFontForNonAscii(const QFont &newFontForNonAscii);
int mouseSelectionScrollSpeed() const;
void setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed);

View File

@ -4288,29 +4288,29 @@
<context>
<name>QSynedit::Document</name>
<message>
<location filename="qsynedit/document.cpp" line="616"/>
<location filename="qsynedit/document.cpp" line="614"/>
<source>Can&apos;t open file &apos;%1&apos; for read!</source>
<translation>&quot;%1&quot;.</translation>
</message>
<message>
<location filename="qsynedit/document.cpp" line="656"/>
<location filename="qsynedit/document.cpp" line="779"/>
<location filename="qsynedit/document.cpp" line="654"/>
<location filename="qsynedit/document.cpp" line="777"/>
<source>Can&apos;t load codec &apos;%1&apos;!</source>
<translation>&quot;%1&quot;!</translation>
</message>
<message>
<location filename="qsynedit/document.cpp" line="675"/>
<location filename="qsynedit/document.cpp" line="673"/>
<source>&apos;%1&apos; is a binaray File!</source>
<oldsource>This is a binaray File!</oldsource>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="qsynedit/document.cpp" line="782"/>
<location filename="qsynedit/document.cpp" line="780"/>
<source>Can&apos;t open file &apos;%1&apos; for save!</source>
<translation>&quot;%1&quot;!</translation>
</message>
<message>
<location filename="qsynedit/document.cpp" line="805"/>
<location filename="qsynedit/document.cpp" line="803"/>
<source>Data not correctly writed to file &apos;%1&apos;.</source>
<translation>&quot;%1&quot;</translation>
</message>
@ -4318,10 +4318,9 @@
<context>
<name>QSynedit::QSynEdit</name>
<message>
<location filename="qsynedit/painter.cpp" line="1019"/>
<source>The syntaxer seems to be in an infinite loop</source>
<oldsource>The highlighter seems to be in an infinite loop</oldsource>
<translation></translation>
<translation type="vanished"></translation>
</message>
</context>
</TS>