diff --git a/src/effects/Caption.cpp b/src/effects/Caption.cpp index 831ed64a..c5182762 100644 --- a/src/effects/Caption.cpp +++ b/src/effects/Caption.cpp @@ -27,7 +27,7 @@ using namespace openshot; /// Blank constructor, useful when using Json to load the effect properties -Caption::Caption() : color("#ffffff"), stroke("#a9a9a9"), background("#ff000000"), background_alpha(0.0), left(0.1), top(0.70), right(0.1), +Caption::Caption() : color("#ffffff"), stroke("#a9a9a9"), background("#ff000000"), background_alpha(0.0), left(0.1), top(0.72), right(0.1), stroke_width(0.5), font_size(20.0), font_alpha(1.0), is_dirty(true), font_name("sans"), font(NULL), metrics(NULL), fade_in(0.35), fade_out(0.35), background_corner(10.0), background_padding(20.0), line_spacing(1.0) { @@ -37,9 +37,10 @@ Caption::Caption() : color("#ffffff"), stroke("#a9a9a9"), background("#ff000000" // Default constructor Caption::Caption(std::string captions) : - color("#ffffff"), caption_text(captions), stroke("#a9a9a9"), background("#ff000000"), background_alpha(0.0), - left(0.1), top(0.70), right(0.1), stroke_width(0.5), font_size(20.0), font_alpha(1.0), is_dirty(true), font_name("sans"), - font(NULL), metrics(NULL), fade_in(0.35), fade_out(0.35), background_corner(10.0), background_padding(20.0), line_spacing(1.0) + color("#ffffff"), stroke("#a9a9a9"), background("#ff000000"), background_alpha(0.0), left(0.1), top(0.72), right(0.1), + stroke_width(0.5), font_size(20.0), font_alpha(1.0), is_dirty(true), font_name("sans"), font(NULL), metrics(NULL), + fade_in(0.35), fade_out(0.35), background_corner(10.0), background_padding(20.0), line_spacing(1.0), + caption_text(captions) { // Init effect properties init_effect_details(); @@ -116,7 +117,7 @@ std::shared_ptr Caption::GetFrame(std::shared_ptrParentTimeline() != NULL) { timeline = (Timeline*) clip->ParentTimeline(); } else if (this->ParentTimeline() != NULL) { @@ -125,19 +126,18 @@ std::shared_ptr Caption::GetFrame(std::shared_ptrinfo.fps.num; - fps.den = timeline->info.fps.den; - // preview window is sometimes smaller/larger than the timeline size - scale_factor = (double) timeline->preview_width / (double) timeline->info.width; + fps = timeline->info.fps; } else if (clip != NULL && clip->Reader() != NULL) { - fps.num = clip->Reader()->info.fps.num; - fps.den = clip->Reader()->info.fps.den; - scale_factor = 1.0; + fps = clip->Reader()->info.fps; } // Get the frame's image std::shared_ptr frame_image = frame->GetImage(); + // Calculate scale factor, to keep different resolutions from + // having dramatically different font sizes + double timeline_scale_factor = frame->GetImage()->width() / 1280.0; + // Load timeline's new frame image into a QPainter QPainter painter(frame_image.get()); painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing, true); @@ -146,7 +146,7 @@ std::shared_ptr Caption::GetFrame(std::shared_ptr Caption::GetFrame(std::shared_ptr