| 143 | } |
| 144 | |
| 145 | std::set<unsigned int>* BMFontConfiguration::parseConfigFile(std::string_view controlFile) |
| 146 | { |
| 147 | std::string data = FileUtils::getInstance()->getStringFromFile(controlFile); |
| 148 | if (data.empty()) |
| 149 | { |
| 150 | return nullptr; |
| 151 | } |
| 152 | if (data.size() >= (sizeof("BMP") - 1) && memcmp("BMF", data.c_str(), sizeof("BMP") - 1) == 0) |
| 153 | { |
| 154 | // Handle fnt file of binary format |
| 155 | std::set<unsigned int>* ret = parseBinaryConfigFile((unsigned char*)&data.front(), static_cast<uint32_t>(data.size()), controlFile); |
| 156 | return ret; |
| 157 | } |
| 158 | if (data[0] == 0) |
| 159 | { |
| 160 | AXLOGW("axmol: Error parsing FNTfile {}", controlFile); |
| 161 | return nullptr; |
| 162 | } |
| 163 | auto contents = data.c_str(); |
| 164 | |
| 165 | std::set<unsigned int>* validCharsString = new std::set<unsigned int>(); |
| 166 | |
| 167 | auto contentsLen = strlen(contents); |
| 168 | char line[512] = {0}; |
| 169 | |
| 170 | auto next = strchr(contents, '\n'); |
| 171 | auto base = contents; |
| 172 | size_t parseCount = 0; |
| 173 | while (next) |
| 174 | { |
| 175 | size_t lineLength = ((int)(next - base)); |
| 176 | memcpy(line, contents + parseCount, lineLength); |
| 177 | line[lineLength] = 0; |
| 178 | |
| 179 | parseCount += lineLength + 1; |
| 180 | if (parseCount < contentsLen) |
| 181 | { |
| 182 | base = next + 1; |
| 183 | next = strchr(base, '\n'); |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | next = nullptr; |
| 188 | } |
| 189 | |
| 190 | if (memcmp(line, "info face", 9) == 0) |
| 191 | { |
| 192 | // FIXME: info parsing is incomplete |
| 193 | // Not needed for the Hiero editors, but needed for the AngelCode editor |
| 194 | // [self parseInfoArguments:line]; |
| 195 | this->parseInfoArguments(line); |
| 196 | } |
| 197 | // Check to see if the start of the line is something we are interested in |
| 198 | else if (memcmp(line, "common lineHeight", 17) == 0) |
| 199 | { |
| 200 | this->parseCommonArguments(line); |
| 201 | } |
| 202 | else if (memcmp(line, "page id", 7) == 0) |
no test coverage detected