2
2
*
3
3
* This file is part of GLogiK project.
4
4
* GLogiK, daemon to handle special features on gaming keyboards
5
- * Copyright (C) 2016-2018 Fabrice Delliaux <[email protected] >
5
+ * Copyright (C) 2016-2021 Fabrice Delliaux <[email protected] >
6
6
*
7
7
* This program is free software: you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License as published by
@@ -44,32 +44,30 @@ FontsManager::~FontsManager()
44
44
45
45
void FontsManager::initializeFont (const FontID fontID)
46
46
{
47
+ #if DEBUGGING_ON
48
+ LOG (DEBUG2) << " initializing font " << toUInt (toEnumType (fontID));
49
+ #endif
50
+ PBMFont* font = nullptr ;
47
51
try {
48
- _fonts.at (fontID);
49
- }
50
- catch (const std::out_of_range& oor) {
51
- PBMFont* font = nullptr ;
52
- try {
53
- switch (fontID) {
54
- case FontID::MONOSPACE85:
55
- font = new FontMonospace85 ();
56
- break ;
57
- case FontID::MONOSPACE86:
58
- font = new FontMonospace86 ();
59
- break ;
60
- case FontID::DEJAVUSANSBOLD1616:
61
- font = new FontDejaVuSansBold1616 ();
62
- break ;
63
- default :
64
- throw GLogiKExcept (" unknown font ID" );
65
- }
52
+ switch (fontID) {
53
+ case FontID::MONOSPACE85:
54
+ font = new FontMonospace85 ();
55
+ break ;
56
+ case FontID::MONOSPACE86:
57
+ font = new FontMonospace86 ();
58
+ break ;
59
+ case FontID::DEJAVUSANSBOLD1616:
60
+ font = new FontDejaVuSansBold1616 ();
61
+ break ;
62
+ default :
63
+ throw GLogiKExcept (" unknown font ID" );
66
64
}
67
- catch (const std::bad_alloc& e) { /* handle new() failure */
68
- throw GLogiKBadAlloc (" font bad allocation" );
69
- }
70
-
71
- _fonts[fontID] = font;
72
65
}
66
+ catch (const std::bad_alloc& e) { /* handle new() failure */
67
+ throw GLogiKBadAlloc (" font bad allocation" );
68
+ }
69
+
70
+ _fonts[fontID] = font;
73
71
}
74
72
75
73
void FontsManager::printCharacterOnFrame (
@@ -83,10 +81,8 @@ void FontsManager::printCharacterOnFrame(
83
81
_fonts.at (fontID)->printCharacterOnFrame (frame, c, PBMXPos, PBMYPos);
84
82
}
85
83
catch (const std::out_of_range& oor) {
86
- std::string warn (" unknown font : " );
87
- warn += std::to_string (toEnumType (fontID));
88
- GKSysLog (LOG_WARNING, WARNING, warn);
89
- throw GLogiKExcept (" unknown font ID" );
84
+ this ->initializeFont (fontID);
85
+ _fonts.at (fontID)->printCharacterOnFrame (frame, c, PBMXPos, PBMYPos);
90
86
}
91
87
}
92
88
0 commit comments