From 6b60c08c7eed8cba71136878c3c596483eb58ab4 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 21 Sep 2012 16:51:13 +0800 Subject: [PATCH] add 'auto-hint' --- TODO | 6 +----- pdf2htmlEX.1.in | 3 +++ share/base.css | 2 -- src/HTMLRenderer/text.cc | 2 ++ src/ffw.c | 8 ++++++++ src/include/Param.h | 1 + src/pdf2htmlEX.cc | 1 + test/test.py | 2 +- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 4c08f1c..8d88412 100644 --- a/TODO +++ b/TODO @@ -6,14 +6,10 @@ option for tounicode-map get unicode from charname using fontforge (test with 'Font' croc.pdf) also for CID Type 0 - -round coordinate and check if it'll be faster - - -add fallback font for ' ', or create glyph for it rename single-html -> embed-font/image/css ... argument auto-completion +add fallback font for ' ', or create glyph for it ==Future== use absolute positioning for long whitespace diff --git a/pdf2htmlEX.1.in b/pdf2htmlEX.1.in index 7de13c4..1a03f05 100644 --- a/pdf2htmlEX.1.in +++ b/pdf2htmlEX.1.in @@ -94,6 +94,9 @@ Specify a ratio greater than 1 would resolve this issue. For some versions of Firefox, however, there will be a problem when the font size is too large, in which case a smaller value should be specified here. .TP +.B --auto-hint <0|1> (Default: 1) +If set to 1, hints will be generated for the fonts. +.TP .B --tounicode <-1|0|1> (Default: 0) A ToUnicode map may be provided for each font in PDF which indicates the 'meaning' of the characters. However often there is better "ToUnicode" info in Type 0/1 fonts, and sometimes the ToUnicode map provided is wrong. diff --git a/share/base.css b/share/base.css index 533a67f..cc27d01 100644 --- a/share/base.css +++ b/share/base.css @@ -8,8 +8,6 @@ right:0; overflow:auto; background-color:grey; - /* for Chrome & Safari */ - -webkit-text-stroke-width:0.13px; } .p { position:relative; diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index 221d2ab..35032a1 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -161,6 +161,8 @@ 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) + ffw_auto_hint(); int * code2GID = nullptr; int code2GID_len = 0; diff --git a/src/ffw.c b/src/ffw.c index ae24935..a9c9799 100644 --- a/src/ffw.c +++ b/src/ffw.c @@ -308,5 +308,13 @@ void ffw_set_widths(int * width_list, int mapping_len) void ffw_auto_hint(void) { + // convert to quadratic + if(!(cur_fv->sf->layers[ly_fore].order2)) + { + SFCloseAllInstrs(cur_fv->sf); + SFConvertToOrder2(cur_fv->sf); + } + memset(cur_fv->selected, 1, cur_fv->map->enccount); FVAutoHint(cur_fv); + FVAutoInstr(cur_fv); } diff --git a/src/include/Param.h b/src/include/Param.h index 4381feb..9b162f0 100644 --- a/src/include/Param.h +++ b/src/include/Param.h @@ -39,6 +39,7 @@ struct Param double h_eps, v_eps; double space_threshold; double font_size_multiplier; + int auto_hint; int tounicode; int space_as_offset; diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 6df9bc8..30aacc1 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -74,6 +74,7 @@ void parse_options (int argc, char **argv) .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, 10.0, "setting a value greater than 1 would increase the rendering accuracy") + .add("auto-hint", ¶m.auto_hint, 1, "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 bb98161..5b1b7d3 100755 --- a/test/test.py +++ b/test/test.py @@ -5,7 +5,7 @@ DIR = 'pdf' import os with open('out.html','w') as outf: - outf.write('
') + outf.write('\n
') for f in os.listdir(DIR): if not f.lower().endswith('.pdf'):