Add new class CNeutrinoFonts for setup and modify neutrino fonts

- move SetupFonts() from CNeutrinoApp to CFontSetup


Origin commit data
------------------
Branch: ni/coolstream
Commit: 465d2aba23
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-06-27 (Thu, 27 Jun 2013)



------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2013-06-27 19:06:35 +02:00
committed by Thilo Graf
parent 74838376c3
commit c82257306f
6 changed files with 210 additions and 116 deletions

View File

@@ -27,6 +27,7 @@ libneutrino_driver_a_SOURCES = \
fontrenderer.cpp \ fontrenderer.cpp \
framebuffer.cpp \ framebuffer.cpp \
genpsi.cpp \ genpsi.cpp \
neutrinofonts.cpp \
radiotext.cpp \ radiotext.cpp \
radiotools.cpp \ radiotools.cpp \
rcinput.cpp \ rcinput.cpp \

View File

@@ -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 <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string>
#include <global.h>
#include <neutrino.h>
#include <driver/fontrenderer.h>
#include <driver/neutrinofonts.h>
#include <system/settings.h>
#include <configfile.h>
extern font_sizes_groups_struct font_sizes_groups[];
extern font_sizes_struct neutrino_font[];
extern const char * locale_real_names[]; /* #include <system/locals_intern.h> */
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);
}

View File

@@ -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__

View File

