diff --git a/src/HTMLRenderer/HTMLRenderer.h b/src/HTMLRenderer/HTMLRenderer.h
index fd8ef07..7c34a4b 100644
--- a/src/HTMLRenderer/HTMLRenderer.h
+++ b/src/HTMLRenderer/HTMLRenderer.h
@@ -69,6 +69,7 @@ public:
bool use_tounicode;
int em_size;
double ascent, descent;
+ bool is_type3;
};
class GfxRGB_hash
diff --git a/src/HTMLRenderer/TextLineBuffer.h b/src/HTMLRenderer/TextLineBuffer.h
index 40cdcb6..5919a3f 100644
--- a/src/HTMLRenderer/TextLineBuffer.h
+++ b/src/HTMLRenderer/TextLineBuffer.h
@@ -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;
};
diff --git a/src/HTMLRenderer/install.cc b/src/HTMLRenderer/install.cc
index ea3efa7..b540434 100644
--- a/src/HTMLRenderer/install.cc
+++ b/src/HTMLRenderer/install.cc
@@ -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)
{
diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc
index 4115eef..d394cc0 100644
--- a/src/HTMLRenderer/state.cc
+++ b/src/HTMLRenderer/state.cc
@@ -100,7 +100,17 @@ void HTMLRenderer::check_state_change(GfxState * state)
if(!(new_font_info->id == cur_font_info->id))
{
- new_line_state = max(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(new_line_state, NLS_DIV);
+ }
+ else
+ {
+ new_line_state = max(new_line_state, NLS_SPAN);
+ }
cur_font_info = new_font_info;
}
diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc
index 1ccf254..c1069d7 100644
--- a/src/HTMLRenderer/text.cc
+++ b/src/HTMLRenderer/text.cc
@@ -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;
}