From b3c2fabf161ba66a1ebe62d37fe94e3ef8e92eec Mon Sep 17 00:00:00 2001 From: cybersphinx Date: Fri, 13 May 2011 15:14:19 +0200 Subject: [PATCH] Scale the video subtitle font with the resolution used. --- lib/framework/wzapp.cpp | 5 +++++ lib/framework/wzapp.h | 2 +- lib/ivis_opengl/textdraw.h | 5 +++-- src/seqdisp.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/framework/wzapp.cpp b/lib/framework/wzapp.cpp index 5286443cb..87ed084c4 100644 --- a/lib/framework/wzapp.cpp +++ b/lib/framework/wzapp.cpp @@ -232,6 +232,9 @@ void WzMainWindow::resizeGL(int width, int height) screenWidth = width; screenHeight = height; + scaledFont.setFamily("DejaVu Sans"); + scaledFont.setPixelSize(12 * height / 480); + glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glPushMatrix(); @@ -293,6 +296,8 @@ void WzMainWindow::setFontType(enum iV_fonts fontID) case font_small: setFont(smallFont); break; + case font_scaled: + setFont(scaledFont); default: break; } diff --git a/lib/framework/wzapp.h b/lib/framework/wzapp.h index 3aa744cee..491c877ef 100644 --- a/lib/framework/wzapp.h +++ b/lib/framework/wzapp.h @@ -71,7 +71,7 @@ private: QCursor *cursors[CURSOR_MAX]; QTimer *timer; QTime tickCount; - QFont regularFont, boldFont, smallFont; + QFont regularFont, boldFont, smallFont, scaledFont; bool notReadyToPaint; ///< HACK Don't draw during initial show(), since some global variables apparently aren't set up. static WzMainWindow *myself; diff --git a/lib/ivis_opengl/textdraw.h b/lib/ivis_opengl/textdraw.h index 34adc06dc..ee0aee4fb 100644 --- a/lib/ivis_opengl/textdraw.h +++ b/lib/ivis_opengl/textdraw.h @@ -26,9 +26,10 @@ enum iV_fonts { - font_regular, - font_large, + font_regular, + font_large, font_small, + font_scaled, }; extern void iV_TextInit(void); diff --git a/src/seqdisp.cpp b/src/seqdisp.cpp index 95213a1af..7f7113fa6 100644 --- a/src/seqdisp.cpp +++ b/src/seqdisp.cpp @@ -157,7 +157,7 @@ bool seq_RenderVideoToBuffer(const char* sequenceName, int seqCommand) { //start the ball rolling - iV_SetFont(font_regular); + iV_SetFont(font_scaled); iV_SetTextColour(WZCOL_TEXT_BRIGHT); /* We do *NOT* want to use the user-choosen resolution when we @@ -246,7 +246,7 @@ static bool seq_StartFullScreenVideo(const char* videoName, const char* audioNam } cdAudio_Pause(); - iV_SetFont(font_regular); + iV_SetFont(font_scaled); iV_SetTextColour(WZCOL_TEXT_BRIGHT); /* We do not want to enter loop_SetVideoPlaybackMode() when we are @@ -260,7 +260,7 @@ static bool seq_StartFullScreenVideo(const char* videoName, const char* audioNam // check to see if we need to pause, and set font each time cdAudio_Pause(); loop_SetVideoPlaybackMode(); - iV_SetFont(font_regular); + iV_SetFont(font_scaled); iV_SetTextColour(WZCOL_TEXT_BRIGHT); } @@ -476,7 +476,7 @@ bool seq_AddTextForVideo(const char* pText, SDWORD xOffset, SDWORD yOffset, SDWO // make sure we take xOffset into account, we don't always start at 0 const unsigned int BUFFER_WIDTH = pie_GetVideoBufferWidth() - xOffset; - iV_SetFont(font_regular); + iV_SetFont(font_scaled); ASSERT(aSeqList[currentSeq].currentText < MAX_TEXT_OVERLAYS, "too many text lines");