From c82257306f949e8d9da8e9aad45a6fc29bcef94a Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Thu, 27 Jun 2013 19:06:35 +0200 Subject: [PATCH] Add new class CNeutrinoFonts for setup and modify neutrino fonts - move SetupFonts() from CNeutrinoApp to CFontSetup Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/465d2aba23935107c746598a287f758b953466dd Author: Michael Liebmann Date: 2013-06-27 (Thu, 27 Jun 2013) ------------------ This commit was generated by Migit --- src/driver/Makefile.am | 1 + src/driver/neutrinofonts.cpp | 102 +++++++++++++++++++++++++++++++++++ src/driver/neutrinofonts.h | 70 ++++++++++++++++++++++++ src/gui/osd_setup.cpp | 55 +++++++++---------- src/neutrino.cpp | 72 ++++--------------------- src/neutrino.h | 26 --------- 6 files changed, 210 insertions(+), 116 deletions(-) create mode 100644 src/driver/neutrinofonts.cpp create mode 100644 src/driver/neutrinofonts.h diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 77823407f..55cbdd75e 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -27,6 +27,7 @@ libneutrino_driver_a_SOURCES = \ fontrenderer.cpp \ framebuffer.cpp \ genpsi.cpp \ + neutrinofonts.cpp \ radiotext.cpp \ radiotools.cpp \ rcinput.cpp \ diff --git a/src/driver/neutrinofonts.cpp b/src/driver/neutrinofonts.cpp new file mode 100644 index 000000000..8c7e0c360 --- /dev/null +++ b/src/driver/neutrinofonts.cpp @@ -0,0 +1,102 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +extern font_sizes_groups_struct font_sizes_groups[]; +extern font_sizes_struct neutrino_font[]; +extern const char * locale_real_names[]; /* #include */ + +const font_sizes_struct signal_font = {LOCALE_FONTSIZE_INFOBAR_SMALL, 14, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}; + +CNeutrinoFonts::CNeutrinoFonts() +{ + memset(&fontDescr, 0, sizeof(neutrino_font_descr_struct)); +} + +CNeutrinoFonts::~CNeutrinoFonts() +{ +} + +CNeutrinoFonts* CNeutrinoFonts::getInstance() +{ + static CNeutrinoFonts* nf = NULL; + if (!nf) + nf = new CNeutrinoFonts(); + return nf; +} + +void CNeutrinoFonts::SetupNeutrinoFonts() +{ + if (g_fontRenderer != NULL) + delete g_fontRenderer; + g_fontRenderer = new FBFontRenderClass(72 * g_settings.screen_xres / 100, 72 * g_settings.screen_yres / 100); + + if (fontDescr.filename != NULL) + free((void *)fontDescr.filename); + printf("[neutrino] settings font file %s\n", g_settings.font_file); + if (access(g_settings.font_file, F_OK)) { + if (!access(FONTDIR"/neutrino.ttf", F_OK)) { + fontDescr.filename = strdup(FONTDIR"/neutrino.ttf"); + strcpy(g_settings.font_file, fontDescr.filename); + } else { + fprintf( stderr,"[neutrino] font file [%s] not found\n neutrino exit\n",FONTDIR"/neutrino.ttf"); + _exit(0); + } + + } else + fontDescr.filename = strdup(g_settings.font_file); + fontStyle[0] = g_fontRenderer->AddFont(fontDescr.filename); + + if (fontDescr.name != NULL) + free((void *)fontDescr.name); + fontDescr.name = strdup(g_fontRenderer->getFamily(fontDescr.filename).c_str()); + printf("[neutrino] font family %s\n", fontDescr.name); + fontStyle[1] = "Bold Regular"; + + g_fontRenderer->AddFont(fontDescr.filename, true); // make italics + fontStyle[2] = "Italic"; + + for (int i = 0; i < SNeutrinoSettings::FONT_TYPE_COUNT; i++) { + if (g_Font[i]) delete g_Font[i]; + g_Font[i] = g_fontRenderer->getFont(fontDescr.name, fontStyle[neutrino_font[i].style], CNeutrinoApp::getInstance()->getConfigFile()->getInt32(locale_real_names[neutrino_font[i].name], neutrino_font[i].defaultsize) + neutrino_font[i].size_offset * fontDescr.size_offset); + } + g_SignalFont = g_fontRenderer->getFont(fontDescr.name, fontStyle[signal_font.style], signal_font.defaultsize + signal_font.size_offset * fontDescr.size_offset); +} diff --git a/src/driver/neutrinofonts.h b/src/driver/neutrinofonts.h new file mode 100644 index 000000000..4e0dce68f --- /dev/null +++ b/src/driver/neutrinofonts.h @@ -0,0 +1,70 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __neutrinofonts__ +#define __neutrinofonts__ + +typedef struct neutrino_font_descr { + const char *name; + const char *filename; + int size_offset; +} neutrino_font_descr_struct; + +typedef struct font_sizes { + const neutrino_locale_t name; + const unsigned int defaultsize; + const unsigned int style; + const unsigned int size_offset; +} font_sizes_struct; + +typedef struct font_sizes_groups { + const neutrino_locale_t groupname; + const unsigned int count; + const SNeutrinoSettings::FONT_TYPES *const content; + const char * const actionkey; + const neutrino_locale_t hint; +} font_sizes_groups_struct; + +class CNeutrinoFonts +{ + private: + const char * fontStyle[3]; + + public: + enum { + FONT_STYLE_REGULAR = 0, + FONT_STYLE_BOLD = 1, + FONT_STYLE_ITALIC = 2 + }; + + CNeutrinoFonts(); + ~CNeutrinoFonts(); + static CNeutrinoFonts* getInstance(); + + neutrino_font_descr_struct fontDescr; + + void SetupNeutrinoFonts(); +}; + + +#endif //__neutrinofonts__ diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 4c7b70c31..511e53ea3 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -146,37 +147,33 @@ font_sizes_groups font_sizes_groups[6] = {LOCALE_FONTMENU_GAMELIST , 2, gamelist_font_sizes , "fontsize.dgam", LOCALE_MENU_HINT_GAMELIST_FONTS } }; -#define FONT_STYLE_REGULAR 0 -#define FONT_STYLE_BOLD 1 -#define FONT_STYLE_ITALIC 2 - font_sizes_struct neutrino_font[SNeutrinoSettings::FONT_TYPE_COUNT] = { - {LOCALE_FONTSIZE_MENU , 20, FONT_STYLE_BOLD , 0}, - {LOCALE_FONTSIZE_MENU_TITLE , 30, FONT_STYLE_BOLD , 0}, - {LOCALE_FONTSIZE_MENU_INFO , 16, FONT_STYLE_REGULAR, 0}, - {LOCALE_FONTSIZE_EPG_TITLE , 25, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_EPG_INFO1 , 17, FONT_STYLE_ITALIC , 2}, - {LOCALE_FONTSIZE_EPG_INFO2 , 17, FONT_STYLE_REGULAR, 2}, - {LOCALE_FONTSIZE_EPG_DATE , 15, FONT_STYLE_REGULAR, 2}, - {LOCALE_FONTSIZE_EVENTLIST_TITLE , 30, FONT_STYLE_REGULAR, 0}, - {LOCALE_FONTSIZE_EVENTLIST_ITEMLARGE, 20, FONT_STYLE_BOLD , 1}, - {LOCALE_FONTSIZE_EVENTLIST_ITEMSMALL, 14, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_EVENTLIST_DATETIME , 16, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_EVENTLIST_EVENT , 17, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_GAMELIST_ITEMLARGE , 20, FONT_STYLE_BOLD , 1}, - {LOCALE_FONTSIZE_GAMELIST_ITEMSMALL , 16, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_CHANNELLIST , 20, FONT_STYLE_BOLD , 1}, - {LOCALE_FONTSIZE_CHANNELLIST_DESCR , 20, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_CHANNELLIST_NUMBER , 14, FONT_STYLE_BOLD , 2}, - {LOCALE_FONTSIZE_CHANNELLIST_EVENT , 17, FONT_STYLE_REGULAR, 2}, - {LOCALE_FONTSIZE_CHANNEL_NUM_ZAP , 40, FONT_STYLE_BOLD , 0}, - {LOCALE_FONTSIZE_INFOBAR_NUMBER , 50, FONT_STYLE_BOLD , 0}, - {LOCALE_FONTSIZE_INFOBAR_CHANNAME , 30, FONT_STYLE_BOLD , 0}, - {LOCALE_FONTSIZE_INFOBAR_INFO , 20, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_INFOBAR_SMALL , 14, FONT_STYLE_REGULAR, 1}, - {LOCALE_FONTSIZE_FILEBROWSER_ITEM , 16, FONT_STYLE_BOLD , 1}, - {LOCALE_FONTSIZE_MENU_HINT , 16, FONT_STYLE_REGULAR, 0} + {LOCALE_FONTSIZE_MENU , 20, CNeutrinoFonts::FONT_STYLE_BOLD , 0}, + {LOCALE_FONTSIZE_MENU_TITLE , 30, CNeutrinoFonts::FONT_STYLE_BOLD , 0}, + {LOCALE_FONTSIZE_MENU_INFO , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 0}, + {LOCALE_FONTSIZE_EPG_TITLE , 25, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_EPG_INFO1 , 17, CNeutrinoFonts::FONT_STYLE_ITALIC , 2}, + {LOCALE_FONTSIZE_EPG_INFO2 , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, + {LOCALE_FONTSIZE_EPG_DATE , 15, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, + {LOCALE_FONTSIZE_EVENTLIST_TITLE , 30, CNeutrinoFonts::FONT_STYLE_REGULAR, 0}, + {LOCALE_FONTSIZE_EVENTLIST_ITEMLARGE, 20, CNeutrinoFonts::FONT_STYLE_BOLD , 1}, + {LOCALE_FONTSIZE_EVENTLIST_ITEMSMALL, 14, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_EVENTLIST_DATETIME , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_EVENTLIST_EVENT , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_GAMELIST_ITEMLARGE , 20, CNeutrinoFonts::FONT_STYLE_BOLD , 1}, + {LOCALE_FONTSIZE_GAMELIST_ITEMSMALL , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_CHANNELLIST , 20, CNeutrinoFonts::FONT_STYLE_BOLD , 1}, + {LOCALE_FONTSIZE_CHANNELLIST_DESCR , 20, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_CHANNELLIST_NUMBER , 14, CNeutrinoFonts::FONT_STYLE_BOLD , 2}, + {LOCALE_FONTSIZE_CHANNELLIST_EVENT , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 2}, + {LOCALE_FONTSIZE_CHANNEL_NUM_ZAP , 40, CNeutrinoFonts::FONT_STYLE_BOLD , 0}, + {LOCALE_FONTSIZE_INFOBAR_NUMBER , 50, CNeutrinoFonts::FONT_STYLE_BOLD , 0}, + {LOCALE_FONTSIZE_INFOBAR_CHANNAME , 30, CNeutrinoFonts::FONT_STYLE_BOLD , 0}, + {LOCALE_FONTSIZE_INFOBAR_INFO , 20, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_INFOBAR_SMALL , 14, CNeutrinoFonts::FONT_STYLE_REGULAR, 1}, + {LOCALE_FONTSIZE_FILEBROWSER_ITEM , 16, CNeutrinoFonts::FONT_STYLE_BOLD , 1}, + {LOCALE_FONTSIZE_MENU_HINT , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 0} }; int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index c66a93807..efa262bd8 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -177,6 +178,7 @@ CPictureViewer * g_PicViewer; CCAMMenuHandler * g_CamHandler; CVolume * g_volume; CAudioMute * g_audioMute; +CNeutrinoFonts * neutrinoFonts = NULL; // Globale Variablen - to use import global.h @@ -200,10 +202,9 @@ CNeutrinoApp::CNeutrinoApp() frameBuffer = CFrameBuffer::getInstance(); frameBuffer->setIconBasePath(DATADIR "/neutrino/icons/"); - SetupFrameBuffer(); - mode = mode_unknown; + mode = mode_unknown; channelList = NULL; TVchannelList = NULL; RADIOchannelList = NULL; @@ -213,7 +214,6 @@ CNeutrinoApp::CNeutrinoApp() current_muted = 0; recordingstatus = 0; g_channel_list_changed = false; - memset(&font, 0, sizeof(neutrino_font_descr_struct)); } /*------------------------------------------------------------------------------------- @@ -223,6 +223,9 @@ CNeutrinoApp::~CNeutrinoApp() { if (channelList) delete channelList; + if (neutrinoFonts) + delete neutrinoFonts; + neutrinoFonts = NULL; } CNeutrinoApp* CNeutrinoApp::getInstance() @@ -236,16 +239,6 @@ CNeutrinoApp* CNeutrinoApp::getInstance() return neutrinoApp; } - -#define FONT_STYLE_REGULAR 0 -#define FONT_STYLE_BOLD 1 -#define FONT_STYLE_ITALIC 2 - -extern font_sizes_groups_struct font_sizes_groups[]; -extern font_sizes_struct neutrino_font[]; - -const font_sizes_struct signal_font = {LOCALE_FONTSIZE_INFOBAR_SMALL , 14, FONT_STYLE_REGULAR, 1}; - typedef struct lcd_setting_t { const char * const name; @@ -1469,8 +1462,6 @@ void CNeutrinoApp::CmdParser(int argc, char **argv) softupdate = false; //fromflash = false; - font.name = NULL; - for(int x=1; xSetupNeutrinoFonts(); - if (g_fontRenderer != NULL) - delete g_fontRenderer; - - g_fontRenderer = new FBFontRenderClass(72 * g_settings.screen_xres / 100, 72 * g_settings.screen_yres / 100); - - if(font.filename != NULL) - free((void *)font.filename); - - printf("[neutrino] settings font file %s\n", g_settings.font_file); - - if(access(g_settings.font_file, F_OK)) { - if(!access(FONTDIR"/neutrino.ttf", F_OK)){ - font.filename = strdup(FONTDIR"/neutrino.ttf"); - strcpy(g_settings.font_file, font.filename); - } - else{ - fprintf( stderr,"[neutrino] font file [%s] not found\n neutrino exit\n",FONTDIR"/neutrino.ttf"); - _exit(0); - } - - } - else{ - font.filename = strdup(g_settings.font_file); - } - style[0] = g_fontRenderer->AddFont(font.filename); - - if(font.name != NULL) - free((void *)font.name); - - font.name = strdup(g_fontRenderer->getFamily(font.filename).c_str()); - - printf("[neutrino] font family %s\n", font.name); - - style[1] = "Bold Regular"; - - g_fontRenderer->AddFont(font.filename, true); // make italics - style[2] = "Italic"; - - for (int i = 0; i < SNeutrinoSettings::FONT_TYPE_COUNT; i++) - { - if(g_Font[i]) delete g_Font[i]; - g_Font[i] = g_fontRenderer->getFont(font.name, style[neutrino_font[i].style], configfile.getInt32(locale_real_names[neutrino_font[i].name], neutrino_font[i].defaultsize) + neutrino_font[i].size_offset * font.size_offset); - } - g_SignalFont = g_fontRenderer->getFont(font.name, style[signal_font.style], signal_font.defaultsize + signal_font.size_offset * font.size_offset); /* recalculate infobar position */ if (g_InfoViewer) g_InfoViewer->start(); @@ -1781,6 +1730,7 @@ TIMER_START(); show_startwizard = true; } /* setup GUI */ + neutrinoFonts = CNeutrinoFonts::getInstance(); SetupFonts(); SetupTiming(); g_PicViewer = new CPictureViewer(); @@ -1789,7 +1739,7 @@ TIMER_START(); CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NEUTRINO_STARTING)); hintBox->paint(); - CVFD::getInstance()->init(font.filename, font.name); + CVFD::getInstance()->init(neutrinoFonts->fontDescr.filename, neutrinoFonts->fontDescr.name); CVFD::getInstance()->Clear(); CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_NEUTRINO_STARTING)); CVFD::getInstance()->setBacklight(g_settings.backlight_tv); diff --git a/src/neutrino.h b/src/neutrino.h index b79678e08..133a29310 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -58,30 +58,6 @@ * * **************************************************************************************/ -typedef struct neutrino_font_descr -{ - const char * name; - const char * filename; - int size_offset; -} neutrino_font_descr_struct; - -typedef struct font_sizes -{ - const neutrino_locale_t name; - const unsigned int defaultsize; - const unsigned int style; - const unsigned int size_offset; -} font_sizes_struct; - -typedef struct font_sizes_groups -{ - const neutrino_locale_t groupname; - const unsigned int count; - const SNeutrinoSettings::FONT_TYPES * const content; - const char * const actionkey; - const neutrino_locale_t hint; -} font_sizes_groups_struct; - extern const unsigned char genre_sub_classes[]; /* epgview.cpp */ extern const neutrino_locale_t * genre_sub_classes_list[]; /* epgview.cpp */ @@ -108,8 +84,6 @@ private: int network_dhcp; int network_automatic_start; - neutrino_font_descr_struct font; - int mode; int lastMode; bool softupdate;