android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / test / src / Fonts.cpp
blob390b7b6b1c0838276fab7b17e60d149841155a66
1 /*
2 Copyright_License {
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.
24 #include "Fonts.hpp"
25 #include "Screen/Font.hpp"
26 #include "Screen/Layout.hpp"
27 #include "Asset.hpp"
29 #include <string.h>
31 Font normal_font, small_font, bold_font, monospace_font;
33 static const TCHAR *
34 GetStandardMonospaceFontFace()
36 if (IsAndroid())
37 return _T("Droid Sans Mono");
39 return _T("Courier");
42 static void
43 InitialiseLogfont(LOGFONT* font, const TCHAR* facename, int height,
44 bool bold = false, bool italic = false,
45 bool variable_pitch = true)
47 memset((char *)font, 0, sizeof(LOGFONT));
49 _tcscpy(font->lfFaceName, facename);
51 #ifdef WIN32
52 font->lfPitchAndFamily = (variable_pitch ? VARIABLE_PITCH : FIXED_PITCH)
53 | FF_DONTCARE;
54 #endif
56 font->lfHeight = (long)height;
57 font->lfWeight = (long)(bold ? FW_BOLD : FW_MEDIUM);
58 font->lfItalic = italic;
60 #ifdef WIN32
61 if (IsAltair())
62 font->lfQuality = NONANTIALIASED_QUALITY;
63 else
64 font->lfQuality = ANTIALIASED_QUALITY;
65 #endif
68 void
69 InitialiseFonts()
71 const TCHAR *face = _T("Tahoma");
73 #ifndef USE_GDI
74 UPixelScalar font_height = Layout::SmallScale(IsAndroid() ? 30 : 24);
75 #else
76 UPixelScalar font_height = Layout::SmallScale(35);
77 #endif
79 LOGFONT lf;
80 InitialiseLogfont(&lf, face, font_height / 2);
81 normal_font.Load(lf);
83 InitialiseLogfont(&lf, face, font_height / 2 - Layout::Scale(2));
84 small_font.Load(lf);
86 InitialiseLogfont(&lf, face, font_height / 2, true);
87 bold_font.Load(lf);
89 InitialiseLogfont(&lf, GetStandardMonospaceFontFace(),
90 10, false, false, false);
91 monospace_font.Load(lf);
94 void
95 DeinitialiseFonts()
97 monospace_font.Destroy();
98 bold_font.Destroy();
99 small_font.Destroy();
100 normal_font.Destroy();