X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fttf2pt1%2Fft.c;h=12f44c652d7b948ab44eff914ead18a25989f84a;hb=4db572fa920c77654159a3041a39baf076272c23;hp=9b65785b92abb0029c73435b5a667003be1704ff;hpb=92c5f229fdf4d1a1d1efd8205dae033e70d07a1a;p=swftools.git diff --git a/pdf2swf/ttf2pt1/ft.c b/pdf2swf/ttf2pt1/ft.c index 9b65785..12f44c6 100644 --- a/pdf2swf/ttf2pt1/ft.c +++ b/pdf2swf/ttf2pt1/ft.c @@ -5,6 +5,7 @@ * */ +#include "../../config.h" #ifdef USE_FREETYPE #include @@ -14,7 +15,7 @@ #include #include #include -#include +#include #include #include #include "pt1.h" @@ -51,7 +52,7 @@ struct frontsw freetype_sw = { /* statics */ -static char * dupcnstring( char *s, int len); +static char * dupcnstring( unsigned char *s, int len); static FT_Library library; static FT_Face face; @@ -153,10 +154,9 @@ glnames( for(i=0; i < face->num_glyphs; i++) { if( FT_Get_Glyph_Name(face, i, bf, MAX_NAMELEN) || bf[0]==0 ) { - sprintf(bf, "_%d", i); + sprintf(bf, "_g_%d", i); WARNING_2 fprintf(stderr, - "**** Glyph No. %d has no postscript name, becomes %s ****\n", - i, bf); + "Glyph No. %d has no postscript name, becomes %s\n", i, bf); } glyph_list[i].name = strdup(bf); if(ISDBG(FT)) fprintf(stderr, "%d has name %s\n", i, bf); @@ -308,9 +308,8 @@ glenc( e = 0; } - if( FT_Set_Charmap(face, face->charmaps[e]) ) { + if( !face->charmaps || FT_Set_Charmap(face, face->charmaps[e]) ) { fprintf(stderr, "**** Cannot set charmap in FreeType ****\n"); - exit(1); } populate_map: @@ -338,19 +337,29 @@ populate_map: /* duplicate a string with counter to a 0-terminated string */ static char * dupcnstring( - char *s, + unsigned char *s, int len ) { - char *res; + char *res, *out; + int i, c; + static int warned=0; if(( res = malloc(len+1) )==NULL) { fprintf (stderr, "****malloc failed %s line %d\n", __FILE__, __LINE__); exit(255); } - memcpy(res, s, len); - res[len] = 0; + out = res; + for(i=0; i=' ' && c!=127) + *out++ = c; + else if(!warned) { + warned=1; + WARNING_1 fprintf(stderr, "Some font name strings are in Unicode, may not show properly\n"); + } + } + *out = 0; return res; } @@ -405,6 +414,10 @@ fnmetrics( { int len; + if(!fm->name_family) + fm->name_family = ""; + if(!fm->name_style) + fm->name_style= ""; len = strlen(fm->name_family) + strlen(fm->name_style) + 2; if(( fm->name_full = malloc(len) )==NULL) { fprintf (stderr, "****malloc failed %s line %d\n", __FILE__, __LINE__); @@ -441,6 +454,9 @@ fnmetrics( } else fm->name_ps = dupcnstring(sn.string, sn.string_len); #endif /* ENABLE_SFNT */ + for(i=0; fm->name_ps[i]!=0; i++) + if(fm->name_ps[i] == ' ') + fm->name_ps[i] = '_'; /* no spaces in the Postscript name */ /* guess the boldness from the font names */ fm->force_bold=0; @@ -450,14 +466,15 @@ fnmetrics( fieldstocheck[2] = fm->name_ps; for(i=0; !fm->force_bold && iforce_bold=1; break;