From 5cf7f2fdf2a6cc356d9d43078da394f4aaec147e Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Sat, 8 Sep 2012 10:24:04 +0800 Subject: [PATCH] add encoding confliction warning in the 2nd phase --- src/HTMLRenderer/text.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index d59999f..27d82c2 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -214,7 +214,6 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo & else { // move the slot such that it's consistent with the encoding seen in PDF - unordered_set nameset; bool name_conflict_warned = false; @@ -284,10 +283,12 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo & { + unordered_set codeset; + bool name_conflict_warned = false; + auto ctu = font->getToUnicode(); memset(cur_mapping, 0, maxcode * sizeof(int32_t)); - if(code2GID) maxcode = min(maxcode, code2GID_len - 1); @@ -322,7 +323,19 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo & u = unicode_from_font(i, font); } - cur_mapping[k] = u; + if(codeset.insert(u).second) + { + cur_mapping[k] = u; + } + else + { + if(!name_conflict_warned) + { + name_conflict_warned = true; + //TODO: may be resolved using advanced font properties? + cerr << "Warning: encoding confliction detected in font: " << hex << info.id << dec << endl; + } + } } ff_reencode_raw(cur_mapping, max_key + 1, 1);