Fix Molten VK printing too many log messages
[0ad.git] / source / graphics / FontMetrics.cpp
blob1026b90efbcf5396f1b9a88257033db475f27ecc
1 /* Copyright (C) 2013 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
18 #include "precompiled.h"
19 #include "FontMetrics.h"
21 #include "graphics/Font.h"
22 #include "graphics/FontManager.h"
23 #include "ps/Filesystem.h"
24 #include "ps/CLogger.h"
25 #include "renderer/Renderer.h"
27 CFontMetrics::CFontMetrics(CStrIntern font)
29 m_Font = g_Renderer.GetFontManager().LoadFont(font);
32 int CFontMetrics::GetLineSpacing() const
34 // Return some arbitrary default if the font failed to load, so that the
35 // user of CFontMetrics doesn't have to care about failures
36 if (!m_Font)
37 return 12;
38 return m_Font->GetLineSpacing();
41 int CFontMetrics::GetHeight() const
43 if (!m_Font)
44 return 6;
45 return m_Font->GetHeight();
48 int CFontMetrics::GetCharacterWidth(wchar_t c) const
50 if (!m_Font)
51 return 6;
52 return m_Font->GetCharacterWidth(c);
55 void CFontMetrics::CalculateStringSize(const wchar_t* string, int& w, int& h) const
57 if (!m_Font)
58 w = h = 0;
59 else
60 m_Font->CalculateStringSize(string, w, h);