diff --git a/pdf2htmlEX.1.in b/pdf2htmlEX.1.in
index c2fe5e7..767b195 100644
--- a/pdf2htmlEX.1.in
+++ b/pdf2htmlEX.1.in
@@ -121,6 +121,11 @@ If it's empty, the file name will be determined automatically.
.B --font-suffix (Default: ".ttf"), --font-format (Default: "truetype")
Specify the suffix and format of fonts extracted from the PDF file. They should be consistent.
.TP
+.B --external-hint-tool (Default: "")
+If specified, the tool will be called in order to enhanced hinting for fonts.
+
+The tool will be called as ' ', where suffix will be the same as specified for --font-suffix.
+.TP
.B --debug <0|1> (Default: 0)
Show debug information.
.TP
diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc
index 8d9b9cd..788b386 100644
--- a/src/HTMLRenderer/text.cc
+++ b/src/HTMLRenderer/text.cc
@@ -393,23 +393,38 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
*
* Generate the font as desired
*
+ */
+ string tmp_fn = (char*)str_fmt("%s/__font%s", param->tmp_dir.c_str(), param->font_suffix.c_str());
+ add_tmp_file(tmp_fn);
+ string fn = (char*)str_fmt("%s/f%llx%s",
+ (param->single_html ? param->tmp_dir : param->dest_dir).c_str(),
+ info.id, param->font_suffix.c_str());
+
+ if(param->single_html)
+ add_tmp_file(fn);
+
+ ffw_save(fn.c_str());
+ ffw_close();
+
+ /*
+ * Step 4
* Reload to retrieve accurate ascent/descent <-- TODO: remove this
*/
+ rename(fn.c_str(), tmp_fn.c_str());
+ ffw_load_font(tmp_fn.c_str());
+ ffw_metric(&info.ascent, &info.descent, &info.em_size);
+ ffw_save(fn.c_str());
+ ffw_close();
+
+ /*
+ * Step 5 (keeping the scope)
+ * Call external hinting program
+ */
+
+ if(param->external_hint_tool != "")
{
- auto fn = str_fmt("%s/f%llx%s",
- (param->single_html ? param->tmp_dir : param->dest_dir).c_str(),
- info.id, param->font_suffix.c_str());
-
- if(param->single_html)
- add_tmp_file((char*)fn);
-
- ffw_save((char*)fn);
- ffw_close();
-
- ffw_load_font((char*)fn);
- ffw_metric(&info.ascent, &info.descent, &info.em_size);
- ffw_save((char*)fn);
- ffw_close();
+ rename(fn.c_str(), tmp_fn.c_str());
+ system((char*)str_fmt("%s %s %s", param->external_hint_tool.c_str(), tmp_fn.c_str(), fn.c_str()));
}
}
diff --git a/src/include/Param.h b/src/include/Param.h
index 9b162f0..f29d7e9 100644
--- a/src/include/Param.h
+++ b/src/include/Param.h
@@ -46,6 +46,8 @@ struct Param
std::string css_filename;
std::string font_suffix, font_format;
+ std::string external_hint_tool;
+
int debug;
int clean_tmp;
};
diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc
index a24bdfc..5cec6df 100644
--- a/src/pdf2htmlEX.cc
+++ b/src/pdf2htmlEX.cc
@@ -81,6 +81,7 @@ void parse_options (int argc, char **argv)
.add("css-filename", ¶m.css_filename, "", "Specify the file name of the generated css file")
.add("font-suffix", ¶m.font_suffix, ".ttf", "suffix for extracted font files")
.add("font-format", ¶m.font_format, "opentype", "format for extracted font files")
+ .add("external-hint-tool", ¶m.external_hint_tool, "", "external tool for hintting fonts")
.add("debug", ¶m.debug, 0, "output debug information")
.add("clean-tmp", ¶m.clean_tmp, 1, "clean temporary files after processing")