| 247 | } |
| 248 | |
| 249 | void FontExportSerializer::generateFontManualXml( |
| 250 | MyGUI::xml::ElementPtr _root, |
| 251 | const MyGUI::UString& _folderName, |
| 252 | DataPtr _data) |
| 253 | { |
| 254 | MyGUI::IFont* resource = MyGUI::FontManager::getInstance().getByName(_data->getPropertyValue("FontName")); |
| 255 | MyGUI::ResourceTrueTypeFont* font = |
| 256 | resource != nullptr ? resource->castType<MyGUI::ResourceTrueTypeFont>(false) : nullptr; |
| 257 | |
| 258 | if (font != nullptr) |
| 259 | { |
| 260 | std::string textureName = _data->getPropertyValue("Name") + ".png"; |
| 261 | MyGUI::ITexture* texture = font->getTextureFont(); |
| 262 | if (texture == nullptr) |
| 263 | return; |
| 264 | texture->saveToFile( |
| 265 | MyGUI::UString(common::concatenatePath(_folderName, MyGUI::UString(textureName))).asUTF8()); |
| 266 | |
| 267 | MyGUI::xml::ElementPtr node = _root->createChild("Resource"); |
| 268 | node->addAttribute("type", "ResourceManualFont"); |
| 269 | node->addAttribute("name", _data->getPropertyValue("Name")); |
| 270 | |
| 271 | addProperty(node, "Source", textureName); |
| 272 | addProperty(node, "Shader", _data->getPropertyValue("Shader")); |
| 273 | addProperty(node, "DefaultHeight", font->getDefaultHeight()); |
| 274 | |
| 275 | MyGUI::xml::Element* codes = node->createChild("Codes"); |
| 276 | |
| 277 | std::vector<std::pair<MyGUI::Char, MyGUI::Char>> codePointRanges = font->getCodePointRanges(); |
| 278 | MyGUI::Char substituteCodePoint = font->getSubstituteCodePoint(); |
| 279 | bool isCustomSubstituteCodePoint = substituteCodePoint != MyGUI::FontCodeType::NotDefined; |
| 280 | |
| 281 | // Add all of the code points. Skip over the substitute code point -- unless it's been customized, in which case it |
| 282 | // needs to be added here as a regular code point and then at the end as a substitute code point. |
| 283 | for (const auto& rarnge : codePointRanges) |
| 284 | for (MyGUI::Char code = rarnge.first; code <= rarnge.second && code >= rarnge.first; ++code) |
| 285 | if (code != substituteCodePoint || isCustomSubstituteCodePoint) |
| 286 | addCode(codes, code, font, false); |
| 287 | |
| 288 | // Always add the substitute code point last, even if it isn't the last one in the range. |
| 289 | addCode(codes, substituteCodePoint, font, true); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | void FontExportSerializer::generateFont(DataPtr _data) |
| 294 | { |
nothing calls this directly
no test coverage detected