@@ -351,22 +351,25 @@ void DVIToSVG::embedFonts () {
351351 if (!_actions) // no dvi actions => no chars written => no fonts to embed
352352 return ;
353353
354+ auto usedFonts = FontManager::instance ().getUniqueFonts ();
354355 auto &usedCharsMap = FontManager::instance ().getUsedChars ();
355356 collect_chars (usedCharsMap);
356357
357358 GlyphTracerMessages messages;
358359 unordered_set<const Font*> tracedFonts; // collect unique fonts already traced
359- for (const auto &fontchar : usedCharsMap) {
360- const Font *font = fontchar.first ;
360+ for (auto font : usedFonts) {
361361 if (auto ph_font = font_cast<const PhysicalFont*>(font)) {
362362 // Check if glyphs should be traced. Only trace the glyphs of unique fonts, i.e.
363363 // avoid retracing the same glyphs again if they are referenced in various sizes.
364364 if (TRACE_MODE != 0 && tracedFonts.find (ph_font->uniqueFont ()) == tracedFonts.end ()) {
365365 ph_font->traceAllGlyphs (TRACE_MODE == ' a' , &messages);
366366 tracedFonts.insert (ph_font->uniqueFont ());
367367 }
368- if (font->path ()) // does font file exist?
369- _svg.append (*ph_font, fontchar.second , &messages);
368+ if (font->path ()) { // does font file exist?
369+ auto it = usedCharsMap.find (font);
370+ if (it != usedCharsMap.end ())
371+ _svg.append (*ph_font, it->second , &messages);
372+ }
370373 else
371374 Message::wstream (true ) << " can't embed font '" << font->name () << " '\n " ;
372375 }
0 commit comments