Commit afa85931 authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Kurt Hindenburg
Browse files

Use the results of u_shapeArabic() in TerminalPainter.cpp

Without this shaping results are ignored, so Arabic letters are not
shaped properly.
parent a4681775
Pipeline #223328 passed with stage
in 2 minutes and 49 seconds
......@@ -1490,6 +1490,7 @@ QPair<int, int> TerminalDisplay::getCharacterPosition(const QPoint &widgetPoint,
const int xOffset = edge ? _terminalFont->fontWidth() / 2 : 0;
int line = qBound(0, (widgetPoint.y() - contentsRect().top() - _contentRect.top()) / _terminalFont->fontHeight(), _usedLines - 1);
bool doubleWidth = line < _lineProperties.count() && _lineProperties[line] & LINE_DOUBLEWIDTH;
bool shaped;
int column =
qBound(0, (widgetPoint.x() + xOffset - contentsRect().left() - _contentRect.left()) / _terminalFont->fontWidth() / (doubleWidth ? 2 : 1), columnMax);
......@@ -1502,7 +1503,7 @@ QPair<int, int> TerminalDisplay::getCharacterPosition(const QPoint &widgetPoint,
int32_t vis2line[MAX_LINE_WIDTH];
const int pos = loc(0, line);
QString line;
bidiMap(_image + pos, line, log2line, line2log, shapemap, vis2line, false);
bidiMap(_image + pos, line, log2line, line2log, shapemap, vis2line, shaped, false);
column = line2log[vis2line[column]];
}
......@@ -2929,13 +2930,21 @@ int TerminalDisplay::selectionState() const
return _actSel;
}
int TerminalDisplay::bidiMap(Character *screenline, QString &line, int *log2line, int *line2log, uint16_t *shapemap, int32_t *vis2line, bool shape, bool bidi)
const
int TerminalDisplay::bidiMap(Character *screenline,
QString &line,
int *log2line,
int *line2log,
uint16_t *shapemap,
int32_t *vis2line,
bool &shaped,
bool shape,
bool bidi) const
{
const int linewidth = _usedColumns;
uint64_t notSkipped[MAX_LINE_WIDTH / 64] = {};
int i;
int lastNonSpace = 0;
shaped = false;
for (i = 0; i < linewidth; i++) {
log2line[i] = line.size();
line2log[line.size()] = i;
......@@ -2969,8 +2978,9 @@ int TerminalDisplay::bidiMap(Character *screenline, QString &line, int *log2line
U_SHAPE_AGGREGATE_TASHKEEL_NOOP | U_SHAPE_LENGTH_FIXED_SPACES_NEAR | U_SHAPE_LETTERS_SHAPE,
&errorCode);
for (int i = 0; i < line.length(); i++) {
shapemap[i] = shaped_line[i];
if (line[i] != shaped_line[i]) {
shapemap[i] = shaped_line[i];
shaped = true;
}
}
}
......
......@@ -400,8 +400,15 @@ public:
// Get mapping between visual and logical positions in line
// returns the index of the last non space character.
int bidiMap(Character *screenline, QString &line, int *log2line, int *line2log, uint16_t *shapemap, int32_t *vis2line, bool shape = true, bool bidi = true)
const;
int bidiMap(Character *screenline,
QString &line,
int *log2line,
int *line2log,
uint16_t *shapemap,
int32_t *vis2line,
bool &shaped,
bool shape = true,
bool bidi = true) const;
public Q_SLOTS:
/**
......
......@@ -168,7 +168,8 @@ void TerminalPainter::drawContents(Character *image,
int line2log[MAX_LINE_WIDTH];
uint16_t shapemap[MAX_LINE_WIDTH];
int32_t vis2line[MAX_LINE_WIDTH];
int lastNonSpace = m_parentDisplay->bidiMap(image + pos, line, log2line, line2log, shapemap, vis2line, bidiEnabled, bidiEnabled);
bool shaped;
int lastNonSpace = m_parentDisplay->bidiMap(image + pos, line, log2line, line2log, shapemap, vis2line, shaped, bidiEnabled, bidiEnabled);
const QRect textArea(textScale.inverted().map(QPoint(textX, textY)), QSize(textWidth, textHeight));
if (!printerFriendly) {
drawBelowText(paint,
......@@ -206,7 +207,10 @@ void TerminalPainter::drawContents(Character *image,
continue;
}
const QString unistr = line.mid(log2line[log_x], log2line[log_x + 1] - log2line[log_x]);
QString unistr = line.mid(log2line[log_x], log2line[log_x + 1] - log2line[log_x]);
if (shaped) {
unistr[0] = shapemap[log2line[log_x]];
}
// paint text fragment
if (unistr.length() && unistr[0] != QChar(0)) {
......@@ -994,7 +998,7 @@ void TerminalPainter::drawTextCharacters(QPainter &painter,
y += m_parentDisplay->terminalFont()->lineSpacing() / 2;
}
painter.drawText(rect.x(), y, text);
if (0 && text.toUcs4().length() > 1) {
if (0 && text.toUcs4().length() >= 1) {
fprintf(stderr, " %i ", text.toUcs4().length());
for (int i = 0; i < text.toUcs4().length(); i++) {
fprintf(stderr, " %04x ", text.toUcs4()[i]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment