the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "UI.h"
3#include "..\..\..\Minecraft.World\StringHelpers.h"
4#include "..\..\..\Minecraft.World\File.h"
5#include "UITTFFont.h"
6
7UITTFFont::UITTFFont(const string &name, const string &path, S32 fallbackCharacter)
8 : m_strFontName(name)
9{
10 app.DebugPrintf("UITTFFont opening %s\n",path.c_str());
11
12#ifdef _UNICODE
13 wstring wPath = convStringToWstring(path);
14 HANDLE file = CreateFile(wPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
15#else
16 HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
17#endif
18 if( file == INVALID_HANDLE_VALUE )
19 {
20 DWORD error = GetLastError();
21 app.DebugPrintf("Failed to open TTF file with error code %d (%x)\n", error, error);
22 assert(false);
23 }
24
25 DWORD dwHigh=0;
26 DWORD dwFileSize = GetFileSize(file,&dwHigh);
27
28 if(dwFileSize!=0)
29 {
30 DWORD bytesRead;
31
32 pbData = (PBYTE) new BYTE[dwFileSize];
33 BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL);
34 if(bSuccess==FALSE)
35 {
36 app.FatalLoadError();
37 }
38 CloseHandle(file);
39
40 IggyFontInstallTruetypeUTF8 ( (void *)pbData, IGGY_TTC_INDEX_none, m_strFontName.c_str(), -1, IGGY_FONTFLAG_none );
41
42 IggyFontInstallTruetypeFallbackCodepointUTF8( m_strFontName.c_str(), -1, IGGY_FONTFLAG_none, fallbackCharacter );
43
44 // 4J Stu - These are so we can use the default flash controls
45 IggyFontInstallTruetypeUTF8 ( (void *)pbData, IGGY_TTC_INDEX_none, "Times New Roman", -1, IGGY_FONTFLAG_none );
46 IggyFontInstallTruetypeUTF8 ( (void *)pbData, IGGY_TTC_INDEX_none, "Arial", -1, IGGY_FONTFLAG_none );
47 }
48}
49
50UITTFFont::~UITTFFont()
51{
52}
53
54
55string UITTFFont::getFontName()
56{
57 return m_strFontName;
58}