mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
working on external font hint tool
This commit is contained in:
parent
201fecb18e
commit
9e7f34bd5a
@ -121,6 +121,11 @@ If it's empty, the file name will be determined automatically.
|
||||
.B --font-suffix <suffix> (Default: ".ttf"), --font-format <format> (Default: "truetype")
|
||||
Specify the suffix and format of fonts extracted from the PDF file. They should be consistent.
|
||||
.TP
|
||||
.B --external-hint-tool <tool> (Default: "")
|
||||
If specified, the tool will be called in order to enhanced hinting for fonts.
|
||||
|
||||
The tool will be called as '<tool> <in.suffix> <out.suffix>', where suffix will be the same as specified for --font-suffix.
|
||||
.TP
|
||||
.B --debug <0|1> (Default: 0)
|
||||
Show debug information.
|
||||
.TP
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user