@@ -49,6 +49,7 @@
#include <gui/widget/colorchooser.h> #include <gui/widget/colorchooser.h>
#include <gui/widget/stringinput.h> #include <gui/widget/stringinput.h>
#include <driver/neutrinofonts.h>
#include <driver/screen_max.h> #include <driver/screen_max.h>
#include <driver/screenshot.h> #include <driver/screenshot.h>
#include <driver/volume.h> #include <driver/volume.h>
@@ -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 } {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] = font_sizes_struct neutrino_font[SNeutrinoSettings::FONT_TYPE_COUNT] =
{ {
{LOCALE_FONTSIZE_MENU , 20, FONT_STYLE_BOLD , 0}, {LOCALE_FONTSIZE_MENU , 20, CNeutrinoFonts::FONT_STYLE_BOLD , 0},
{LOCALE_FONTSIZE_MENU_TITLE , 30, FONT_STYLE_BOLD , 0}, {LOCALE_FONTSIZE_MENU_TITLE , 30, CNeutrinoFonts::FONT_STYLE_BOLD , 0},
{LOCALE_FONTSIZE_MENU_INFO , 16, FONT_STYLE_REGULAR, 0}, {LOCALE_FONTSIZE_MENU_INFO , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 0},
{LOCALE_FONTSIZE_EPG_TITLE , 25, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_EPG_TITLE , 25, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_EPG_INFO1 , 17, FONT_STYLE_ITALIC , 2}, {LOCALE_FONTSIZE_EPG_INFO1 , 17, CNeutrinoFonts::FONT_STYLE_ITALIC , 2},
{LOCALE_FONTSIZE_EPG_INFO2 , 17, FONT_STYLE_REGULAR, 2}, {LOCALE_FONTSIZE_EPG_INFO2 , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 2},
{LOCALE_FONTSIZE_EPG_DATE , 15, FONT_STYLE_REGULAR, 2}, {LOCALE_FONTSIZE_EPG_DATE , 15, CNeutrinoFonts::FONT_STYLE_REGULAR, 2},
{LOCALE_FONTSIZE_EVENTLIST_TITLE , 30, FONT_STYLE_REGULAR, 0}, {LOCALE_FONTSIZE_EVENTLIST_TITLE , 30, CNeutrinoFonts::FONT_STYLE_REGULAR, 0},
{LOCALE_FONTSIZE_EVENTLIST_ITEMLARGE, 20, FONT_STYLE_BOLD , 1}, {LOCALE_FONTSIZE_EVENTLIST_ITEMLARGE, 20, CNeutrinoFonts::FONT_STYLE_BOLD , 1},
{LOCALE_FONTSIZE_EVENTLIST_ITEMSMALL, 14, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_EVENTLIST_ITEMSMALL, 14, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_EVENTLIST_DATETIME , 16, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_EVENTLIST_DATETIME , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_EVENTLIST_EVENT , 17, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_EVENTLIST_EVENT , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_GAMELIST_ITEMLARGE , 20, FONT_STYLE_BOLD , 1}, {LOCALE_FONTSIZE_GAMELIST_ITEMLARGE , 20, CNeutrinoFonts::FONT_STYLE_BOLD , 1},
{LOCALE_FONTSIZE_GAMELIST_ITEMSMALL , 16, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_GAMELIST_ITEMSMALL , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_CHANNELLIST , 20, FONT_STYLE_BOLD , 1}, {LOCALE_FONTSIZE_CHANNELLIST , 20, CNeutrinoFonts::FONT_STYLE_BOLD , 1},
{LOCALE_FONTSIZE_CHANNELLIST_DESCR , 20, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_CHANNELLIST_DESCR , 20, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_CHANNELLIST_NUMBER , 14, FONT_STYLE_BOLD , 2}, {LOCALE_FONTSIZE_CHANNELLIST_NUMBER , 14, CNeutrinoFonts::FONT_STYLE_BOLD , 2},
{LOCALE_FONTSIZE_CHANNELLIST_EVENT , 17, FONT_STYLE_REGULAR, 2}, {LOCALE_FONTSIZE_CHANNELLIST_EVENT , 17, CNeutrinoFonts::FONT_STYLE_REGULAR, 2},
{LOCALE_FONTSIZE_CHANNEL_NUM_ZAP , 40, FONT_STYLE_BOLD , 0}, {LOCALE_FONTSIZE_CHANNEL_NUM_ZAP , 40, CNeutrinoFonts::FONT_STYLE_BOLD , 0},
{LOCALE_FONTSIZE_INFOBAR_NUMBER , 50, FONT_STYLE_BOLD , 0}, {LOCALE_FONTSIZE_INFOBAR_NUMBER , 50, CNeutrinoFonts::FONT_STYLE_BOLD , 0},
{LOCALE_FONTSIZE_INFOBAR_CHANNAME , 30, FONT_STYLE_BOLD , 0}, {LOCALE_FONTSIZE_INFOBAR_CHANNAME , 30, CNeutrinoFonts::FONT_STYLE_BOLD , 0},
{LOCALE_FONTSIZE_INFOBAR_INFO , 20, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_INFOBAR_INFO , 20, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_INFOBAR_SMALL , 14, FONT_STYLE_REGULAR, 1}, {LOCALE_FONTSIZE_INFOBAR_SMALL , 14, CNeutrinoFonts::FONT_STYLE_REGULAR, 1},
{LOCALE_FONTSIZE_FILEBROWSER_ITEM , 16, FONT_STYLE_BOLD , 1}, {LOCALE_FONTSIZE_FILEBROWSER_ITEM , 16, CNeutrinoFonts::FONT_STYLE_BOLD , 1},
{LOCALE_FONTSIZE_MENU_HINT , 16, FONT_STYLE_REGULAR, 0} {LOCALE_FONTSIZE_MENU_HINT , 16, CNeutrinoFonts::FONT_STYLE_REGULAR, 0}
}; };
int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey)

View File

