commit 946b81acbe5d02fda902d86e7da5d860f71ad651
Author: Gregorio Gervasio, Jr <ggervasio@yahoo.com>
Date: Sat Mar 3 15:12:53 2012 -0800
Modified to scale CC608 region according to text zoom setting.
diff --git a/mythtv/libs/libmythtv/subtitlescreen.cpp b/mythtv/libs/libmythtv/subtitlescreen.cpp
index c092e67..147adbd 100644
|
a
|
b
|
void SubtitleScreen::DisplayCC608Subtitles(void)
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | FormattedTextSubtitle fsub(m_safeArea, m_useBackground, this); |
| 646 | | fsub.InitFromCC608(textlist->buffers); |
| | 646 | fsub.InitFromCC608(textlist->buffers, m_textFontZoom); |
| 647 | 647 | fsub.Layout608(); |
| 648 | 648 | fsub.Layout(); |
| 649 | 649 | m_refreshArea = fsub.Draw() || m_refreshArea; |
| … |
… |
static QString srtColorString(QColor color)
|
| 845 | 845 | .arg(color.blue(), 2, 16, QLatin1Char('0')); |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | | void FormattedTextSubtitle::InitFromCC608(vector<CC608Text*> &buffers) |
| | 848 | void FormattedTextSubtitle::InitFromCC608(vector<CC608Text*> &buffers, int textFontZoom) |
| 849 | 849 | { |
| 850 | 850 | static const QColor clr[8] = |
| 851 | 851 | { |
| … |
… |
void FormattedTextSubtitle::InitFromCC608(vector<CC608Text*> &buffers)
|
| 858 | 858 | vector<CC608Text*>::iterator i = buffers.begin(); |
| 859 | 859 | bool teletextmode = (*i)->teletextmode; |
| 860 | 860 | bool useBackground = m_useBackground && !teletextmode; |
| 861 | | //int xscale = teletextmode ? 40 : 36; |
| | 861 | |
| | 862 | int xscale = teletextmode ? 40 : 36; |
| 862 | 863 | int yscale = teletextmode ? 25 : 17; |
| 863 | | int pixelSize = m_safeArea.height() / (yscale * LINE_SPACING) * |
| 864 | | (parent ? parent->m_textFontZoom : 100) / 100; |
| | 864 | int pixelSize = m_safeArea.height() * textFontZoom |
| | 865 | / (yscale * LINE_SPACING * 100); |
| | 866 | int fontwidth = 0; |
| | 867 | int xmid = 0; |
| | 868 | int yoffset = 0; |
| 865 | 869 | if (parent) |
| | 870 | { |
| 866 | 871 | parent->SetFontSizes(pixelSize, pixelSize, pixelSize); |
| | 872 | CC708CharacterAttribute def_attr(false, false, false, clr[0], useBackground); |
| | 873 | QFont *font = parent->Get708Font(def_attr)->GetFace(); |
| | 874 | QFontMetrics fm(*font); |
| | 875 | fontwidth = fm.averageCharWidth(); |
| | 876 | xmid = m_safeArea.width()/2; |
| | 877 | } |
| | 878 | LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("xmid = %1, fontwidth = %4"). |
| | 879 | arg(xmid).arg(fontwidth)); |
| | 880 | |
| | 881 | int rows, cols; |
| | 882 | if (teletextmode) |
| | 883 | { |
| | 884 | // teletext expects a 24 row / 40 char grid |
| | 885 | rows = 24+1; |
| | 886 | cols = 40; |
| | 887 | } |
| | 888 | else |
| | 889 | { |
| | 890 | // CC has 15 rows, 32 columns |
| | 891 | // - add one row top and bottom for margin |
| | 892 | rows = 15+2; |
| | 893 | cols = 32; |
| | 894 | } |
| 867 | 895 | |
| 868 | 896 | for (; i != buffers.end(); ++i) |
| 869 | 897 | { |
| … |
… |
void FormattedTextSubtitle::InitFromCC608(vector<CC608Text*> &buffers)
|
| 873 | 901 | const bool isBold = false; |
| 874 | 902 | QString text(cc->text); |
| 875 | 903 | |
| 876 | | int orig_x = teletextmode ? cc->y : (cc->x + 3); |
| | 904 | int orig_x = teletextmode ? cc->y : cc->x; |
| | 905 | // position as if we use a fixed size font |
| | 906 | // - font size already has zoom factor applied |
| | 907 | |
| | 908 | int x; |
| | 909 | if (xmid) |
| | 910 | // center horizontally |
| | 911 | x = xmid + (orig_x - cols/2) * fontwidth; |
| | 912 | else |
| | 913 | // fallback |
| | 914 | x = (orig_x + 3) * m_safeArea.width() / xscale; |
| | 915 | |
| 877 | 916 | int orig_y = teletextmode ? cc->x : cc->y; |
| 878 | | int y = (int)(((float)orig_y / (float)yscale) * |
| 879 | | (float)m_safeArea.height()); |
| 880 | | FormattedTextLine line(0, y, orig_x, orig_y); |
| 881 | | // Indented lines are handled as initial strings of space |
| 882 | | // characters, to improve vertical alignment. Monospace fonts |
| 883 | | // are assumed. |
| 884 | | if (orig_x > 0) |
| 885 | | { |
| 886 | | CC708CharacterAttribute attr(false, false, false, |
| 887 | | Qt::white, useBackground); |
| 888 | | FormattedTextChunk chunk(QString(orig_x, ' '), attr, parent); |
| 889 | | line.chunks += chunk; |
| 890 | | } |
| | 917 | int y; |
| | 918 | if (orig_y < rows/2) |
| | 919 | // top half -- anchor up |
| | 920 | y = yoffset + (orig_y * m_safeArea.height() * textFontZoom |
| | 921 | / (rows * 100)); |
| | 922 | else |
| | 923 | // bottom half -- anchor down |
| | 924 | y = yoffset + m_safeArea.height() |
| | 925 | - ((rows - orig_y) * m_safeArea.height() * textFontZoom |
| | 926 | / (rows * 100)); |
| | 927 | |
| | 928 | FormattedTextLine line(x, y, orig_x, orig_y); |
| 891 | 929 | while (!text.isNull()) |
| 892 | 930 | { |
| 893 | 931 | QString captionText = |
diff --git a/mythtv/libs/libmythtv/subtitlescreen.h b/mythtv/libs/libmythtv/subtitlescreen.h
index 0ab77a3..44b3f6a 100644
|
a
|
b
|
class FormattedTextSubtitle
|
| 184 | 184 | m_xAnchor = 0; |
| 185 | 185 | m_yAnchor = 0; |
| 186 | 186 | } |
| 187 | | void InitFromCC608(vector<CC608Text*> &buffers); |
| | 187 | void InitFromCC608(vector<CC608Text*> &buffers, int textFontZoom = 100); |
| 188 | 188 | void InitFromCC708(const CC708Window &win, int num, |
| 189 | 189 | const vector<CC708String*> &list, |
| 190 | 190 | float aspect = 1.77777f, |