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

better solution to the ascent/descent problem

This commit is contained in:
Lu Wang 2012-08-30 08:39:49 +08:00
parent 18e4c644f5
commit 02d5cbf244
3 changed files with 11 additions and 5 deletions

View File

@ -19,8 +19,6 @@
.l { .l {
position:absolute; position:absolute;
white-space:pre; white-space:pre;
line-height:0;
height:0;
font-size:0; font-size:0;
transform-origin:0% 0%; transform-origin:0% 0%;
-ms-transform-origin:0% 0%; -ms-transform-origin:0% 0%;

View File

@ -8,6 +8,7 @@
*/ */
#include <iostream> #include <iostream>
#include <cmath>
#include <boost/format.hpp> #include <boost/format.hpp>
@ -18,6 +19,7 @@
#include "namespace.h" #include "namespace.h"
using std::all_of; using std::all_of;
using std::round;
FontInfo HTMLRenderer::install_font(GfxFont * font) FontInfo HTMLRenderer::install_font(GfxFont * font)
{ {
@ -257,7 +259,10 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
for(const string & key : {"Win", "Typo", "HHead"}) for(const string & key : {"Win", "Typo", "HHead"})
{ {
script_fout << "SetOS2Value(\"" << key << "Ascent\", 0)" << endl; script_fout << format("SetOS2Value(\"%1%Ascent\", %2%)") % key % (int)round(font->getAscent() * 1000) << endl;
script_fout << format("SetOS2Value(\"%1%AscentIsOffset\", 0)") % key << endl;
script_fout << format("SetOS2Value(\"%1%Descent\", %2%)") % key % (int)round(-font->getDescent() * 1000) << endl;
script_fout << format("SetOS2Value(\"%1%DescentIsOffset\", 0)") % key << endl;
} }
script_fout << format("Generate(%1%)") % ((param->single_html ? tmp_dir : dest_dir) / (fn+".ttf")) << endl; script_fout << format("Generate(%1%)") % ((param->single_html ? tmp_dir : dest_dir) / (fn+".ttf")) << endl;
if(param->single_html) if(param->single_html)

View File

@ -352,8 +352,11 @@ void HTMLRenderer::prepare_line(GfxState * state)
double x,y; // in user space double x,y; // in user space
state->transform(state->getCurX(), state->getCurY(), &x, &y); state->transform(state->getCurX(), state->getCurY(), &x, &y);
html_fout << format("<div style=\"left:%1%px;top:%2%px;\" class=\"l t%|3$x|\">") html_fout << format("<div style=\"left:%1%px;top:%2%px;bottom:%3%px;\" class=\"l t%|4$x|\">")
% x % (pageHeight-y) % cur_tm_id; % x
% (pageHeight - y - state->getFont()->getAscent() * draw_font_size)
% (y + state->getFont()->getDescent() * draw_font_size)
% cur_tm_id;
//resync position //resync position
draw_ty = cur_ty; draw_ty = cur_ty;