summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src/FontManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dviware/dvisvgm/src/FontManager.cpp')
-rw-r--r--dviware/dvisvgm/src/FontManager.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/dviware/dvisvgm/src/FontManager.cpp b/dviware/dvisvgm/src/FontManager.cpp
index eabb4a3d30..929e9f823b 100644
--- a/dviware/dvisvgm/src/FontManager.cpp
+++ b/dviware/dvisvgm/src/FontManager.cpp
@@ -101,8 +101,14 @@ int FontManager::fontnum (int id) const {
int FontManager::vfFirstFontNum (const VirtualFont *vf) const {
+ auto it = _vfFirstFontNumMap.find(vf);
+ return (it == _vfFirstFontNumMap.end()) ? -1 : (int) it->second;
+}
+
+
+Font* FontManager::vfFirstFont (const VirtualFont *vf) const {
auto it = _vfFirstFontMap.find(vf);
- return (it == _vfFirstFontMap.end()) ? -1 : (int) it->second;
+ return (it == _vfFirstFontMap.end()) ? nullptr : it->second;
}
@@ -221,8 +227,10 @@ int FontManager::registerFont (uint32_t fontnum, const string &name, uint32_t ch
else { // register font referenced in vf file
const VirtualFont *vf = _vfStack.top();
_vfnum2id[vf][fontnum] = newid;
- if (_vfFirstFontMap.find(vf) == _vfFirstFontMap.end()) // first fontdef of VF?
- _vfFirstFontMap[vf] = fontnum;
+ if (_vfFirstFontNumMap.find(vf) == _vfFirstFontNumMap.end()) { // first fontdef of VF?
+ _vfFirstFontNumMap.emplace(vf, fontnum);
+ _vfFirstFontMap.emplace(vf, _fonts.back().get());
+ }
}
return newid;
}