From 6916ffb91bbadd23af9977e8c3d544b4220df1b8 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 31 Aug 2012 10:10:06 +0800 Subject: [PATCH] unify asc/dsc for ff/chrome, need more work --- src/BackgroundRenderer.cc | 2 +- src/HTMLRenderer/install.cc | 17 ++++++++++++++--- src/Param.h | 2 ++ src/pdf2htmlEX.cc | 2 ++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/BackgroundRenderer.cc b/src/BackgroundRenderer.cc index 2a6dd3f..aad7f99 100644 --- a/src/BackgroundRenderer.cc +++ b/src/BackgroundRenderer.cc @@ -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); } diff --git a/src/HTMLRenderer/install.cc b/src/HTMLRenderer/install.cc index bc61763..0096845 100644 --- a/src/HTMLRenderer/install.cc +++ b/src/HTMLRenderer/install.cc @@ -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) diff --git a/src/Param.h b/src/Param.h index 3570f5d..ba96cc0 100644 --- a/src/Param.h +++ b/src/Param.h @@ -29,6 +29,8 @@ struct Param int single_html; int always_apply_tounicode; + std::string font_suffix, font_format; + int debug; int clean_tmp; }; diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 6a41f5f..46629fd 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -74,6 +74,8 @@ po::variables_map parse_options (int argc, char **argv) ("veps", po::value(¶m.v_eps)->default_value(1.0), "max tolerated vertical offset (in pixels)") ("single-html", po::value(¶m.single_html)->default_value(1), "combine everything into one single HTML file") ("always-apply-tounicode", po::value(¶m.always_apply_tounicode)->default_value(0), "ToUnicode map is ignore for non-TTF fonts unless this switch is on") + ("font-suffix", po::value(¶m.font_suffix)->default_value(".ttf"), "suffix for extracted font files") + ("font-format", po::value(¶m.font_format)->default_value("truetype"), "format for extracted font files") ("process-nontext", po::value(¶m.process_nontext)->default_value(1), "process nontext objects") ("debug", po::value(¶m.debug)->default_value(0), "output debug information") ("clean-tmp", po::value(¶m.clean_tmp)->default_value(1), "clean temporary files after processing")