From 92c929777e027e642f31c37e841650f0620aec71 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Mon, 27 Aug 2012 07:26:30 +0800 Subject: [PATCH] working... --- src/HTMLRenderer/install.cc | 7 +------ src/HTMLRenderer/text.cc | 13 ++----------- src/util.h | 8 ++++++++ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/HTMLRenderer/install.cc b/src/HTMLRenderer/install.cc index b40a8db..27a7b43 100644 --- a/src/HTMLRenderer/install.cc +++ b/src/HTMLRenderer/install.cc @@ -143,12 +143,7 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix, n = ctu->mapToUnicode(c, &u); } - if((n == 0) || (n > 1) || (!isLegalUnicode(*u))) - { - return (Unicode)(c + 0xE000); - } - else - return *u; + return check_unicode(u, n, c); }; if(!font->isCIDFont()) diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index 9f720f8..020765f 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -196,17 +196,8 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s) ++nSpaces; } - // TODO: don't use ToUnicode Map for nonttf fonts - - if((uLen > 0) && (all_of(u, u+uLen, isLegalUnicode))) - { - outputUnicodes(html_fout, u, uLen); - } - else - { - Unicode u = 0xE000 + code; - outputUnicodes(html_fout, &u, 1); - } + Unicode uu = check_unicode(u, uLen, code); + outputUnicodes(html_fout, &uu, 1); dx += dx1; dy += dy1; diff --git a/src/util.h b/src/util.h index 1e7a740..1b5c7a2 100644 --- a/src/util.h +++ b/src/util.h @@ -65,6 +65,14 @@ static inline bool isLegalUnicode(Unicode u) return true; } +static inline Unicode check_unicode(Unicode * u, int len, CharCode code) +{ + if((len == 0) || (len > 1) || (!isLegalUnicode(*u))) + return (Unicode)(code + 0xE000); + else + return *u; +} + static inline void outputUnicodes(std::ostream & out, const Unicode * u, int uLen) { for(int i = 0; i < uLen; ++i)