Skip to content
Merged
Show file tree
Hide file tree
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
51 changes: 19 additions & 32 deletions src/modules/qt/filter_qtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,35 +262,6 @@ static QColor get_qcolor(mlt_properties filter_properties,
return QColor(color.r, color.g, color.b, color.a);
}

static QPen get_qpen(mlt_properties filter_properties,
mlt_properties frame_properties,
int position,
int length)
{
QColor color;
int outline = mlt_properties_get_int(filter_properties, "outline");
QPen pen;

pen.setWidth(outline);
if (outline) {
color = get_qcolor(filter_properties, "olcolour", frame_properties, position, length);
} else {
color = get_qcolor(filter_properties, "bgcolour", frame_properties, position, length);
}
pen.setColor(color);

return pen;
}

static QBrush get_qbrush(mlt_properties filter_properties,
mlt_properties frame_properties,
int position,
int length)
{
QColor color = get_qcolor(filter_properties, "fgcolour", frame_properties, position, length);
return QBrush(color);
}

static void transform_painter(QPainter *painter,
mlt_rect frame_rect,
QRectF path_rect,
Expand Down Expand Up @@ -367,10 +338,26 @@ static void paint_text(QPainter *painter,
int position,
int length)
{
QPen pen = get_qpen(filter_properties, frame_properties, position, length);
painter->setPen(pen);
QBrush brush = get_qbrush(filter_properties, frame_properties, position, length);
// Draw the outline first, and then draw the fill on top of it.
// This avoids the outline encroaching on the text fill.

// Draw the outline if requested
int outline = mlt_properties_get_int(filter_properties, "outline");
if (outline) {
QPen pen;
pen.setWidth(outline);
QColor color = get_qcolor(filter_properties, "olcolour", frame_properties, position, length);
pen.setColor(color);
painter->setPen(pen);
painter->setBrush(Qt::NoBrush); // No brush needed for outline
painter->drawPath(*qpath);
}

// Fill the text area
QColor color = get_qcolor(filter_properties, "fgcolour", frame_properties, position, length);
QBrush brush(color);
painter->setBrush(brush);
painter->setPen(Qt::NoPen); // No pen needed for fill
painter->drawPath(*qpath);
}

Expand Down
17 changes: 12 additions & 5 deletions src/modules/qt/producer_qtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,23 @@ static void generate_qimage(mlt_properties frame_properties)
#endif
);

QPen pen;
pen.setWidth(outline);
// Draw the outline first, and then draw the fill on top of it.
// This avoids the outline encroaching on the text fill.

// Draw the outline if requested
if (outline) {
QPen pen;
pen.setWidth(outline);
pen.setColor(QColor(ol_color.r, ol_color.g, ol_color.b, ol_color.a));
} else {
pen.setColor(QColor(bg_color.r, bg_color.g, bg_color.b, bg_color.a));
painter.setPen(pen);
painter.setBrush(Qt::NoBrush); // No brush needed for outline
painter.drawPath(*qPath);
}
painter.setPen(pen);

// Fill the text area
QBrush brush(QColor(fg_color.r, fg_color.g, fg_color.b, fg_color.a));
painter.setBrush(brush);
painter.setPen(Qt::NoPen); // No pen needed for fill
painter.drawPath(*qPath);
}

Expand Down
Loading