MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / getDefaultPath

Method getDefaultPath

src/Font.cpp:19–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17std::map< std::pair<std::string, int>, std::weak_ptr<Font> > Font::sFontMap;
18
19std::string Font::getDefaultPath()
20{
21 const int fontCount = 4;
22
23#ifdef WIN32
24 std::string fonts[] = {"DejaVuSerif.ttf",
25 "Arial.ttf",
26 "Verdana.ttf",
27 "Tahoma.ttf" };
28
29 //build full font path
30 TCHAR winDir[MAX_PATH];
31 GetWindowsDirectory(winDir, MAX_PATH);
32#ifdef UNICODE
33 char winDirChar[MAX_PATH*2];
34 char DefChar = ' ';
35 WideCharToMultiByte(CP_ACP, 0, winDir, -1, winDirChar, MAX_PATH, &DefChar, NULL);
36 std::string fontPath(winDirChar);
37#else
38 std::string fontPath(winDir);
39#endif
40 fontPath += "\\Fonts\\";
41 //prepend to font file names
42 for(int i = 0; i < fontCount; i++)
43 {
44 fonts[i] = fontPath + fonts[i];
45 }
46#else
47 std::string fonts[] = {"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf",
48 "/usr/share/fonts/TTF/DejaVuSerif.ttf",
49 "/usr/share/fonts/dejavu/DejaVuSerif.ttf",
50 "font.ttf" };
51#endif
52
53 for(int i = 0; i < fontCount; i++)
54 {
55 if(boost::filesystem::exists(fonts[i]))
56 return fonts[i];
57 }
58
59 LOG(LogError) << "Error - could not find a font!";
60
61 return "";
62}
63
64void Font::initLibrary()
65{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected