/** Replaces the map data of the given font. * If the font is locked (because it's already in use) nothing happens. * @param[in] mapline parsed font data * @return true if data has been replaced */ bool FontMap::replace (const MapLine &mapline) { if (mapline.texname().empty()) return false; if (mapline.fontfname().empty() && mapline.encname().empty()) return remove(mapline); vector<Subfont*> subfonts; if (mapline.sfd()) mapline.sfd()->subfonts(subfonts); else subfonts.push_back(nullptr); for (Subfont *subfont : subfonts) { string fontname = mapline.texname()+(subfont ? subfont->id() : ""); auto it = _entries.find(fontname); if (it == _entries.end()) _entries.emplace(fontname, util::make_unique<Entry>(mapline, subfont)); else if (!it->second->locked) *it->second = Entry(mapline, subfont); } return true; }
/** Appends given map line data to the font map if there is no entry for the corresponding * font in the map yet. * @param[in] mapline parsed font data * @return true if data has been appended */ bool FontMap::append (const MapLine &mapline) { bool appended = false; if (!mapline.texname().empty()) { if (!mapline.fontfname().empty() || !mapline.encname().empty()) { vector<Subfont*> subfonts; if (mapline.sfd()) mapline.sfd()->subfonts(subfonts); else subfonts.push_back(nullptr); for (Subfont *subfont : subfonts) { string fontname = mapline.texname()+(subfont ? subfont->id() : ""); auto it = _entries.find(fontname); if (it == _entries.end()) { _entries.emplace(fontname, util::make_unique<Entry>(mapline, subfont)); appended = true; } } } } return appended; }
FontMap::Entry::Entry (const MapLine &mapline, Subfont *sf) : fontname(mapline.fontfname()), encname(mapline.encname()), subfont(sf), fontindex(mapline.fontindex()), locked(false), style(mapline.bold(), mapline.extend(), mapline.slant()) { }