added custom font scaling.
[swftools.git] / lib / modules / swffont.c
index 7ed72ed..ab77363 100644 (file)
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
+static int loadfont_scale = 1;
+
+int swf_SetLoadFontScale(int scale)
+{
+    loadfont_scale = scale;
+}
+
 #ifdef HAVE_FREETYPE
 
 #include <freetype/freetype.h>
@@ -29,7 +36,7 @@
 #include <freetype/ttnameid.h>
 #include <freetype/ftoutln.h>
 
-#define FT_SCALE 1
+#define FT_SCALE loadfont_scale
 #define FT_SUBPIXELS 64
 
 static int ft_move_to(FT_Vector* _to, void* user) 
@@ -133,7 +140,7 @@ SWFFONT* swf_LoadTrueTypeFont(char*filename)
 
     font->layout->ascent = face->ascender*20/FT_SUBPIXELS; //face->bbox.xMin;
     font->layout->descent = abs(face->descender)*20/FT_SUBPIXELS; //face->bbox.xMax;
-    font->layout->leading = -face->bbox.xMin*20/FT_SUBPIXELS;
+    font->layout->leading = abs(face->bbox.yMin - face->bbox.yMax); //-face->bbox.xMin*20/FT_SUBPIXELS;
     font->layout->kerningcount = 0;
     
     name = FT_Get_Postscript_Name(face);
@@ -256,7 +263,6 @@ SWFFONT* swf_LoadTrueTypeFont(char*filename)
        FT_Done_Glyph(glyph);
        font->glyph2ascii[font->numchars] = font->glyph2ascii[t];
        glyph2glyph[t] = font->numchars;
-       printf("%d %d\n", t, glyph2glyph[t]);
        font->numchars++;
     }
     /* notice: if skipunused is true, font->glyph2ascii, font->glyphnames and font->layout->bounds will 
@@ -266,7 +272,6 @@ SWFFONT* swf_LoadTrueTypeFont(char*filename)
     for(t=0;t<font->maxascii;t++) {
        if(font->ascii2glyph[t]>=0) {
            font->ascii2glyph[t] = glyph2glyph[font->ascii2glyph[t]];
-           printf("ascii %d -> glyph %d\n", t, font->ascii2glyph[t]);
        }
     }
     free(glyph2glyph);