mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
Better solution for ascent/descent
but need more work when: - different styles in the same line - non-embedded fonts (that we cannot find the correct ascent/descent)
This commit is contained in:
parent
02d5cbf244
commit
4b1aff0da5
2
TODO
2
TODO
@ -1,5 +1,7 @@
|
|||||||
better solution for ascent/descent (cross-platform, embeded/not)
|
better solution for ascent/descent (cross-platform, embeded/not)
|
||||||
|
|
||||||
|
option to embed local matched fonts for non-embedded ones
|
||||||
|
|
||||||
fake space detection
|
fake space detection
|
||||||
take care of spaces (simulate by <span>)
|
take care of spaces (simulate by <span>)
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
position:absolute;
|
position:absolute;
|
||||||
white-space:pre;
|
white-space:pre;
|
||||||
font-size:0;
|
font-size:0;
|
||||||
transform-origin:0% 0%;
|
transform-origin:0% 190%;
|
||||||
-ms-transform-origin:0% 0%;
|
-ms-transform-origin:0% 100%;
|
||||||
-moz-transform-origin:0% 0%;
|
-moz-transform-origin:0% 100%;
|
||||||
-webkit-transform-origin:0% 0%;
|
-webkit-transform-origin:0% 100%;
|
||||||
-o-transform-origin:0% 0%;
|
-o-transform-origin:0% 100%;
|
||||||
}
|
}
|
||||||
span {
|
span {
|
||||||
position:relative;
|
position:relative;
|
||||||
|
@ -30,7 +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 << endl;
|
allcss_fout << format(")format(\"%1%\");}.f%|2$x|{font-family:f%|2$x|;line-height:%3%;}") % fontfileformat % fn_id % (font->getAscent() - font->getDescent()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string general_font_family(GfxFont * font)
|
static string general_font_family(GfxFont * font)
|
||||||
@ -62,6 +62,8 @@ void HTMLRenderer::export_local_font(long long fn_id, GfxFont * font, const stri
|
|||||||
else if(font->isItalic() || ifind_first(original_font_name, "italic"))
|
else if(font->isItalic() || ifind_first(original_font_name, "italic"))
|
||||||
allcss_fout << "font-style:italic;";
|
allcss_fout << "font-style:italic;";
|
||||||
|
|
||||||
|
allcss_fout << "line-height:" << (font->getAscent() - font->getDescent()) << ";";
|
||||||
|
|
||||||
allcss_fout << "}" << endl;
|
allcss_fout << "}" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,23 +247,6 @@ 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 << 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)
|
||||||
add_tmp_file(fn+".ttf");
|
add_tmp_file(fn+".ttf");
|
||||||
|
@ -352,11 +352,14 @@ 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;bottom:%3%px;\" class=\"l t%|4$x|\">")
|
// TODO class for height
|
||||||
|
html_fout << format("<div style=\"left:%1%px;bottom:%2%px;height:%4%px;line-height:%5%px;\" class=\"l t%|3$x|\">")
|
||||||
% x
|
% x
|
||||||
% (pageHeight - y - state->getFont()->getAscent() * draw_font_size)
|
% y
|
||||||
% (y + state->getFont()->getDescent() * draw_font_size)
|
% cur_tm_id
|
||||||
% cur_tm_id;
|
% (state->getFont()->getAscent() * draw_font_size)
|
||||||
|
% (2*(state->getFont()->getAscent() * draw_font_size))
|
||||||
|
;
|
||||||
|
|
||||||
//resync position
|
//resync position
|
||||||
draw_ty = cur_ty;
|
draw_ty = cur_ty;
|
||||||
|
Loading…
Reference in New Issue
Block a user