From eba7ba10fa1cb6e8b6d76d1eb6a9f2fb8c340d4a Mon Sep 17 00:00:00 2001 From: kramm Date: Wed, 7 Dec 2005 19:40:36 +0000 Subject: [PATCH] removed extra treatment for space characters, because a) It creates problems with some PDFs (e.g. Indesign) b) We *do* need to draw them, or otherwise text extraction out of the SWFs will fail. --- pdf2swf/SWFOutputDev.cc | 64 +++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index b54f1e6..fd9cdc0 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -1119,8 +1119,22 @@ char* makeStringPrintable(char*str) int getGfxCharID(gfxfont_t*font, int charnr, char *charname, int u) { - int t; + char*uniname = 0; + if(u>0) { + int t; + /* find out char name from unicode index + TODO: should be precomputed + */ + for(t=0;tnum_glyphs;t++) { if(font->glyphs[t].name && !strcmp(font->glyphs[t].name,charname)) { msg(" Char [%d,>%s<,%d] maps to %d\n", charnr, charname, u, t); @@ -1137,17 +1151,30 @@ int getGfxCharID(gfxfont_t*font, int charnr, char *charname, int u) } } + if(uniname) { + int t; + for(t=0;tnum_glyphs;t++) { + if(font->glyphs[t].name && !strcmp(font->glyphs[t].name,uniname)) { + msg(" Char [%d,>%s<,%d] maps to %d\n", charnr, uniname, u, t); + return t; + } + } + /* if we didn't find the character, maybe + we can find the capitalized version */ + for(t=0;tnum_glyphs;t++) { + if(font->glyphs[t].name && !strcasecmp(font->glyphs[t].name,uniname)) { + msg(" Char [%d,>>%s<<,%d] maps to %d\n", charnr, uniname, u, t); + return t; + } + } + } + /* try to use the unicode id */ if(u>=0 && umax_unicode && font->unicode2glyph[u]>=0) { msg(" Char [%d,%s,>%d<] maps to %d\n", charnr, charname, u, font->unicode2glyph[u]); return font->unicode2glyph[u]; } - /* we don't need to "draw" space characters, so don't overdo the search - for a matching glyph */ - if(charname && !strcasecmp(charname, "space")) - return -1; - if(charnr>=0 && charnrnum_glyphs) { msg(" Char [>%d<,%s,%d] maps to %d\n", charnr, charname, u, charnr); return charnr; @@ -1214,22 +1241,6 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, Unicode u=0; char*name=0; - if(_u && uLen) { - u = *_u; - if (u) { - int t; - /* find out char name from unicode index - TODO: should be precomputed - */ - for(t=0;tisCIDFont()) { GfxCIDFont*cfont = (GfxCIDFont*)font; @@ -1239,9 +1250,7 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, Gfx8BitFont*font8; font8 = (Gfx8BitFont*)font; char**enc=font8->getEncoding(); - if(enc && enc[c] && strcasecmp(enc[c], "space")) { - name = enc[c]; - } + name = enc[c]; } if (CIDToGIDMap) { msg(" drawChar(%f, %f, c='%c' (%d), GID=%d, u=%d <%d>) CID=%d name=\"%s\" render=%d\n", x, y, (c&127)>=32?c:'?', c, CIDToGIDMap[c], u, uLen, font->isCIDFont(), FIXNULL(name), render); @@ -1255,7 +1264,8 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, if(uLen<=1) { charid = getGfxCharID(current_gfxfont, c, name, u); } else { - charid = getGfxCharID(current_gfxfont, c, 0, -1); + charid = getGfxCharID(current_gfxfont, c, name, -1); + if(charid < 0) { /* multiple unicodes- should usually map to a ligature. if the ligature doesn't exist, we need to draw @@ -1270,7 +1280,7 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, } if(charid<0) { - if(!name || strcasecmp(name, "space")) { + if(!name) { msg(" Didn't find character '%s' (c=%d,u=%d) in current charset (%s, %d characters)", FIXNULL(name),c, u, FIXNULL((char*)current_font_id), current_gfxfont->num_glyphs); } -- 1.7.10.4