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

logic for hinting

This commit is contained in:
Lu Wang 2012-09-24 01:55:35 +08:00
parent 9847860a4a
commit 01f546efce
4 changed files with 23 additions and 13 deletions

View File

@ -95,9 +95,9 @@ Specify a ratio greater than 1 would resolve this issue, however it might freeze
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: 0)
If set to 1, hints will be generated for the fonts.
If set to 1, hints will be generated for the fonts using fontforge.
This switch is experimental which may break other things.
This may be overrided by --external-hint-tool. This switch is experimental which may break other things.
.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.
@ -122,7 +122,7 @@ If it's empty, the file name will be determined automatically.
Specify the suffix and format of fonts extracted from the PDF file. They should be consistent.
.TP
.B --external-hint-tool <tool> (Default: "")
If specified, the tool will be called in order to enhanced hinting for fonts.
If specified, the tool will be called in order to enhanced hinting for fonts, this will override --auto-hint.
The tool will be called as '<tool> <in.suffix> <out.suffix>', where suffix will be the same as specified for --font-suffix.
.TP

View File

@ -161,9 +161,6 @@ 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;
int maxcode = 0;
@ -184,7 +181,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
const char * used_map = nullptr;
ffw_metric(&info.ascent, &info.descent, &info.em_size);
info.em_size = ffw_get_em_size();
if(param->debug)
{
@ -415,7 +412,16 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
rename(fn.c_str(), tmp_fn.c_str());
if(system((char*)str_fmt("%s \"%s\" \"%s\"", param->external_hint_tool.c_str(), tmp_fn.c_str(), fn.c_str())) != 0)
{
rename(tmp_fn.c_str(), fn.c_str());
if(param->auto_hint)
{
ffw_load_font(tmp_fn.c_str());
ffw_auto_hint();
ffw_save(fn.c_str());
}
else
{
rename(tmp_fn.c_str(), fn.c_str());
}
}
}
@ -425,7 +431,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
*/
rename(fn.c_str(), tmp_fn.c_str());
ffw_load_font(tmp_fn.c_str());
ffw_metric(&info.ascent, &info.descent, &info.em_size);
ffw_metric(&info.ascent, &info.descent);
ffw_save(fn.c_str());
ffw_close();

View File

@ -215,7 +215,12 @@ void ffw_close(void)
cur_fv = NULL;
}
void ffw_metric(double * ascent, double * descent, int * em_size)
int ffw_get_em_size(void)
{
return cur_fv->sf->ascent + cur_fv->sf->descent;
}
void ffw_metric(double * ascent, double * descent)
{
SplineFont * sf = cur_fv->sf;
struct pfminfo * info = &sf->pfminfo;
@ -227,8 +232,6 @@ void ffw_metric(double * ascent, double * descent, int * em_size)
DBounds bb;
SplineFontFindBounds(sf, &bb);
*em_size = sf->ascent + sf->descent;
/*
printf("bb %lf %lf\n", bb.maxy, bb.miny);
printf("_ %d %d\n", sf->ascent, sf->descent);

View File

@ -30,8 +30,9 @@ void ffw_cidflatten(void);
void ffw_save(const char * filename);
void ffw_close(void);
int ffw_get_em_size(void);
// fix metrics and get them
void ffw_metric(double * ascent, double * descent, int * em_size);
void ffw_metric(double * ascent, double * descent);
void ffw_set_widths(int * width_list, int mapping_len);