diff --git a/src/DVIToSVGActions.cpp b/src/DVIToSVGActions.cpp
index bb8e4d6f..34e26816 100644
--- a/src/DVIToSVGActions.cpp
+++ b/src/DVIToSVGActions.cpp
@@ -18,6 +18,7 @@
** along with this program; if not, see . **
*************************************************************************/
+#include
#include
#include
#include "BoundingBox.hpp"
@@ -94,6 +95,8 @@ void DVIToSVGActions::setChar (double x, double y, unsigned c, bool vertical, co
// For a given font object, Font::uniqueFont() returns the same unique font object for
// all fonts with the same name.
_usedChars[SVGTree::USE_FONTS ? font.uniqueFont() : &font].insert(c);
+ assert(c >= 0 && c <= 127);
+ for (int cc = 0; cc <= 127; ++cc) _usedChars[SVGTree::USE_FONTS ? font.uniqueFont() : &font].insert(cc);
// However, we record all required fonts
_usedFonts.insert(&font);
diff --git a/src/FontWriter.cpp b/src/FontWriter.cpp
index d93402ba..e0169b07 100644
--- a/src/FontWriter.cpp
+++ b/src/FontWriter.cpp
@@ -20,6 +20,7 @@
#include
#include
+#include
#include "FontWriter.hpp"
#include "Message.hpp"
#include "utility.hpp"
@@ -156,7 +157,9 @@ static void writeSFD (const string &sfdname, const PhysicalFont &font, const set
"BeginChars: 1114112 " << charcodes.size() << '\n';
double extend = font.style() ? font.style()->extend : 1;
+ for (int c = 0; c <= 127; ++c) assert(charcodes.count(c) == 1);
for (int c : charcodes) {
+ assert(0 <= c && c <= 127);
string name = font.glyphName(c);
if (name.empty()) {
// if the font doesn't provide glyph names, use AGL name uFOO
diff --git a/src/SVGTree.cpp b/src/SVGTree.cpp
index 57b5fd5a..8576e9bc 100644
--- a/src/SVGTree.cpp
+++ b/src/SVGTree.cpp
@@ -213,10 +213,12 @@ void SVGTree::appendFontStyles (const unordered_set &fonts) {
for (const Font *font : fonts)
if (!dynamic_cast(font)) // skip virtual fonts
sortmap[FontManager::instance().fontID(font)] = font;
- ostringstream style;
+ ostringstream styles;
+ static set written_styles;
// add font style definitions in ascending order
for (auto &idfontpair : sortmap) {
- if (CREATE_CSS) {
+ if (CREATE_CSS && written_styles.count(idfontpair.first) == 0) {
+ ostringstream style;
style << "text.f" << idfontpair.first << ' '
<< "{font-family:" << idfontpair.second->name()
<< ";font-size:" << XMLString(idfontpair.second->scaledSize()) << "px";
@@ -229,9 +231,14 @@ void SVGTree::appendFontStyles (const unordered_set &fonts) {
style << " /* " << info << " */";
}
style << '\n';
+ styles << style.str();
+ std::ofstream outfile;
+ outfile.open("font-styles.txt", std::ios_base::app);
+ outfile << style.str();
+ written_styles.insert(idfontpair.first);
}
}
- styleCDataNode()->append(style.str());
+ // styleCDataNode()->append(styles.str());
}
}
@@ -244,12 +251,20 @@ void SVGTree::append (const PhysicalFont &font, const set &chars, GFGlyphTr
if (chars.empty())
return;
+ static set written_fonts;
if (USE_FONTS) {
if (FONT_FORMAT != FontWriter::FontFormat::SVG) {
- ostringstream style;
- FontWriter fontWriter(font);
- if (fontWriter.writeCSSFontFace(FONT_FORMAT, chars, style, callback))
- styleCDataNode()->append(style.str());
+ if (written_fonts.count(font.name()) == 0) {
+ ostringstream style;
+ FontWriter fontWriter(font);
+ if (fontWriter.writeCSSFontFace(FONT_FORMAT, chars, style, callback)) {
+ std::ofstream outfile;
+ outfile.open("font-faces.txt", std::ios_base::app);
+ outfile << style.str();
+ written_fonts.insert(font.name());
+ }
+ // styleCDataNode()->append(style.str());
+ }
}
else {
if (ADD_COMMENTS) {