| 1074 | } |
| 1075 | |
| 1076 | bool ResourcePool::LoadSpriteFont(const char* name, const std::wstring& path, bool mipmaps)LNOEXCEPT |
| 1077 | { |
| 1078 | LDEBUG_RESOURCETIMER; |
| 1079 | |
| 1080 | { |
| 1081 | LDEBUG_RESOURCESCOPE; |
| 1082 | |
| 1083 | LASSERT(LAPP.GetRenderer()); |
| 1084 | |
| 1085 | if (m_SpriteFontPool.find(name) != m_SpriteFontPool.end()) |
| 1086 | { |
| 1087 | LWARNING("LoadFont: ����'%m'�Ѵ��ڣ����ز����ѱ�ȡ��", name); |
| 1088 | return true; |
| 1089 | } |
| 1090 | |
| 1091 | std::unordered_map<wchar_t, f2dGlyphInfo> tOutputCharset; |
| 1092 | std::wstring tOutputTextureName; |
| 1093 | |
| 1094 | // ��ȡ�ļ� |
| 1095 | fcyRefPointer<fcyMemStream> tDataBuf; |
| 1096 | if (!m_pMgr->LoadFile(path.c_str(), tDataBuf)) |
| 1097 | return false; |
| 1098 | |
| 1099 | // ת������ |
| 1100 | wstring tFileData; |
| 1101 | try |
| 1102 | { |
| 1103 | if (tDataBuf->GetLength() > 0) |
| 1104 | { |
| 1105 | // stupid |
| 1106 | tFileData = fcyStringHelper::MultiByteToWideChar(string((const char*)tDataBuf->GetInternalBuffer(), (size_t)tDataBuf->GetLength()), CP_UTF8); |
| 1107 | } |
| 1108 | } |
| 1109 | catch (const bad_alloc&) |
| 1110 | { |
| 1111 | LERROR("LoadFont: ת������ʱ�������ڴ�"); |
| 1112 | return false; |
| 1113 | } |
| 1114 | |
| 1115 | // ��ȡHGE���嶨�� |
| 1116 | try |
| 1117 | { |
| 1118 | ResFont::HGEFont::ReadDefine(tFileData, tOutputCharset, tOutputTextureName); |
| 1119 | } |
| 1120 | catch (const fcyException& e) |
| 1121 | { |
| 1122 | LERROR("LoadFont: װ��HGE���嶨���ļ�'%s'ʧ�� (�쳣��Ϣ'%m' Դ'%m')", path.c_str(), e.GetDesc(), e.GetSrc()); |
| 1123 | return false; |
| 1124 | } |
| 1125 | catch (const bad_alloc&) |
| 1126 | { |
| 1127 | LERROR("LoadFont: �ڴ治��"); |
| 1128 | return false; |
| 1129 | } |
| 1130 | |
| 1131 | // װ������ |
| 1132 | try |
| 1133 | { |
no test coverage detected