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

unify asc/dsc for ff/chrome, need more work

This commit is contained in:
Lu Wang 2012-08-31 10:10:06 +08:00
parent d72c5123e8
commit 6916ffb91b
4 changed files with 19 additions and 4 deletions

View File

@ -18,6 +18,6 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen)
{
// SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code, nBytes, u, uLen);
SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code, nBytes, u, uLen);
}

View File

@ -251,9 +251,9 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
if(ctu)
ctu->decRefCnt();
auto dest = ((param->single_html ? tmp_dir : dest_dir) / (fn+".ttf"));
auto dest = ((param->single_html ? tmp_dir : dest_dir) / (fn+(param->font_suffix)));
if(param->single_html)
add_tmp_file(fn+".ttf");
add_tmp_file(fn+(param->font_suffix));
script_fout << format("Generate(%1%)") % dest << endl;
script_fout << "Close()" << endl;
@ -267,6 +267,17 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
}
}
/*
* Firefox & Chrome interprets the values in different ways
* Trying to unify them
*/
script_fout << "a=GetOS2Value(\"TypoAscent\")" << endl;
script_fout << "d=GetOS2Value(\"TypoDescent\")" << endl;
script_fout << "SetOS2Value(\"TypoAscent\", 0)" << endl;
script_fout << "SetOS2Value(\"TypoDescent\", -a-d)" << endl;
script_fout << format("Generate(%1%)") % dest << endl;
if(system((boost::format("fontforge -script %1% 1>%2% 2>%3%") % script_path % (tmp_dir / (fn+".info")) % (tmp_dir / NULL_FILENAME)).str().c_str()) != 0)
cerr << "Warning: fontforge failed." << endl;
@ -302,7 +313,7 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
cerr << "Ascent: " << info.ascent << " Descent: " << info.descent << endl;
}
export_remote_font(info, ".ttf", "truetype", font);
export_remote_font(info, param->font_suffix, param->font_format, font);
}
void HTMLRenderer::install_base_font(GfxFont * font, GfxFontLoc * font_loc, long long fn_id)

View File

@ -29,6 +29,8 @@ struct Param
int single_html;
int always_apply_tounicode;
std::string font_suffix, font_format;
int debug;
int clean_tmp;
};

View File

@ -74,6 +74,8 @@ po::variables_map parse_options (int argc, char **argv)
("veps", po::value<double>(&param.v_eps)->default_value(1.0), "max tolerated vertical offset (in pixels)")
("single-html", po::value<int>(&param.single_html)->default_value(1), "combine everything into one single HTML file")
("always-apply-tounicode", po::value<int>(&param.always_apply_tounicode)->default_value(0), "ToUnicode map is ignore for non-TTF fonts unless this switch is on")
("font-suffix", po::value<string>(&param.font_suffix)->default_value(".ttf"), "suffix for extracted font files")
("font-format", po::value<string>(&param.font_format)->default_value("truetype"), "format for extracted font files")
("process-nontext", po::value<int>(&param.process_nontext)->default_value(1), "process nontext objects")
("debug", po::value<int>(&param.debug)->default_value(0), "output debug information")
("clean-tmp", po::value<int>(&param.clean_tmp)->default_value(1), "clean temporary files after processing")