new option config_fontquality
[swftools.git] / lib / pdf / GFXOutputDev.cc
index da5df32..91ecf07 100644 (file)
@@ -368,6 +368,7 @@ GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc)
     this->config_remapunicode=0;
     this->config_transparent=0;
     this->config_extrafontdata = 0;
+    this->config_fontquality = 10;
 
     this->gfxfontlist = gfxfontlist_create();
   
@@ -384,12 +385,17 @@ void GFXOutputDev::setParameter(const char*key, const char*value)
         this->config_transparent = atoi(value);
     } else if(!strcmp(key,"extrafontdata")) {
         this->config_extrafontdata = atoi(value);
+    } else if(!strcmp(key,"fontquality")) {
+        this->config_fontquality = atof(value);
+       if(this->config_fontquality<=1)
+           this->config_fontquality=1;
     } else if(!strcmp(key,"help")) {
        printf("\nPDF layer options:\n");
        printf("breakonwarning=0/1  Abort conversion if graphic objects are found which\n");
        printf("                    are not 100%% supported\n");
        printf("transparent=0/1     Make PDF transparent (alpha background)\n");
        printf("extrafontdata=0/1   Store Type3 characters and capture characters\n");
+       printf("fontquality=1..100  Curve approximation quality of the fonts\n");
     }
     
 }
@@ -836,7 +842,7 @@ GFXOutputDev::~GFXOutputDev()
        free(this->pages); this->pages = 0;
     }
 
-    gfxfontlist_free(this->gfxfontlist, 1);
+    gfxfontlist_free(this->gfxfontlist, 1);this->gfxfontlist = 0;
 };
 GBool GFXOutputDev::upsideDown() 
 {
@@ -850,12 +856,6 @@ GBool GFXOutputDev::useDrawChar()
 const char*renderModeDesc[]= {"fill", "stroke", "fill+stroke", "invisible",
                       "clip+fill", "stroke+clip", "fill+stroke+clip", "clip"};
 
-#define RENDER_FILL 0
-#define RENDER_STROKE 1
-#define RENDER_FILLSTROKE 2
-#define RENDER_INVISIBLE 3
-#define RENDER_CLIP 4
-
 static char tmp_printstr[4096];
 char* makeStringPrintable(char*str)
 {
@@ -1425,7 +1425,7 @@ void GFXOutputDev::updateStrokeColor(GfxState *state)
 }
 
 
-gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src)
+gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src, double config_fontquality)
 {
     gfxfont_t*font = (gfxfont_t*)malloc(sizeof(gfxfont_t));
     memset(font, 0, sizeof(gfxfont_t));
@@ -1434,7 +1434,8 @@ gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src)
     memset(font->glyphs, 0, sizeof(gfxglyph_t)*src->num_glyphs);
     font->id = strdup(getFontID(xpdffont));
     int t;
-    double quality = (INTERNAL_FONT_SIZE * 0.05) / src->max_size;
+    
+    double quality = (INTERNAL_FONT_SIZE * 200 / config_fontquality) / src->max_size;
     double scale = 1;
     //printf("%d glyphs\n", font->num_glyphs);
     font->num_glyphs = 0;
@@ -1525,7 +1526,7 @@ void GFXOutputDev::updateFont(GfxState *state)
     
     gfxfont_t*font = gfxfontlist_findfont(this->gfxfontlist,id);
     if(!font) {
-       font = createGfxFont(gfxFont, current_fontinfo);
+       font = createGfxFont(gfxFont, current_fontinfo, this->config_fontquality);
         font->id = strdup(id);
        this->gfxfontlist = gfxfontlist_addfont(this->gfxfontlist, font);
        device->addfont(device, font);