Skip to content

Commit

Permalink
Subtitles: Minor cleanup of SubtitleScreen:InitializeFonts().
Browse files Browse the repository at this point in the history
Before switching to the Qt font infrastructure, loading fonts was much
more error-prone and needed more checks and logging.  That is largely
unnecessary now.
  • Loading branch information
stichnot committed Apr 13, 2012
1 parent c9208a9 commit 6aa737c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
37 changes: 11 additions & 26 deletions mythtv/libs/libmythtv/subtitlescreen.cpp
Expand Up @@ -368,8 +368,7 @@ void SubtitleScreen::DisplayTextSubtitles(void)
QRect oldsafe = m_safeArea;
m_safeArea = vo->GetSafeRect();
changed = (oldsafe != m_safeArea);
if (!InitializeFonts(changed))
return;
InitializeFonts(changed);
}
else
{
Expand Down Expand Up @@ -455,8 +454,7 @@ void SubtitleScreen::DisplayRawTextSubtitles(void)
QRect oldsafe = m_safeArea;
m_safeArea = vo->GetSafeRect();
changed = (oldsafe != m_safeArea);
if (!InitializeFonts(changed))
return;
InitializeFonts(changed);

// delete old subs that may still be on screen
DeleteAllChildren();
Expand Down Expand Up @@ -620,8 +618,7 @@ void SubtitleScreen::DisplayCC608Subtitles(void)
{
return;
}
if (!InitializeFonts(changed))
return;
InitializeFonts(changed);

CC608Buffer* textlist = m_608reader->GetOutputText(changed);
if (!changed)
Expand Down Expand Up @@ -675,8 +672,7 @@ void SubtitleScreen::DisplayCC708Subtitles(void)
return;
}

if (!InitializeFonts(changed))
return;
InitializeFonts(changed);

for (uint i = 0; i < 8; i++)
{
Expand Down Expand Up @@ -757,31 +753,21 @@ void SubtitleScreen::AddScaledImage(QImage &img, QRect &pos)
}
}

bool SubtitleScreen::InitializeFonts(bool wasResized)
void SubtitleScreen::InitializeFonts(bool wasResized)
{
bool success = true;

if (!m_fontsAreInitialized)
{
LOG(VB_GENERAL, LOG_INFO, "InitializeFonts()");

int count = 0;
foreach(QString font, m_fontNames)
{
MythFontProperties *mythfont = new MythFontProperties();
if (mythfont)
{
QFont newfont(font);
newfont.setStretch(m_fontStretch);
font.detach();
mythfont->SetFace(newfont);
m_fontSet.insert(count, mythfont);
count++;
}
QFont newfont(font);
newfont.setStretch(m_fontStretch);
font.detach();
mythfont->SetFace(newfont);
m_fontSet.insert(count, mythfont);
count++;
}
success = count > 0;
LOG(VB_PLAYBACK, LOG_INFO, LOC +
QString("Loaded %1 CEA-708 fonts").arg(count));
}

if (wasResized || !m_fontsAreInitialized)
Expand All @@ -792,7 +778,6 @@ bool SubtitleScreen::InitializeFonts(bool wasResized)
}

m_fontsAreInitialized = true;
return success;
}

MythFontProperties* SubtitleScreen::Get708Font(CC708CharacterAttribute attr)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/subtitlescreen.h
Expand Up @@ -66,7 +66,7 @@ class SubtitleScreen : public MythScreenType
void DisplayCC708Subtitles(void);
void AddScaledImage(QImage &img, QRect &pos);
void Clear708Cache(int num);
bool InitializeFonts(bool wasResized);
void InitializeFonts(bool wasResized);
MythFontProperties* Get708Font(CC708CharacterAttribute attr) const;
void SetFontSizes(int nSmall, int nMedium, int nLarge);

Expand Down

0 comments on commit 6aa737c

Please sign in to comment.