MCPcopy Create free account
hub / github.com/OGRECave/ogre / parseAttribute

Method parseAttribute

Components/Overlay/src/OgreOverlayTranslator.cpp:63–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61//! [font_translate]
62
63void FontTranslator::parseAttribute(ScriptCompiler* compiler, FontPtr& pFont, const AbstractNode& node)
64{
65 auto p = node.getProperty();
66 if (p.name == "glyph")
67 {
68 if (p.values.size() != 5)
69 {
70 compiler->addError(node);
71 return;
72 }
73
74 std::vector<float> coords(4);
75 for(size_t i = 0; i < 4; ++i)
76 {
77
78 if (!StringConverter::parse(p.values[1 + i], coords[i]))
79 {
80 compiler->addError(node);
81 return;
82 }
83 }
84
85 // Set
86 // Support numeric and character glyph specification
87 Font::CodePoint cp;
88 if (p.values[0].size() > 1 && p.values[0][0] == 'u')
89 {
90 // Unicode glyph spec
91 String trimmed = p.values[0].substr(1);
92 cp = StringConverter::parseUnsignedInt(trimmed);
93 }
94 else
95 {
96 // Direct character
97 cp = p.values[0][0];
98 }
99 pFont->setGlyphInfoFromTexCoords(
100 cp, FloatRect(coords[0], coords[1], coords[2], coords[3])); // assume image is square
101 }
102 else if (p.name == "antialias_colour")
103 {
104 bool flag;
105 if (p.values.empty() || !StringConverter::parse(p.values.front(), flag))
106 {
107 compiler->addError(node, BLANKSTRING, ScriptCompiler::CE_STRINGEXPECTED);
108 return;
109 }
110 pFont->setAntialiasColour(flag);
111 compiler->addError(node, p.name, ScriptCompiler::CE_DEPRECATEDSYMBOL);
112 }
113 else if(p.name == "merge_fonts")
114 {
115 if (p.values.empty())
116 {
117 compiler->addError(node);
118 return;
119 }
120

Callers

nothing calls this directly

Calls 8

parseUnsignedIntFunction · 0.85
addErrorMethod · 0.80
frontMethod · 0.80
getPropertyMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
getByNameMethod · 0.45
setParameterMethod · 0.45

Tested by

no test coverage detected