Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set setWeight=QFont::Bold for wrappingArrow … #3412

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 37 additions & 35 deletions src/qcodeedit/lib/widgets/qlinenumberpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,39 +128,39 @@ bool QLineNumberPanel::paint(QPainter *p, QEditor *e)

QFont f(e->document()->font());
f.setWeight(QFont::Bold);
const QFontMetricsF sfm(f);
bool specialFontUsage=false;
QFont specialFont(font());
const QFontMetricsF sfm(f);
bool specialFontUsage=false;
QFont specialFont(font());

#ifndef WIN32
#ifndef WIN32
static const QChar wrappingArrow(0x2937);
const QFontMetricsF specialSfm(sfm);
const QFontMetricsF specialSfm(sfm);
#if defined Q_OS_MAC
if(!specialSfm.inFont(wrappingArrow)){
specialFontUsage=true;
specialFont.setFamily("Gothic Regular");
//specialSfm(specialFont);
}
if(!specialSfm.inFont(wrappingArrow)){
specialFontUsage=true;
specialFont.setFamily("Gothic Regular");
//specialSfm(specialFont);
}
#endif
#else
#else
// 0xC4 gives a decent wrapping arrow in Wingdings fonts, availables on all windows systems
// this is a hackish fallback to workaround Windows issues with Unicode...
static const QChar wrappingArrow(0xC4);
specialFont.setFamily("Wingdings");
const QFontMetricsF specialSfm(specialFont);
const QFontMetricsF specialSfm(specialFont);
specialFontUsage=true;
#endif
#endif

int max = e->document()->lines();
if(max<100) max=100; // always reserve 3 line number columns to avoid ugly jumping of width
QString s_width=QString::number(max);
s_width.fill('6');
const qreal panelWidth = UtilsUi::getFmWidth(sfm, s_width) + 5;
const qreal panelWidth = UtilsUi::getFmWidth(sfm, s_width) + 5;
setFixedWidth(panelWidth);

int n;
qreal posY,
as = QFontMetricsF(e->document()->font()).ascent(),
int n;
qreal posY,
as = QFontMetricsF(e->document()->font()).ascent(),
ls = e->document()->getLineSpacing(),
pageBottom = e->viewport()->height(),
contentsY = e->verticalOffset();
Expand Down Expand Up @@ -203,37 +203,39 @@ bool QLineNumberPanel::paint(QPainter *p, QEditor *e)

p->save();
f.setWeight(QFont::Bold);

p->setFont(f);
}

if ( draw )
{
p->drawText(QPointF(width() - 2 - UtilsUi::getFmWidth(sfm, txt),
posY),
txt);
if(specialFontUsage){
if (line.lineSpan()>1) {
p->save();
specialFont.setBold(n == cursorLine); //todo: only get bold on the current wrapped line
p->setFont(specialFont);
}
}
p->drawText(QPointF(width() - 2 - UtilsUi::getFmWidth(sfm, txt),
posY),
txt);
if (line.lineSpan()>1) {
p->save();
if(specialFontUsage){
specialFont.setBold(n == cursorLine); //todo: only get bold on the current wrapped line
p->setFont(specialFont);
} else {
f.setWeight(QFont::Normal);
p->setFont(f);
}
}

for ( int i = 1; i < line.lineSpan(); ++i )
p->drawText(QPointF(width() - 2 - UtilsUi::getFmWidth(specialSfm, wrappingArrow), posY + i * ls), wrappingArrow);
p->drawText(QPointF(width() - 2 - UtilsUi::getFmWidth(specialSfm, wrappingArrow), posY + i * ls), wrappingArrow);

if(specialFontUsage){
if (line.lineSpan()>1)
p->restore();
}
// if(specialFontUsage){
if (line.lineSpan()>1)
p->restore();
// }
} else {
int yOff = posY - (as + 1) + ls / 2;

if ( (n + 1) % 5 )
p->drawPoint(QPointF(width() - 5, yOff));
p->drawPoint(QPointF(width() - 5, yOff));
else
p->drawLine(QPointF(width() - 7, yOff), QPointF(width() - 2, yOff));
p->drawLine(QPointF(width() - 7, yOff), QPointF(width() - 2, yOff));
}

if ( n == cursorLine )
Expand Down