| 93 | } |
| 94 | |
| 95 | void 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 | |
| 140 | void DefaultTeXFontParser::parseExtraPath() throw(ex_res_parse) { |
| 141 | const XMLElement* syms = _root->FirstChildElement("TeXSymbols"); |
nothing calls this directly
no test coverage detected