MCPcopy Create free account
hub / github.com/NanoMichael/MicroTeX / parseStyleMappings

Method parseStyleMappings

src/res/parser/font_parser.cpp:95–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void DefaultTeXFontParser::parseStyleMappings(
96 _out_ map<string, vector<CharFont*>>& res) throw(ex_res_parse) {
97 const XMLElement* mapping = _root->FirstChildElement("TextStyleMappings");
98 // no defined style mappings
99 if (mapping == nullptr) return;
100#ifdef HAVE_LOG
101 __dbg("TextStyleMappings tag name: %s\n", mapping->Name());
102#endif // HAVE_LOG
103 // iterate all mappings
104 mapping = mapping->FirstChildElement("TextStyleMapping");
105 while (mapping != nullptr) {
106 const string textStyleName = getAttrValueAndCheckIfNotNull("name", mapping);
107 string boldFontId = "";
108 obtainAttr("bold", mapping, boldFontId);
109 // parse range
110 const XMLElement* range = mapping->FirstChildElement("MapRange");
111#ifdef HAVE_LOG
112 __dbg("MapRange tag name: %s\n", range->Name());
113#endif // HAVE_LOG
114 vector<CharFont*> charFonts(4);
115 while (range != nullptr) {
116 const string fontId = getAttrValueAndCheckIfNotNull("fontId", range);
117 int ch = getIntAndCheck("start", range);
118 const string code = getAttrValueAndCheckIfNotNull("code", range);
119 // find the code mapping
120 auto it = _rangeTypeMappings.find(code);
121 if (it == _rangeTypeMappings.end()) {
122 throw ex_xml_parse(
123 RESOURCE_NAME,
124 "MapRange", "code", "contains an unknown 'range name' '" + code + "'!");
125 }
126 CharFont* f = nullptr;
127 if (boldFontId.empty()) {
128 f = new CharFont((wchar_t)ch, __id(fontId));
129 } else {
130 f = new CharFont((wchar_t)ch, __id(fontId), __id(boldFontId));
131 }
132 charFonts[it->second] = f;
133 range = range->NextSiblingElement("MapRange");
134 }
135 res[textStyleName] = charFonts;
136 mapping = mapping->NextSiblingElement("TextStyleMapping");
137 }
138}
139
140void DefaultTeXFontParser::parseExtraPath() throw(ex_res_parse) {
141 const XMLElement* syms = _root->FirstChildElement("TeXSymbols");

Callers

nothing calls this directly

Calls 4

ex_xml_parseClass · 0.85
FirstChildElementMethod · 0.80
NameMethod · 0.80
NextSiblingElementMethod · 0.80

Tested by

no test coverage detected