@@ -51,6 +51,7 @@
#include <driver/abstime.h> #include <driver/abstime.h>
#include <driver/fontrenderer.h> #include <driver/fontrenderer.h>
#include <driver/framebuffer.h> #include <driver/framebuffer.h>
#include <driver/neutrinofonts.h>
#include <driver/rcinput.h> #include <driver/rcinput.h>
#include <driver/shutdown_count.h> #include <driver/shutdown_count.h>
#include <driver/record.h> #include <driver/record.h>
@@ -177,6 +178,7 @@ CPictureViewer * g_PicViewer;
CCAMMenuHandler * g_CamHandler; CCAMMenuHandler * g_CamHandler;
CVolume * g_volume; CVolume * g_volume;
CAudioMute * g_audioMute; CAudioMute * g_audioMute;
CNeutrinoFonts * neutrinoFonts = NULL;
// Globale Variablen - to use import global.h // Globale Variablen - to use import global.h
@@ -200,7 +202,6 @@ CNeutrinoApp::CNeutrinoApp()
frameBuffer = CFrameBuffer::getInstance(); frameBuffer = CFrameBuffer::getInstance();
frameBuffer->setIconBasePath(DATADIR "/neutrino/icons/"); frameBuffer->setIconBasePath(DATADIR "/neutrino/icons/");
SetupFrameBuffer(); SetupFrameBuffer();
mode = mode_unknown; mode = mode_unknown;
@@ -213,7 +214,6 @@ CNeutrinoApp::CNeutrinoApp()
current_muted = 0; current_muted = 0;
recordingstatus = 0; recordingstatus = 0;
g_channel_list_changed = false; g_channel_list_changed = false;
memset(&font, 0, sizeof(neutrino_font_descr_struct));
} }
/*------------------------------------------------------------------------------------- /*-------------------------------------------------------------------------------------
@@ -223,6 +223,9 @@ CNeutrinoApp::~CNeutrinoApp()
{ {
if (channelList) if (channelList)
delete channelList; delete channelList;
if (neutrinoFonts)
delete neutrinoFonts;
neutrinoFonts = NULL;
} }
CNeutrinoApp* CNeutrinoApp::getInstance() CNeutrinoApp* CNeutrinoApp::getInstance()
@@ -236,16 +239,6 @@ CNeutrinoApp* CNeutrinoApp::getInstance()
return neutrinoApp; 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 typedef struct lcd_setting_t
{ {
const char * const name; const char * const name;
@@ -1469,8 +1462,6 @@ void CNeutrinoApp::CmdParser(int argc, char **argv)
softupdate = false; softupdate = false;
//fromflash = false; //fromflash = false;
font.name = NULL;
for(int x=1; x<argc; x++) { for(int x=1; x<argc; x++) {
if ((!strcmp(argv[x], "-u")) || (!strcmp(argv[x], "--enable-update"))) { if ((!strcmp(argv[x], "-u")) || (!strcmp(argv[x], "--enable-update"))) {
dprintf(DEBUG_NORMAL, "Software update enabled\n"); dprintf(DEBUG_NORMAL, "Software update enabled\n");
@@ -1531,52 +1522,10 @@ void CNeutrinoApp::SetupFrameBuffer()
void CNeutrinoApp::SetupFonts() void CNeutrinoApp::SetupFonts()
{ {
const char * style[3]; if (neutrinoFonts == NULL)
neutrinoFonts = CNeutrinoFonts::getInstance();
neutrinoFonts->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(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 */ /* recalculate infobar position */
if (g_InfoViewer) if (g_InfoViewer)
g_InfoViewer->start(); g_InfoViewer->start();
@@ -1781,6 +1730,7 @@ TIMER_START();
show_startwizard = true; show_startwizard = true;
} }
/* setup GUI */ /* setup GUI */
neutrinoFonts = CNeutrinoFonts::getInstance();
SetupFonts(); SetupFonts();
SetupTiming(); SetupTiming();
g_PicViewer = new CPictureViewer(); g_PicViewer = new CPictureViewer();
@@ -1789,7 +1739,7 @@ TIMER_START();
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NEUTRINO_STARTING)); CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NEUTRINO_STARTING));
hintBox->paint(); hintBox->paint();
CVFD::getInstance()->init(font.filename, font.name); CVFD::getInstance()->init(neutrinoFonts->fontDescr.filename, neutrinoFonts->fontDescr.name);
CVFD::getInstance()->Clear(); CVFD::getInstance()->Clear();
CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_NEUTRINO_STARTING)); CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_NEUTRINO_STARTING));
CVFD::getInstance()->setBacklight(g_settings.backlight_tv); CVFD::getInstance()->setBacklight(g_settings.backlight_tv);

View File

@@ -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 unsigned char genre_sub_classes[]; /* epgview.cpp */
extern const neutrino_locale_t * genre_sub_classes_list[]; /* epgview.cpp */ extern const neutrino_locale_t * genre_sub_classes_list[]; /* epgview.cpp */
@@ -108,8 +84,6 @@ private:
int network_dhcp; int network_dhcp;
int network_automatic_start; int network_automatic_start;
neutrino_font_descr_struct font;
int mode; int mode;
int lastMode; int lastMode;
bool softupdate; bool softupdate;