MCPcopy Create free account
hub / github.com/MyGUI/mygui / addCode

Function addCode

Tools/FontEditor/FontExportSerializer.cpp:205–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 }
204
205 static void addCode(
206 MyGUI::xml::Element* _node,
207 MyGUI::Char _code,
208 MyGUI::ResourceTrueTypeFont* _font,
209 bool _isSubstitute)
210 {
211 MyGUI::xml::Element* codeNode = _node->createChild("Code");
212
213 if (!_isSubstitute)
214 {
215 switch (_code)
216 {
217 case MyGUI::FontCodeType::Selected: codeNode->addAttribute("index", "selected"); break;
218
219 case MyGUI::FontCodeType::SelectedBack: codeNode->addAttribute("index", "selected_back"); break;
220
221 case MyGUI::FontCodeType::Cursor: codeNode->addAttribute("index", "cursor"); break;
222
223 default: codeNode->addAttribute("index", _code); break;
224 }
225 }
226 else
227 {
228 codeNode->addAttribute("index", "substitute");
229 }
230
231 const MyGUI::GlyphInfo* info = _font->getGlyphInfo(_code);
232 MyGUI::ITexture* texture = _font->getTextureFont();
233 MyGUI::FloatCoord coord(
234 info->uvRect.left * (float)texture->getWidth(),
235 info->uvRect.top * (float)texture->getHeight(),
236 info->width,
237 info->height);
238
239 if (!coord.empty())
240 codeNode->addAttribute("coord", coord);
241
242 if (info->bearingX != 0.0f || info->bearingY != 0.0f)
243 codeNode->addAttribute("bearing", MyGUI::FloatPoint(info->bearingX, info->bearingY));
244
245 if (info->advance != info->width)
246 codeNode->addAttribute("advance", info->advance);
247 }
248
249 void FontExportSerializer::generateFontManualXml(
250 MyGUI::xml::ElementPtr _root,

Callers 1

generateFontManualXmlMethod · 0.85

Calls 8

createChildMethod · 0.80
addAttributeMethod · 0.80
FloatPointFunction · 0.50
getGlyphInfoMethod · 0.45
getTextureFontMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected