1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-06-30 23:49:00 +00:00

new option --process-type3

This commit is contained in:
Lu Wang 2013-09-21 13:56:57 +08:00
parent 7c0505ffec
commit 09203f61a4
3 changed files with 21 additions and 7 deletions

View File

@ -184,6 +184,13 @@ Clear the fstype bits in TTF/OTF fonts.
Turn this on if Internet Explorer complains about 'Permission must be Installable' AND you have permission to do so.
.TP
.B --process-type3 <0|1> (Default: 0)
If turned on, pdf2htmlEX will try to convert Type 3 fonts such that text can be rendered natively in HTML.
Otherwise all text with Type 3 fonts will be rendered as image.
This feature is highly experimental.
.SS Text
.TP

View File

@ -210,10 +210,10 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
tm_transform_bbox(font_matrix, transformed_bbox);
double transformed_bbox_width = transformed_bbox[2] - transformed_bbox[0];
double transformed_bbox_height = transformed_bbox[3] - transformed_bbox[1];
// we want the glyphs is rendered in a box of size around 100 x 100
// for rectangles, the longer edge should be 100
info.font_size_scale = std::max(transformed_bbox_width, transformed_bbox_height);
// we want the glyphs is rendered in a box of size around GLYPH_DUMP_EM_SIZE x GLYPH_DUMP_EM_SIZE
// for rectangles, the longer edge should be GLYPH_DUMP_EM_SIZE
const double GLYPH_DUMP_EM_SIZE = 100.0;
double scale = GLYPH_DUMP_EM_SIZE / info.font_size_scale;
@ -242,6 +242,7 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
auto glyph_width = ((Gfx8BitFont*)font)->getWidth(code);
#if 1
{
// pain the glyph
cairo_set_font_face(cr, cur_font->getFontFace());
@ -273,8 +274,7 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
double dummy = 0;
cairo_matrix_transform_distance(&m2, &glyph_width, &dummy);
}
/*
#else
{
// manually draw the char to get the metrics
// adapted from _render_type3_glyph of poppler
@ -308,6 +308,7 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
// calculate the position of origin
cairo_matrix_transform_point(&ctm, &ox, &oy);
oy -= transformed_bbox_height * scale;
// calculate glyph width
double dummy = 0;
cairo_matrix_transform_distance(&ctm, &glyph_width, &dummy);
@ -337,7 +338,7 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
delete gfx;
delete output_dev;
}
*/
#endif
{
auto status = cairo_status(cr);

View File

@ -146,6 +146,7 @@ void parse_options (int argc, char **argv)
.add("stretch-narrow-glyph", &param.stretch_narrow_glyph, 0, "stretch narrow glyphs instead of padding them")
.add("squeeze-wide-glyph", &param.squeeze_wide_glyph, 1, "shrink wide glyphs instead of truncating them")
.add("override-fstype", &param.override_fstype, 0, "clear the fstype bits in TTF/OTF fonts")
.add("process-type3", &param.process_type3, 0, "convert Type 3 fonts for web (experimental)")
// text
.add("heps", &param.h_eps, 1.0, "horizontal threshold for merging text, in pixels")
@ -299,8 +300,13 @@ void check_param()
exit(EXIT_FAILURE);
}
//test
param.process_type3 = 1;
#if not ENABLE_SVG
if(param.process_type3)
{
cerr << "process-type3 is enabled, however SVG support is not built in this version of pdf2htmlEX." << endl;
exit(EXIT_FAILURE);
}
#endif
}
int main(int argc, char **argv)