From 661b1aa92ab04e3494ad6db1a76cf1732ff18c62 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 21 Sep 2012 18:12:14 +0800 Subject: [PATCH] tweaking font-size-multiplier and auto-hint --- README.md | 6 +++++- pdf2htmlEX.1.in | 2 +- src/HTMLRenderer/text.cc | 1 + src/ffw.c | 26 ++++++++++++++------------ src/pdf2htmlEX.cc | 4 ++-- test/test.py | 2 +- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 706542c..77a8403 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ MacPorts and Homebrew are coming soon ### 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 @@ -79,6 +79,10 @@ I've tested with CYGWIN without any problem, and I believe it also works on MinG pdf2htmlEX --help +## FAQ + +[here](https://github.com/coolwanglu/pdf2htmlEX/wiki/FAQ) + ## LICENSE GPLv2 & GPLv3 Dual licensed diff --git a/pdf2htmlEX.1.in b/pdf2htmlEX.1.in index 18917d3..98cff1d 100644 --- a/pdf2htmlEX.1.in +++ b/pdf2htmlEX.1.in @@ -87,7 +87,7 @@ pdf2htmlEX would try to optimize the generated HTML file moving Text within this .B --space-threshold (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. .TP -.B --font-size-multiplier (Default: 1.0) +.B --font-size-multiplier (Default: 3.0) 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. diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index 35032a1..2244ca6 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -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) + { ffw_load_font(filepath.c_str()); if(param->auto_hint) diff --git a/src/ffw.c b/src/ffw.c index c5b24ee..43b4f35 100644 --- a/src/ffw.c +++ b/src/ffw.c @@ -260,19 +260,19 @@ void ffw_metric(double * ascent, double * descent, int * em_size) sf->ascent = min(floor(bb.maxy+0.5), em); sf->descent = em - bb.maxy; - info->os2_winascent = a; - info->os2_typoascent = a; - info->hhead_ascent = a; - info->winascent_add = 0; - info->typoascent_add = 0; - info->hheadascent_add = 0; + info->os2_winascent = 0; + info->os2_typoascent = 0; + info->hhead_ascent = 0; + info->winascent_add = 1; + info->typoascent_add = 1; + info->hheadascent_add = 1; - info->os2_windescent = -d; - info->os2_typodescent = d; - info->hhead_descent = d; - info->windescent_add = 0; - info->typodescent_add = 0; - info->hheaddescent_add = 0; + info->os2_windescent = 0; + info->os2_typodescent = 0; + info->hhead_descent = 0; + info->windescent_add = 1; + info->typodescent_add = 1; + info->hheaddescent_add = 1; info->os2_typolinegap = 0; info->linegap = 0; @@ -310,6 +310,8 @@ void ffw_auto_hint(void) // convert to quadratic if(!(cur_fv->sf->layers[ly_fore].order2)) { + return; + SFCloseAllInstrs(cur_fv->sf); SFConvertToOrder2(cur_fv->sf); } diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 77f1c97..9c507ec 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -73,8 +73,8 @@ void parse_options (int argc, char **argv) .add("heps", ¶m.h_eps, 1.0, "max tolerated horizontal offset (in pixels)") .add("veps", ¶m.v_eps, 1.0, "max tolerated vertical offset (in pixels)") .add("space-threshold", ¶m.space_threshold, (1.0/8), "distance no thiner than (threshold * em) will be considered as a space character") - .add("font-size-multiplier", ¶m.font_size_multiplier, 1.0, "setting a value greater than 1 would increase the rendering accuracy") - .add("auto-hint", ¶m.auto_hint, 0, "[Experimental] Whether to generate hints for fonts") + .add("font-size-multiplier", ¶m.font_size_multiplier, 3.0, "setting a value greater than 1 would increase the rendering accuracy") + .add("auto-hint", ¶m.auto_hint, 1, "[Experimental] Whether to generate hints for fonts") .add("tounicode", ¶m.tounicode, 0, "Specify how to deal with ToUnicode map, 0 for auto, 1 for forced, -1 for disabled") .add("space-as-offset", ¶m.space_as_offset, 0, "treat space characters as offsets") diff --git a/test/test.py b/test/test.py index 5b1b7d3..0fa0f74 100755 --- a/test/test.py +++ b/test/test.py @@ -11,7 +11,7 @@ with open('out.html','w') as outf: if not f.lower().endswith('.pdf'): continue 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] outf.write('%s
' % (ff,ff)) outf.flush();