Skip to content

Commit

Permalink
add 'auto-hint'
Browse files Browse the repository at this point in the history
  • Loading branch information
coolwanglu committed Sep 21, 2012
1 parent ec1898c commit 6b60c08
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
6 changes: 1 addition & 5 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pdf2htmlEX.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 0 additions & 2 deletions share/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
right:0;
overflow:auto;
background-color:grey;
/* for Chrome & Safari */
-webkit-text-stroke-width:0.13px;
}
.p {
position:relative;
Expand Down
2 changes: 2 additions & 0 deletions src/HTMLRenderer/text.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/ffw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions src/include/Param.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/pdf2htmlEX.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void parse_options (int argc, char **argv)
.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("font-size-multiplier", &param.font_size_multiplier, 10.0, "setting a value greater than 1 would increase the rendering accuracy")
.add("auto-hint", &param.auto_hint, 1, "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("space-as-offset", &param.space_as_offset, 0, "treat space characters as offsets")

Expand Down
2 changes: 1 addition & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os

with open('out.html','w') as outf:
outf.write('<html><head><meta charset=\"utf-8\"></head><body><div style="position:absolute;top:0;left:0;width:80%;height:100%;"><iframe width="100%" height="100%" name="pdf"></iframe></div><div style="position:absolute;top:0;right:0;width:20%;height:100%;overflow:auto;text-align:right;">')
outf.write('<!DOCTYPE html>\n<html><head><meta charset=\"utf-8\"></head><body><div style="position:absolute;top:0;left:0;width:80%;height:100%;"><iframe width="100%" height="100%" name="pdf"></iframe></div><div style="position:absolute;top:0;right:0;width:20%;height:100%;overflow:auto;text-align:right;">')

for f in os.listdir(DIR):
if not f.lower().endswith('.pdf'):
Expand Down

0 comments on commit 6b60c08

Please sign in to comment.