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

corrected vertical position of LaTeX Math fonts, but this may hurt the font? just wait for bugs

This commit is contained in:
Lu Wang 2012-08-30 01:01:45 +08:00
parent 19dbaa3149
commit 6f87affd82
8 changed files with 42 additions and 31 deletions

12
TODO
View File

@ -1,19 +1,17 @@
z-index for space span z-index for space span
fake space detection fake space detection -> Unicode U+200B
manpage manpage
disable selection if we know unicode is wrong
compress div/span
option to break ligatures option to break ligatures
check if we can add information to the font, and let browsers show ligatures automatically check if we can add information to the font, and let browsers show ligatures automatically
use absolute positioning for long whitespace use absolute positioning for long whitespace
solution/workaround for latex math fonts solution/workaround for latex math fonts
wiki page
- why the html looks ugly : use a modern web browser, use Linux/Mac, (enabling ClearType for Windows XP)
- why got incorrect text after copy&paste : try ligature or always-apply-unicode
- why text are so small : set --zoom or zoom in the page
- why images are blurred : set higher dpi
==Future== ==Future==
custom html/css custom html/css
native support for image native support for image

View File

@ -1,5 +1,4 @@
#pdf-main { #pdf-main {
font-family: sans-serif;
position:absolute; position:absolute;
top:0; top:0;
left:0; left:0;
@ -10,37 +9,38 @@
/* for Chrome & Safari */ /* for Chrome & Safari */
-webkit-text-stroke-width:0.13px; -webkit-text-stroke-width:0.13px;
} }
#pdf-main .p { .p {
position:relative; position:relative;
margin:13px auto; margin:13px auto;
background-color:white; background-color:white;
overflow:hidden; overflow:hidden;
display:none; display:none;
} }
#pdf-main .l { .l {
position:absolute; position:absolute;
white-space:pre; white-space:pre;
font-size:1px;
transform-origin:0% 100%;
-ms-transform-origin:0% 100%;
-moz-transform-origin:0% 100%;
-webkit-transform-origin:0% 100%;
-o-transform-origin:0% 100%;
}
#pdf-main span {
position:relative;
line-height:0; line-height:0;
height:0;
font-size:0;
transform-origin:0% 0%;
-ms-transform-origin:0% 0%;
-moz-transform-origin:0% 0%;
-webkit-transform-origin:0% 0%;
-o-transform-origin:0% 0%;
}
span {
position:relative;
vertical-align: baseline; vertical-align: baseline;
} }
#pdf-main ._ { ._ {
color:transparent; color:transparent;
} }
#pdf-main ::selection{ ::selection{
background: rgba(127,255,255,1); background: rgba(127,255,255,1);
} }
#pdf-main ::-moz-selection{ ::-moz-selection{
background: rgba(127,255,255,1); background: rgba(127,255,255,1);
} }
#pdf-main .i { .i {
position:absolute; position:absolute;
} }

View File

@ -18,6 +18,6 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
double originX, double originY, double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen) 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

@ -152,6 +152,7 @@ class HTMLRenderer : public OutputDev
void export_remote_font(long long fn_id, const std::string & suffix, const std::string & fontfileformat, GfxFont * font); void export_remote_font(long long fn_id, const std::string & suffix, const std::string & fontfileformat, GfxFont * font);
void export_remote_default_font(long long fn_id); void export_remote_default_font(long long fn_id);
void export_local_font(long long fn_id, GfxFont * font, const std::string & original_font_name, const std::string & cssfont); void export_local_font(long long fn_id, GfxFont * font, const std::string & original_font_name, const std::string & cssfont);
void export_font_size(long long fs_id, double font_size); void export_font_size(long long fs_id, double font_size);
void export_transform_matrix(long long tm_id, const double * tm); void export_transform_matrix(long long tm_id, const double * tm);
void export_letter_space(long long ls_id, double letter_space); void export_letter_space(long long ls_id, double letter_space);

View File

@ -12,6 +12,7 @@
#include "HTMLRenderer.h" #include "HTMLRenderer.h"
#include "namespace.h" #include "namespace.h"
#include "config.h"
using boost::algorithm::ifind_first; using boost::algorithm::ifind_first;
@ -29,9 +30,7 @@ void HTMLRenderer::export_remote_font(long long fn_id, const string & suffix, co
allcss_fout << fn; allcss_fout << fn;
} }
allcss_fout << format(")format(\"%1%\");}.f%|2$x|{font-family:f%|2$x|;") % fontfileformat % fn_id; allcss_fout << format(")format(\"%1%\");}.f%|2$x|{font-family:f%|2$x|;}") % fontfileformat % fn_id << endl;
allcss_fout << "}" << endl;
} }
static string general_font_family(GfxFont * font) static string general_font_family(GfxFont * font)
@ -66,7 +65,6 @@ void HTMLRenderer::export_local_font(long long fn_id, GfxFont * font, const stri
allcss_fout << "}" << endl; allcss_fout << "}" << endl;
} }
void HTMLRenderer::export_font_size (long long fs_id, double font_size) void HTMLRenderer::export_font_size (long long fs_id, double font_size)
{ {
allcss_fout << format(".s%|1$x|{font-size:%2%px;}") % fs_id % font_size << endl; allcss_fout << format(".s%|1$x|{font-size:%2%px;}") % fs_id % font_size << endl;

View File

@ -245,6 +245,20 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
if(ctu) if(ctu)
ctu->decRefCnt(); ctu->decRefCnt();
/*
* Fontforge cannot set the ***Ascent value for nonTTF fonts
* So save to a temp ttf file and open it again
*/
string tmpfn = fn + "_.ttf";
add_tmp_file(tmpfn);
script_fout << format("Generate(%1%)") % (tmp_dir / tmpfn) << endl;
script_fout << format("Open(%1%)") % (tmp_dir / tmpfn) << endl;
for(const string & key : {"Win", "Typo", "HHead"})
{
script_fout << "SetOS2Value(\"" << key << "Ascent\", 0)" << 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)
add_tmp_file(fn+".ttf"); add_tmp_file(fn+".ttf");

View File

@ -352,8 +352,8 @@ 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;bottom:%2%px;\" class=\"l t%|3$x|\"><em></em>") html_fout << format("<div style=\"left:%1%px;top:%2%px;\" class=\"l t%|3$x|\">")
% x % y % cur_tm_id; % x % (pageHeight-y) % cur_tm_id;
//resync position //resync position
draw_ty = cur_ty; draw_ty = cur_ty;