1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00

tweaking font-size-multiplier and auto-hint

This commit is contained in:
Lu Wang 2012-09-21 18:12:14 +08:00
parent acfcb62bfc
commit 661b1aa92a
6 changed files with 24 additions and 17 deletions

View File

@ -54,7 +54,7 @@ MacPorts and Homebrew are coming soon
### Windows ### Windows
I've tested with CYGWIN without any problem, and I believe it also works on MinGW without many modifications. I have tested with CYGWIN without any problem, and I believe it also works on MinGW without many modifications.
### Build from source ### Build from source
@ -79,6 +79,10 @@ I've tested with CYGWIN without any problem, and I believe it also works on MinG
pdf2htmlEX --help pdf2htmlEX --help
## FAQ
[here](https://github.com/coolwanglu/pdf2htmlEX/wiki/FAQ)
## LICENSE ## LICENSE
GPLv2 & GPLv3 Dual licensed GPLv2 & GPLv3 Dual licensed

View File

@ -87,7 +87,7 @@ pdf2htmlEX would try to optimize the generated HTML file moving Text within this
.B --space-threshold <ratio> (Default: 1.0/6) .B --space-threshold <ratio> (Default: 1.0/6)
pdf2htmlEX would insert a whitespace character ' ' if the distance between two consecutive letters in the same line is wider than ratio * font_size. pdf2htmlEX would insert a whitespace character ' ' if the distance between two consecutive letters in the same line is wider than ratio * font_size.
.TP .TP
.B --font-size-multiplier <ratio> (Default: 1.0) .B --font-size-multiplier <ratio> (Default: 3.0)
Many web browsers limit the minimum font size, and many would round the given font size, which results in incorrect rendering. Many web browsers limit the minimum font size, and many would round the given font size, which results in incorrect rendering.
Specify a ratio greater than 1 would resolve this issue, however it might freeze some browsers. Specify a ratio greater than 1 would resolve this issue, however it might freeze some browsers.

View File

@ -159,6 +159,7 @@ string HTMLRenderer::dump_embedded_font (GfxFont * font, long long fn_id)
} }
void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo & info, bool get_metric_only) void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo & info, bool get_metric_only)
{ {
ffw_load_font(filepath.c_str()); ffw_load_font(filepath.c_str());
if(param->auto_hint) if(param->auto_hint)

View File

@ -260,19 +260,19 @@ void ffw_metric(double * ascent, double * descent, int * em_size)
sf->ascent = min(floor(bb.maxy+0.5), em); sf->ascent = min(floor(bb.maxy+0.5), em);
sf->descent = em - bb.maxy; sf->descent = em - bb.maxy;
info->os2_winascent = a; info->os2_winascent = 0;
info->os2_typoascent = a; info->os2_typoascent = 0;
info->hhead_ascent = a; info->hhead_ascent = 0;
info->winascent_add = 0; info->winascent_add = 1;
info->typoascent_add = 0; info->typoascent_add = 1;
info->hheadascent_add = 0; info->hheadascent_add = 1;
info->os2_windescent = -d; info->os2_windescent = 0;
info->os2_typodescent = d; info->os2_typodescent = 0;
info->hhead_descent = d; info->hhead_descent = 0;
info->windescent_add = 0; info->windescent_add = 1;
info->typodescent_add = 0; info->typodescent_add = 1;
info->hheaddescent_add = 0; info->hheaddescent_add = 1;
info->os2_typolinegap = 0; info->os2_typolinegap = 0;
info->linegap = 0; info->linegap = 0;
@ -310,6 +310,8 @@ void ffw_auto_hint(void)
// convert to quadratic // convert to quadratic
if(!(cur_fv->sf->layers[ly_fore].order2)) if(!(cur_fv->sf->layers[ly_fore].order2))
{ {
return;
SFCloseAllInstrs(cur_fv->sf); SFCloseAllInstrs(cur_fv->sf);
SFConvertToOrder2(cur_fv->sf); SFConvertToOrder2(cur_fv->sf);
} }

View File

@ -73,8 +73,8 @@ void parse_options (int argc, char **argv)
.add("heps", &param.h_eps, 1.0, "max tolerated horizontal offset (in pixels)") .add("heps", &param.h_eps, 1.0, "max tolerated horizontal offset (in pixels)")
.add("veps", &param.v_eps, 1.0, "max tolerated vertical offset (in pixels)") .add("veps", &param.v_eps, 1.0, "max tolerated vertical offset (in pixels)")
.add("space-threshold", &param.space_threshold, (1.0/8), "distance no thiner than (threshold * em) will be considered as a space character") .add("space-threshold", &param.space_threshold, (1.0/8), "distance no thiner than (threshold * em) will be considered as a space character")
.add("font-size-multiplier", &param.font_size_multiplier, 1.0, "setting a value greater than 1 would increase the rendering accuracy") .add("font-size-multiplier", &param.font_size_multiplier, 3.0, "setting a value greater than 1 would increase the rendering accuracy")
.add("auto-hint", &param.auto_hint, 0, "[Experimental] Whether to generate hints for fonts") .add("auto-hint", &param.auto_hint, 1, "[Experimental] Whether to generate hints for fonts")
.add("tounicode", &param.tounicode, 0, "Specify how to deal with ToUnicode map, 0 for auto, 1 for forced, -1 for disabled") .add("tounicode", &param.tounicode, 0, "Specify how to deal with ToUnicode map, 0 for auto, 1 for forced, -1 for disabled")
.add("space-as-offset", &param.space_as_offset, 0, "treat space characters as offsets") .add("space-as-offset", &param.space_as_offset, 0, "treat space characters as offsets")

View File

@ -11,7 +11,7 @@ with open('out.html','w') as outf:
if not f.lower().endswith('.pdf'): if not f.lower().endswith('.pdf'):
continue continue
print f print f
os.system('pdf2htmlEX -l 10 --dest-dir html "%s/%s"' % (DIR,f)) os.system('pdf2htmlEX --dest-dir html "%s/%s"' % (DIR,f))
ff = f[:-3] ff = f[:-3]
outf.write('<a href="html/%shtml" target="pdf">%s</a><br/>' % (ff,ff)) outf.write('<a href="html/%shtml" target="pdf">%s</a><br/>' % (ff,ff))
outf.flush(); outf.flush();