added debugging messages to getCharID().
[swftools.git] / pdf2swf / swfoutput.cc
index 4402785..b4c1229 100644 (file)
@@ -1001,8 +1001,10 @@ struct fontlist_t
     fontlist_t*next;
 } *fontlist = 0;
 
-/* todo: why don't higher values (64, 1024) work here? */
-#define FONT_INTERNAL_SIZE 1
+/* Notice: we can only put chars in the range -1639,1638 (-32768/20,32768/20).
+   So if we set this value to high, the char coordinates will overflow.
+   If we set it to low, however, the char positions will be inaccurate */
+#define FONT_INTERNAL_SIZE 4
 
 /* process a character. */
 static int drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int charnr, int u, swfmatrix*m)
@@ -1142,6 +1144,7 @@ int getCharID(SWFFONT *font, int charnr, char *charname, int u)
     if(charname) {
        for(t=0;t<font->numchars;t++) {
            if(font->glyphnames[t] && !strcmp(font->glyphnames[t],charname)) {
+               msg("<debug> Char [%d,>%s<,%d] maps to %d\n", charnr, charname, u, t);
                return t;
            }
        }
@@ -1149,6 +1152,7 @@ int getCharID(SWFFONT *font, int charnr, char *charname, int u)
           we can find the capitalized version */
        for(t=0;t<font->numchars;t++) {
            if(font->glyphnames[t] && !strcasecmp(font->glyphnames[t],charname)) {
+               msg("<debug> Char [%d,>>%s<<,%d] maps to %d\n", charnr, charname, u, t);
                return t;
            }
        }
@@ -1157,11 +1161,13 @@ int getCharID(SWFFONT *font, int charnr, char *charname, int u)
     if(u>0) {
        /* try to use the unicode id */
        if(u>=0 && u<font->maxascii && font->ascii2glyph[u]>=0) {
+           msg("<debug> Char [%d,%s,>%d<] maps to %d\n", charnr, charname, u, font->ascii2glyph[u]);
            return font->ascii2glyph[u];
        }
     }
 
     if(charnr>=0 && charnr<font->numchars) {
+       msg("<debug> Char [>%d<,%s,%d] maps to %d\n", charnr, charname, u, charnr);
        return charnr;
     }
 
@@ -1170,6 +1176,7 @@ int getCharID(SWFFONT *font, int charnr, char *charname, int u)
           is US-ASCII based. It's needed for fonts which return broken unicode
           indices */
        if(charnr>=0 && charnr<font->maxascii && font->ascii2glyph[charnr]>=0) {
+           msg("<debug> Char [>%d<,%s,%d] maps to %d\n", charnr, charname, u, font->ascii2glyph[charnr]);
            return font->ascii2glyph[charnr];
        }
     }
@@ -1400,7 +1407,6 @@ static void startshape(struct swfoutput*obj)
   shapeid = ++currentswfid;
   swf_SetU16(tag,shapeid);  // ID
 
-  /* TODO: patch back */
   bboxrectpos = tag->len;
   r.xmin = 0;
   r.ymin = 0;