git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added some error checks.
[swftools.git]
/
pdf2swf
/
swfoutput.cc
diff --git
a/pdf2swf/swfoutput.cc
b/pdf2swf/swfoutput.cc
index
63c33cb
..
5e5e4da
100644
(file)
--- a/
pdf2swf/swfoutput.cc
+++ b/
pdf2swf/swfoutput.cc
@@
-899,6
+899,11
@@
static void drawchar(struct swfoutput*obj, SWFFont*font, char*character, int cha
if(usefonts && ! drawonlyshapes)
{
int charid = font->getSWFCharID(character, charnr);
if(usefonts && ! drawonlyshapes)
{
int charid = font->getSWFCharID(character, charnr);
+ if(charid<0) {
+ msg("<warning> Didn't find character '%s' (%d) in current charset (%s)",
+ FIXNULL(character),charnr, FIXNULL(font->getName()));
+ return;
+ }
if(shapeid>=0)
endshape();
if(textid<0)
if(shapeid>=0)
endshape();
if(textid<0)
@@
-912,8
+917,8
@@
static void drawchar(struct swfoutput*obj, SWFFont*font, char*character, int cha
char* charname = character;
if(!outline) {
char* charname = character;
if(!outline) {
- msg("<warning> Didn't find %s in current charset (%s)",
- FIXNULL(character),FIXNULL(font->getName()));
+ msg("<warning> Didn't find character '%s' (%d) in current charset (%s)",
+ FIXNULL(character),charnr,FIXNULL(font->getName()));
return;
}
return;
}
@@
-991,13
+996,18
@@
SWFFont::SWFFont(char*name, int id, char*filename)
int t, outlinepos=0;
char*map[256];
int t, outlinepos=0;
char*map[256];
+ char*null = 0;
+ if(!a)
+ a=&null;
+
t=0;
while(a[t])
t++;
this->charnum = t;
t=0;
while(a[t])
t++;
this->charnum = t;
- if(!charnum)
- return;
+ if(!charnum) {
+ this->standardtablesize = 0;
+ }
msg("<verbose> Font %s(%d): Storing %d outlines.\n", FIXNULL(name), id, charnum);
this->standardtablesize = 256;
msg("<verbose> Font %s(%d): Storing %d outlines.\n", FIXNULL(name), id, charnum);
this->standardtablesize = 256;
@@
-1007,9
+1017,18
@@
SWFFont::SWFFont(char*name, int id, char*filename)
for(t = 0; t < this->standardtablesize; t++) {
char*name = T1_GetCharName(id,t);
for(t = 0; t < this->standardtablesize; t++) {
char*name = T1_GetCharName(id,t);
- if(!name)
- name = "";
+ char chh[2] = "";
+ chh[0] = t;
+ if(!name || !strstr(name, "notdef")) {
+ if(t<standardEncodingSize) {
+ name = standardEncodingNames[t];
+ }
+ if(!name) {
+ name = ""; //TODO: store something like <%d>
+ }
+ }
standardtable[t] = strdup(name);
standardtable[t] = strdup(name);
+ msg("<debug> Char %d is named %s\n", t, name);
}
outline = (T1_OUTLINE**)malloc(charnum*sizeof(T1_OUTLINE*));
}
outline = (T1_OUTLINE**)malloc(charnum*sizeof(T1_OUTLINE*));
@@
-1068,7
+1087,6
@@
SWFFont::SWFFont(char*name, int id, char*filename)
t=0;
}
}
t=0;
}
}
- printf("done\n");
}
/* free all tables, write out definefont tags */
}
/* free all tables, write out definefont tags */
@@
-1153,7
+1171,8
@@
SWFFont::~SWFFont()
}
free(ptr);
}
free(ptr);
- free(outline);
+ if(outline)
+ free(outline);
for(t=0;t<charnum;t++)
free(charname[t]);
for(t=0;t<standardtablesize;t++)
for(t=0;t<charnum;t++)
free(charname[t]);
for(t=0;t<standardtablesize;t++)
@@
-1187,10
+1206,10
@@
T1_OUTLINE*SWFFont::getOutline(char*name, int charnr)
/* if we didn't find it by name, use the names of the first 256 characters
of the font to try a new name based on charnr */
if(this->standardtable && charnr>=0 && charnr < this->standardtablesize) {
/* if we didn't find it by name, use the names of the first 256 characters
of the font to try a new name based on charnr */
if(this->standardtable && charnr>=0 && charnr < this->standardtablesize) {
- return getOutline(this->standardtable[charnr], -1);
+ T1_OUTLINE*ret = getOutline(this->standardtable[charnr], -1);
+ if(ret) return ret;
}
}
- msg("<warning> Didn't find character '%s' in font '%s'", FIXNULL(name), this->name);
return 0;
}
return 0;
}
@@
-1226,10
+1245,10
@@
int SWFFont::getSWFCharID(char*name, int charnr)
/* if we didn't find it by name, use the names of the first 256 (or so) characters
of the font to try a new name based on charnr */
if(this->standardtable && charnr>=0 && charnr < this->standardtablesize) {
/* if we didn't find it by name, use the names of the first 256 (or so) characters
of the font to try a new name based on charnr */
if(this->standardtable && charnr>=0 && charnr < this->standardtablesize) {
- return getSWFCharID(this->standardtable[charnr], -1);
+ int ret = getSWFCharID(this->standardtable[charnr], -1);
+ if(ret) return ret;
}
}
- msg("<warning> Didn't find character '%s' in font '%s'", FIXNULL(name), this->name);
- return 0;
+ return -1;
}
int SWFFont::getWidth(char*name)
}
int SWFFont::getWidth(char*name)