1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

add 'auto-hint'

This commit is contained in:
Lu Wang 2012-09-21 16:51:13 +08:00
parent ec1898cc00
commit 6b60c08c7e
8 changed files with 17 additions and 8 deletions

6
TODO
View File

@ -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

View File

@ -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.

View File

@ -8,8 +8,6 @@
right:0;
overflow:auto;
background-color:grey;
/* for Chrome & Safari */
-webkit-text-stroke-width:0.13px;
}
.p {
position:relative;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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")

View File

@ -5,7 +5,7 @@ DIR = 'pdf'
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'):