mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-05 09:38:40 +00:00
fix width of type 3 fonts; don't show hidden text for type 3 fonts
This commit is contained in:
parent
da8a18c2d9
commit
d274d4f6c8
|
@ -69,6 +69,7 @@ public:
|
||||||
bool use_tounicode;
|
bool use_tounicode;
|
||||||
int em_size;
|
int em_size;
|
||||||
double ascent, descent;
|
double ascent, descent;
|
||||||
|
bool is_type3;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GfxRGB_hash
|
class GfxRGB_hash
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
|
|
||||||
class Offset {
|
class Offset {
|
||||||
public:
|
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;
|
double width;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,16 +37,26 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font)
|
||||||
|
|
||||||
long long new_fn_id = font_name_map.size();
|
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)
|
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);
|
export_remote_default_font(new_fn_id);
|
||||||
return &(cur_info_iter->second);
|
|
||||||
|
return &(new_font_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_info_iter->second.ascent = font->getAscent();
|
new_font_info.ascent = font->getAscent();
|
||||||
cur_info_iter->second.descent = font->getDescent();
|
new_font_info.descent = font->getDescent();
|
||||||
|
new_font_info.is_type3 = (font->getType() == fontType3);
|
||||||
|
|
||||||
if(param->debug)
|
if(param->debug)
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,7 +100,17 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
||||||
|
|
||||||
if(!(new_font_info->id == cur_font_info->id))
|
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;
|
cur_font_info = new_font_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -504,7 +504,14 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto font = state->getFont();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user