diff --git a/src/HTMLRenderer/font.cc b/src/HTMLRenderer/font.cc
index f13fac6..7665748 100644
--- a/src/HTMLRenderer/font.cc
+++ b/src/HTMLRenderer/font.cc
@@ -346,12 +346,13 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
{
+ string map_filename;
ofstream map_outf;
if(param.debug)
{
- string fn = (char*)str_fmt("%s/f%llx.map", param.tmp_dir.c_str(), info.id);
- tmp_files.add(fn);
- map_outf.open(fn);
+ map_filename = (char*)str_fmt("%s/f%llx.map", param.tmp_dir.c_str(), info.id);
+ tmp_files.add(map_filename);
+ map_outf.open(map_filename);
}
unordered_set codeset;
@@ -427,7 +428,8 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
cur_code = -1;
if(param.debug)
{
- map_outf.seekp(0);
+ map_outf.close();
+ map_outf.open(map_filename);
}
continue;
}
diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc
index daafcea..dc7ae3a 100644
--- a/src/HTMLRenderer/general.cc
+++ b/src/HTMLRenderer/general.cc
@@ -396,9 +396,23 @@ void HTMLRenderer::post_process(void)
continue;
}
- if(line.empty()
- || (line.find_first_not_of(' ') == string::npos)
- || line[0] == '#')
+ // trim space at both sides
+ {
+ static const char * whitespaces = " \t\n\v\f\r";
+ auto idx1 = line.find_first_not_of(whitespaces);
+ if(idx1 == string::npos)
+ {
+ line.clear();
+ }
+ else
+ {
+ auto idx2 = line.find_last_not_of(whitespaces);
+ assert(idx2 >= idx1);
+ line = line.substr(idx1, idx2 - idx1 + 1);
+ }
+ }
+
+ if(line.empty() || line[0] == '#')
continue;