4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2012 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.
24 #include "Screen/Fonts.hpp"
25 #include "Screen/Font.hpp"
26 #include "Screen/Layout.hpp"
28 /// values inside infoboxes like numbers, etc.
30 Font
Fonts::infobox_small
;
32 Font
Fonts::infobox_units
;
34 /// Titles of infoboxes like Next, WP L/D etc.
36 /// vario display, runway informations
38 Font
Fonts::monospace
;
39 /// text names on the map
41 /// menu buttons, waypoint selection, messages, etc.
43 /// Flarm Traffic draweing and stats, map labels in italic
44 Font
Fonts::map_label
;
45 /// font labels for important labels (e.g. big/medium cities)
46 Font
Fonts::map_label_important
;
48 // these are the non-custom parameters
51 LOGFONT log_infobox_units
;
55 LOGFONT log_infobox_small
;
58 LOGFONT log_map_label
;
59 LOGFONT log_map_label_important
;
60 static LOGFONT log_monospace
;
63 GetStandardMonospaceFontFace()
66 return _T("Droid Sans Mono");
72 InitialiseLogfont(LOGFONT
* font
, const TCHAR
* facename
, UPixelScalar height
,
73 bool bold
= false, bool italic
= false,
74 bool variable_pitch
= true)
76 memset((char *)font
, 0, sizeof(LOGFONT
));
78 _tcscpy(font
->lfFaceName
, facename
);
80 font
->lfPitchAndFamily
= (variable_pitch
? VARIABLE_PITCH
: FIXED_PITCH
)
83 font
->lfHeight
= (long)height
;
84 font
->lfWeight
= (long)(bold
? FW_BOLD
: FW_MEDIUM
);
85 font
->lfItalic
= italic
;
89 font
->lfQuality
= NONANTIALIASED_QUALITY
;
91 font
->lfQuality
= ANTIALIASED_QUALITY
;
98 InitialiseLogfont(&log_infobox
, _T("RasterGothicTwentyFourCond"), 24, true);
99 InitialiseLogfont(&log_title
, _T("RasterGothicNineCond"), 10);
100 InitialiseLogfont(&log_cdi
, _T("RasterGothicEighteenCond"), 19, true);
101 InitialiseLogfont(&log_map_label
, _T("RasterGothicTwelveCond"), 13);
102 InitialiseLogfont(&log_map_label_important
,
103 _T("RasterGothicTwelveCond"), 13, true);
104 InitialiseLogfont(&log_map
, _T("RasterGothicFourteenCond"), 15);
105 InitialiseLogfont(&log_map_bold
, _T("RasterGothicFourteenCond"), 15, true);
106 InitialiseLogfont(&log_infobox_small
, _T("RasterGothicEighteenCond"), 19, true);
107 InitialiseLogfont(&log_monospace
, GetStandardMonospaceFontFace(),
108 10, false, false, false);
112 SizeLogFont(LOGFONT
&logfont
, UPixelScalar width
, const TCHAR
* str
)
114 // JMW algorithm to auto-size info window font.
115 // this is still required in case title font property doesn't exist.
121 if (!font
.Set(logfont
))
124 tsize
= font
.TextSize(str
);
125 } while ((unsigned)tsize
.cx
> width
);
134 LoadAltairLogFonts();
139 UPixelScalar FontHeight
= Layout::SmallScale(IsAndroid() ? 30 : 24);
141 UPixelScalar FontHeight
= Layout::SmallScale(35);
144 // oversize first so can then scale down
145 InitialiseLogfont(&log_infobox
, Fonts::GetStandardFontFace(),
146 (int)(FontHeight
* 1.4), true, false, true);
149 log_infobox
.lfCharSet
= ANSI_CHARSET
;
152 InitialiseLogfont(&log_title
, Fonts::GetStandardFontFace(),
153 FontHeight
/ 3, true);
155 // new font for CDI Scale
156 InitialiseLogfont(&log_cdi
, Fonts::GetStandardFontFace(),
157 UPixelScalar(FontHeight
* 0.6), false, false, false);
159 // new font for map labels
160 InitialiseLogfont(&log_map_label
, Fonts::GetStandardFontFace(),
161 UPixelScalar(FontHeight
* 0.39), false, true);
163 // new font for map labels big/medium cities
164 InitialiseLogfont(&log_map_label_important
, Fonts::GetStandardFontFace(),
165 UPixelScalar(FontHeight
* 0.39), true, true);
167 // new font for map labels
168 InitialiseLogfont(&log_map
, Fonts::GetStandardFontFace(),
169 UPixelScalar(FontHeight
* 0.507));
171 // Font for map bold text
172 InitialiseLogfont(&log_map_bold
, Fonts::GetStandardFontFace(),
173 UPixelScalar(FontHeight
* 0.507), true);
175 InitialiseLogfont(&log_infobox_small
, Fonts::GetStandardFontFace(),
178 InitialiseLogfont(&log_infobox_small
, Fonts::GetStandardFontFace(),
179 (int)(FontHeight
* 0.56), true);
181 InitialiseLogfont(&log_monospace
, GetStandardMonospaceFontFace(),
182 UPixelScalar(FontHeight
* 0.39), false, false, false);
188 InitialiseLogFonts();
190 title
.Set(log_title
);
192 map_label
.Set(log_map_label
);
193 map_label_important
.Set(log_map_label_important
);
195 map_bold
.Set(log_map_bold
);
196 monospace
.Set(log_monospace
);
198 return title
.IsDefined() && cdi
.IsDefined() &&
199 map_label
.IsDefined() && map_label_important
.IsDefined() &&
200 map
.IsDefined() && map_bold
.IsDefined() &&
201 monospace
.IsDefined();
205 Fonts::SizeInfoboxFont(UPixelScalar control_width
)
207 LOGFONT lf
= log_infobox
;
210 SizeLogFont(lf
, control_width
, _T("1234m"));
214 unsigned height
= lf
.lfHeight
;
215 lf
= log_infobox_units
;
216 lf
.lfHeight
= (height
* 2) / 5;
217 infobox_units
.Set(lf
);
220 lf
= log_infobox_small
;
222 SizeLogFont(lf
, control_width
, _T("12345m"));
223 infobox_small
.Set(lf
);
227 Fonts::Deinitialize()
230 infobox_small
.Reset();
232 infobox_units
.Reset();
239 map_label_important
.Reset();
244 Fonts::GetStandardFontFace()
247 return _T("RasterGothicFourteenCond");
250 return _T("Droid Sans");