summaryrefslogtreecommitdiff
path: root/fontmanager.c
blob: b55621a60b14902032d52b5ce2d9ae48593f7231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "geometrymanager.h"
#include "config.h"
#include "fontmanager.h"

cFontManager::cFontManager() {
}

cFontManager::~cFontManager() {
    DeleteFonts();
}

void cFontManager::SetFonts() {
    InitialiseFontType();
    //Common Fonts
    FontButton = CreateFont(geoManager.footerHeight/3 + 4 + tvguideConfig.FontButtonDelta);
    FontDetailView = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontDetailViewDelta);
    FontDetailViewSmall = CreateFont(geoManager.osdHeight/40 + tvguideConfig.FontDetailViewSmallDelta);
    FontDetailHeader = CreateFont(geoManager.osdHeight/27 + tvguideConfig.FontDetailHeaderDelta);
    FontDetailHeaderLarge = CreateFont(geoManager.osdHeight/20 + tvguideConfig.FontDetailHeaderDelta);
    FontMessageBox = CreateFont(geoManager.osdHeight/33 + tvguideConfig.FontMessageBoxDelta);
    FontMessageBoxLarge = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontMessageBoxLargeDelta);    
    FontStatusHeader = CreateFont(geoManager.statusHeaderHeight/6 - 4 + tvguideConfig.FontStatusHeaderDelta);
    FontStatusHeaderLarge = CreateFont(geoManager.statusHeaderHeight/5 + tvguideConfig.FontStatusHeaderLargeDelta);
    //Fonts for vertical Display 
    FontChannelHeader = CreateFont(geoManager.colWidth/10 + tvguideConfig.FontChannelHeaderDelta);
    FontChannelGroups = CreateFont(geoManager.colWidth/8 + tvguideConfig.FontChannelGroupsDelta);
    FontGrid = CreateFont(geoManager.colWidth/12 + tvguideConfig.FontGridDelta);
    FontGridSmall = CreateFont(geoManager.colWidth/12 + tvguideConfig.FontGridSmallDelta);
    FontTimeLineWeekday = CreateFont(geoManager.timeLineWidth/3 + tvguideConfig.FontTimeLineWeekdayDelta);
    FontTimeLineDate = CreateFont(geoManager.timeLineWidth/4 + tvguideConfig.FontTimeLineDateDelta);
    FontTimeLineTime = CreateFont(geoManager.timeLineWidth/4 + tvguideConfig.FontTimeLineTimeDelta);
    //Fonts for horizontal Display 
    FontChannelHeaderHorizontal = CreateFont(geoManager.rowHeight/3 + tvguideConfig.FontChannelHeaderHorizontalDelta);
    FontChannelGroupsHorizontal = CreateFont(geoManager.rowHeight/3 + 5 + tvguideConfig.FontChannelGroupsHorizontalDelta);
    FontGridHorizontal = CreateFont(geoManager.rowHeight/3 + 5 + tvguideConfig.FontGridHorizontalDelta);
    FontGridHorizontalSmall = CreateFont(geoManager.rowHeight/4 + tvguideConfig.FontGridHorizontalSmallDelta);
    FontTimeLineDateHorizontal = CreateFont(geoManager.timeLineHeight/2 + 5 + tvguideConfig.FontTimeLineDateHorizontalDelta);
    FontTimeLineTimeHorizontal = CreateFont(geoManager.timeLineHeight/2 + tvguideConfig.FontTimeLineTimeHorizontalDelta);
    //Fonts for RecMenu
    FontRecMenuItem = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontRecMenuItemDelta);
    FontRecMenuItemSmall = CreateFont(geoManager.osdHeight/40 + tvguideConfig.FontRecMenuItemSmallDelta);
    FontRecMenuItemLarge = CreateFont(geoManager.osdHeight/25 + tvguideConfig.FontRecMenuItemLargeDelta);
}

void cFontManager::DeleteFonts() {
    delete FontButton;
    delete FontDetailView;
    delete FontDetailViewSmall;
    delete FontDetailHeader;
    delete FontDetailHeaderLarge;
    delete FontMessageBox;
    delete FontMessageBoxLarge;
    delete FontStatusHeader;
    delete FontStatusHeaderLarge;
    delete FontChannelHeader;
    delete FontChannelGroups;
    delete FontGrid;
    delete FontGridSmall;
    delete FontTimeLineWeekday;
    delete FontTimeLineDate;
    delete FontTimeLineTime;
    delete FontChannelHeaderHorizontal;
    delete FontChannelGroupsHorizontal;
    delete FontGridHorizontal;
    delete FontGridHorizontalSmall;
    delete FontTimeLineDateHorizontal;
    delete FontTimeLineTimeHorizontal;
    delete FontRecMenuItem;
    delete FontRecMenuItemSmall;
    delete FontRecMenuItemLarge;
}

void cFontManager::InitialiseFontType(void) {
    if (tvguideConfig.fontIndex == 0) {
        fontName = tvguideConfig.fontNameDefault;
    } else {
        cStringList availableFonts;
        cFont::GetAvailableFontNames(&availableFonts);
        if (availableFonts[tvguideConfig.fontIndex-1]) {
            fontName = availableFonts[tvguideConfig.fontIndex-1];
        } else 
            fontName = tvguideConfig.fontNameDefault;
    }
    cFont *test = NULL;
    test = cFont::CreateFont(*fontName, 30);
    if (!test) {
        fontName = DefaultFontSml;
    }
    delete test;
    esyslog("tvguide: Set Font to %s", *fontName);
}

cFont *cFontManager::CreateFont(int size) {
    return cFont::CreateFont(*fontName, size);
}