4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "StandardFonts.hpp"
26 #include "Screen/Font.hpp"
27 #include "Screen/Layout.hpp"
30 #include "Screen/OpenGL/Cache.hpp"
35 /// values inside infoboxes like numbers, etc.
37 Font
Fonts::infobox_small
;
39 Font
Fonts::infobox_units
;
41 /// Titles of infoboxes like Next, WP L/D etc.
43 /// vario display, runway informations
45 Font
Fonts::monospace
;
46 /// text names on the map
48 /// menu buttons, waypoint selection, messages, etc.
50 /// Flarm Traffic draweing and stats, map labels in italic
51 Font
Fonts::map_label
;
52 /// font labels for important labels (e.g. big/medium cities)
53 Font
Fonts::map_label_important
;
55 // these are the non-custom parameters
58 LOGFONT log_infobox_units
;
62 LOGFONT log_infobox_small
;
65 LOGFONT log_map_label
;
66 LOGFONT log_map_label_important
;
67 static LOGFONT log_monospace
;
70 InitialiseLogfont(LOGFONT
* font
, const TCHAR
* facename
, UPixelScalar height
,
71 bool bold
= false, bool italic
= false,
72 bool variable_pitch
= true)
74 memset((char *)font
, 0, sizeof(LOGFONT
));
76 _tcscpy(font
->lfFaceName
, facename
);
78 font
->lfPitchAndFamily
= (variable_pitch
? VARIABLE_PITCH
: FIXED_PITCH
)
81 font
->lfHeight
= (long)height
;
82 font
->lfWeight
= (long)(bold
? FW_BOLD
: FW_MEDIUM
);
83 font
->lfItalic
= italic
;
87 font
->lfQuality
= NONANTIALIASED_QUALITY
;
89 font
->lfQuality
= ANTIALIASED_QUALITY
;
96 InitialiseLogfont(&log_infobox
, _T("RasterGothicTwentyFourCond"), 24, true);
97 InitialiseLogfont(&log_title
, _T("RasterGothicNineCond"), 10);
98 InitialiseLogfont(&log_cdi
, _T("RasterGothicEighteenCond"), 19, true);
99 InitialiseLogfont(&log_map_label
, _T("RasterGothicTwelveCond"), 13);
100 InitialiseLogfont(&log_map_label_important
,
101 _T("RasterGothicTwelveCond"), 13);
102 InitialiseLogfont(&log_map
, _T("RasterGothicFourteenCond"), 15);
103 InitialiseLogfont(&log_map_bold
, _T("RasterGothicFourteenCond"), 15, true);
104 InitialiseLogfont(&log_infobox_small
, _T("RasterGothicEighteenCond"), 19, true);
105 InitialiseLogfont(&log_monospace
, GetStandardMonospaceFontFace(),
106 10, false, false, false);
110 SizeLogFont(LOGFONT
&logfont
, UPixelScalar width
, const TCHAR
* str
)
112 // JMW algorithm to auto-size info window font.
113 // this is still required in case title font property doesn't exist.
119 if (!font
.Load(logfont
))
122 tsize
= font
.TextSize(str
);
123 } while ((unsigned)tsize
.cx
> width
);
132 LoadAltairLogFonts();
137 UPixelScalar font_height
= Layout::SmallScale(IsAndroid() ? 30 : 24);
139 UPixelScalar font_height
= Layout::SmallScale(35);
142 // oversize first so can then scale down
143 InitialiseLogfont(&log_infobox
, GetStandardFontFace(),
144 (int)(font_height
* 1.4), true, false, true);
147 log_infobox
.lfCharSet
= ANSI_CHARSET
;
150 InitialiseLogfont(&log_title
, GetStandardFontFace(), font_height
/ 3);
152 // new font for CDI Scale
153 InitialiseLogfont(&log_cdi
, GetStandardFontFace(),
154 UPixelScalar(font_height
* 0.6), false, false, false);
156 // new font for map labels
157 InitialiseLogfont(&log_map_label
, GetStandardFontFace(),
158 UPixelScalar(font_height
* 0.39), false, true);
160 // new font for map labels big/medium cities
161 InitialiseLogfont(&log_map_label_important
, GetStandardFontFace(),
162 UPixelScalar(font_height
* 0.39), false, true);
164 // new font for map labels
165 InitialiseLogfont(&log_map
, GetStandardFontFace(),
166 UPixelScalar(font_height
* 0.507));
168 // Font for map bold text
169 InitialiseLogfont(&log_map_bold
, GetStandardFontFace(),
170 UPixelScalar(font_height
* 0.507), true);
172 InitialiseLogfont(&log_infobox_small
, GetStandardFontFace(),
176 InitialiseLogfont(&log_infobox_units
, GetStandardFontFace(),
177 (int)(font_height
* 0.56));
180 InitialiseLogfont(&log_monospace
, GetStandardMonospaceFontFace(),
181 UPixelScalar(font_height
* 0.39), false, false, false);
187 InitialiseLogFonts();
189 title
.Load(log_title
);
191 map_label
.Load(log_map_label
);
192 map_label_important
.Load(log_map_label_important
);
194 map_bold
.Load(log_map_bold
);
195 monospace
.Load(log_monospace
);
197 return title
.IsDefined() && cdi
.IsDefined() &&
198 map_label
.IsDefined() && map_label_important
.IsDefined() &&
199 map
.IsDefined() && map_bold
.IsDefined() &&
200 monospace
.IsDefined();
204 Fonts::SizeInfoboxFont(UPixelScalar control_width
)
206 LOGFONT lf
= log_infobox
;
209 SizeLogFont(lf
, control_width
, _T("1234m"));
213 unsigned height
= lf
.lfHeight
;
214 lf
= log_infobox_units
;
215 lf
.lfHeight
= (height
* 2) / 5;
216 infobox_units
.Load(lf
);
219 lf
= log_infobox_small
;
221 SizeLogFont(lf
, control_width
, _T("12345m"));
222 infobox_small
.Load(lf
);
230 Fonts::Deinitialize()
233 infobox_small
.Destroy();
235 infobox_units
.Destroy();
242 map_label_important
.Destroy();