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

fix width of type 3 fonts; don't show hidden text for type 3 fonts

This commit is contained in:
Lu Wang 2013-01-19 20:13:31 +08:00
parent da8a18c2d9
commit d274d4f6c8
5 changed files with 35 additions and 7 deletions

View File

@ -69,6 +69,7 @@ public:
bool use_tounicode;
int em_size;
double ascent, descent;
bool is_type3;
};
class GfxRGB_hash

View File

@ -58,7 +58,7 @@ public:
class Offset {
public:
size_t start_idx; // should put this idx before text[start_idx];
size_t start_idx; // should put this Offset right before text[start_idx];
double width;
};

View File

@ -37,16 +37,26 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font)
long long new_fn_id = font_name_map.size();
auto cur_info_iter = font_name_map.insert(make_pair(fn_id, FontInfo({new_fn_id, true}))).first;
auto cur_info_iter = font_name_map.insert(make_pair(fn_id, FontInfo())).first;
FontInfo & new_font_info = cur_info_iter->second;
new_font_info.id = new_fn_id;
new_font_info.use_tounicode = true;
if(font == nullptr)
{
new_font_info.ascent = 0;
new_font_info.descent = 0;
new_font_info.is_type3 = false;
export_remote_default_font(new_fn_id);
return &(cur_info_iter->second);
return &(new_font_info);
}
cur_info_iter->second.ascent = font->getAscent();
cur_info_iter->second.descent = font->getDescent();
new_font_info.ascent = font->getAscent();
new_font_info.descent = font->getDescent();
new_font_info.is_type3 = (font->getType() == fontType3);
if(param->debug)
{

View File

@ -100,7 +100,17 @@ void HTMLRenderer::check_state_change(GfxState * state)
if(!(new_font_info->id == cur_font_info->id))
{
new_line_state = max<NewLineState>(new_line_state, NLS_SPAN);
// Currently Type 3 font are shown hidden in HTML, with default fonts (at viewers' machine)
// The width of the text displayed is likely to be wrong
// So we will create separate (absolute positioned) blocks for them, such that it won't affect other text
if(new_font_info->is_type3 || cur_font_info->is_type3)
{
new_line_state = max<NewLineState>(new_line_state, NLS_DIV);
}
else
{
new_line_state = max<NewLineState>(new_line_state, NLS_SPAN);
}
cur_font_info = new_font_info;
}

View File

@ -504,7 +504,14 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
return;
auto font = state->getFont();
if((font == nullptr) || (font->getWMode()))
// Writing mode fonts and Type 3 fonts are rendered as images
// I don't find a way to display writing mode fonts in HTML except for one div for each character, which is too costly
// For type 3 fonts, due to the font matrix, still it's hard to show it on HTML
if( (font == nullptr)
|| (font->getWMode())
|| (font->getType() == fontType3)
)
{
return;
}