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

viewertexteditor: Fix incorrect text rendering when pixel aspect ratio not 1 #2084

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions app/node/generator/text/textv3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame, const GenerateJob& job) cons

// Draw rich text onto image
QPainter p(&img);
p.scale(1.0 / frame->video_params().divider(), 1.0 / frame->video_params().divider());
const double par = frame->video_params().pixel_aspect_ratio().toDouble();
Copy link
Collaborator

@ThomasWilshaw ThomasWilshaw Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long explicit names are prefered so something like pixel_aspect_ratio would be better

p.scale(1.0 / frame->video_params().divider() / par, 1.0 / frame->video_params().divider());

QVector2D pos = job.Get(kPositionInput).toVec2();
p.translate(pos.x() - size.x()/2, pos.y() - size.y()/2);
p.translate(frame->video_params().width()/2, frame->video_params().height()/2);
p.translate(frame->video_params().width()/2 * par, frame->video_params().height()/2);
p.setClipRect(0, 0, size.x(), size.y());

switch (static_cast<VerticalAlignment>(job.Get(kVerticalAlignmentInput).toInt())) {
Expand Down